fix improper reading on VERSION #40
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Package | |
on: | |
push: | |
branches: | |
- 'no-cgo' | |
permissions: | |
contents: read | |
defaults: | |
run: | |
shell: bash | |
env: | |
RELEASE: ${{ github.run_number }} | |
SENTRY: ${{ secrets.SENTRY_DSN }} | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
arch: [ amd64, arm64 ] | |
exclude: # These systems are incompatible with our client anyway | |
- os: ubuntu-latest | |
arch: arm64 | |
- os: windows-latest | |
arch: arm64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: WillAbides/setup-go-faster@v1.14.0 | |
with: | |
go-version-file: 'go.mod' | |
- name: Read version | |
run: | | |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV | |
- name: Prepare environment | |
env: | |
OS: ${{ matrix.os }} | |
ARCH: ${{ matrix.arch }} | |
run: | | |
# Add OS-specific flags | |
FLAGS="-trimpath" | |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
FLAGS+=" -buildmode=pie" | |
fi | |
LDFLAGS="-s -w -X main.version=${VERSION} -X main.sentryDSN=${SENTRY}" | |
if [ "${{ matrix.arch }}" = "windows-latest" ]; then | |
LDFLAGS+=" -H=windowsgui" | |
fi | |
# Send to env | |
echo "FLAGS=${FLAGS}" >> $GITHUB_ENV | |
echo "LDFLAGS=${LDFLAGS}" >> $GITHUB_ENV | |
- name: Build project | |
run: >- | |
env | |
CGO_ENABLED=0 | |
GOARCH="${{ matrix.arch }}" | |
go build | |
-o bin/pinnacle | |
${FLAGS} -ldflags="${LDFLAGS}" | |
pinnacle/src | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pinnacle-${{ matrix.os }}-${{ matrix.arch }} | |
path: bin/pinnacle | |
retention-days: 1 | |
package_windows: | |
needs: build | |
strategy: | |
matrix: | |
arch: [ amd64, arm64 ] | |
exclude: | |
- arch: arm64 | |
runs-on: windows-latest | |
steps: | |
- name: Checkout .iss files | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
pkg/windows | |
VERSION | |
- name: Download binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: pinnacle-windows-latest-${{ matrix.arch }} | |
path: bin/windows | |
- name: Read version | |
run: | | |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV | |
- name: Set env variables | |
run: | | |
if [ "${{ matrix.arch }}" = "amd64" ]; then | |
ARCH_NAME="x86_64" | |
elif [ "${{ matrix.arch }}" = "arm64" ]; then | |
ARCH_NAME="ARM64" | |
else | |
ARCH_NAME="???" | |
fi | |
echo "ARCH_NAME=${ARCH_NAME}" >> $GITHUB_ENV | |
- name: Prepare for packaging | |
run: | | |
# Set variable for .iss file path | |
ISS_FILE="pkg/windows/iss/PackagePinnacle-${{ matrix.arch }}.iss" | |
# Edit versions in iss file | |
sed -i "s/#define MyAppVersion \"1.0.0\"/#define MyAppVersion \"${VERSION}\"/" "$ISS_FILE" | |
# Rename binary | |
mv "bin/windows/pinnacle" "bin/windows/pinnacle-windows-${{ matrix.arch }}.exe" | |
# Export env variable | |
echo "ISS_FILE=${ISS_FILE}" >> $GITHUB_ENV | |
- name: Package with Inno Setup | |
run: | | |
iscc.exe "$ISS_FILE" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: AlpineClientSetup-${{ env.VERSION }}-${{ env.ARCH_NAME }}.exe | |
path: build/out/AlpineClientSetup-${{ env.VERSION }}-${{ env.ARCH_NAME }}.exe | |
retention-days: 1 | |
package_linux: | |
needs: build | |
strategy: | |
matrix: | |
arch: [ amd64 , arm64 ] | |
exclude: | |
- arch: arm64 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout pkg files | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
pkg/linux | |
VERSION | |
- name: Download binary | |
uses: actions/download-artifact@v4 | |
with: | |
name: pinnacle-ubuntu-latest-${{ matrix.arch }} | |
path: bin/linux | |
- name: Install dependencies | |
run: >- | |
sudo apt-get update && | |
sudo apt-get install -y | |
rpm | |
debhelper | |
devscripts | |
dpkg-dev | |
- name: Read version | |
run: | | |
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV | |
- name: Prepare for packaging | |
run: | | |
# Edit version in specs/control files | |
sed -i "s/^Version:.*/Version: ${VERSION}/" pkg/linux/rpm/SPECS/pinnacle.spec | |
sed -i "s/^Release:.*/Release: ${RELEASE}/" pkg/linux/rpm/SPECS/pinnacle.spec | |
sed -i "s/^Version:.*/Version: ${VERSION}-${RELEASE}/" pkg/linux/deb/DEBIAN/control | |
# Set up rpmbuild/debbuild file tree | |
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} | |
mkdir -p ~/debbuild/alpine-client/{DEBIAN,usr/bin,usr/share/applications,usr/share/pixmaps} | |
# Copy resources | |
cp -r pkg/linux/rpm/* ~/rpmbuild/ | |
cp -r pkg/linux/deb/* ~/debbuild/alpine-client/ | |
# Copy binaries | |
cp "bin/linux/pinnacle" ~/rpmbuild/SOURCES/pinnacle-linux-${{ matrix.arch }} | |
cp "bin/linux/pinnacle" ~/debbuild/alpine-client/usr/bin/alpine-client | |
# Make binaries executable | |
chmod +x ~/rpmbuild/SOURCES/pinnacle-linux-${{ matrix.arch }} | |
chmod +x ~/debbuild/alpine-client/usr/bin/alpine-client | |
# Create output folder | |
mkdir -p build/out | |
- name: Package RPM | |
run: >- | |
rpmbuild -bb | |
~/rpmbuild/SPECS/pinnacle.spec | |
--define "_rpmdir build/out" | |
--target=x86_64 | |
- name: Package DEB | |
run: >- | |
dpkg-deb -Zgzip | |
--build ~/debbuild/alpine-client | |
"build/out/alpine-client_${VERSION}-${RELEASE}_amd64.deb" | |
- name: Tidy artifact | |
run: | | |
cp -r build/out/x86_64/* build/out/ | |
rm -rf build/out/x86_64 | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-installers-${{ env.VERSION }}-x86_64 | |
path: build/out | |
retention-days: 1 | |
# package_macos: | |
# runs-on: macos-latest | |
# needs: build_macos | |
# steps: | |
# - name: Checkout pkg/darwin | |
# uses: actions/checkout@v4 | |
# with: | |
# sparse-checkout: | | |
# pkg/darwin | |
# VERSION | |
# | |
# - name: Download binaries | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: macos-binaries | |
# path: bin | |
# | |
# - name: Read version | |
# run: | | |
# echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV | |
# | |
# - name: Set up environment | |
# run: | | |
# # Set env variables for paths | |
# APP="pkg/darwin/Alpine Client.app/Contents" | |
# | |
# # Create necessary folders | |
# mkdir "${APP}/MacOS" | |
# mkdir -p build/out/ | |
# | |
# # Replace version in Info.plist files | |
# sed -i '' "s/<string>1.0.0<\/string>/<string>${VERSION}<\/string>/" "${APP}/Info.plist" | |
# | |
# # Move compiled binary | |
# cp bin/pinnacle-darwin-amd64 "${APP}/MacOS/pinnacle-darwin-amd64" | |
# | |
# # Set permissions | |
# chmod +x "${APP}/MacOS/pinnacle-darwin-amd64" | |
# | |
# # Export APP env for later | |
# echo "APP=${APP}" >> $GITHUB_ENV | |
# | |
# - name: Package for amd64 | |
# run: >- | |
# pkgbuild | |
# --root pkg/darwin | |
# --identifier com.alpineclient.pinnacle | |
# --version "$VERSION" | |
# --install-location /Applications | |
# "build/out/AlpineClientSetup-${VERSION}-x86_64.pkg" | |
# | |
# - name: Swap and64 binary for arm64 | |
# run: | | |
# rm -f "${APP}/MacOS/pinnacle-darwin-amd64" | |
# cp bin/pinnacle-darwin-arm64 "${APP}/MacOS/pinnacle-darwin-arm64" | |
# sed -i '' 's/amd64/arm64/g' "${APP}/Info.plist" | |
# chmod +x "${APP}/MacOS/pinnacle-darwin-arm64" | |
# | |
# - name: Package for arm64 | |
# run: >- | |
# pkgbuild | |
# --root pkg/darwin | |
# --identifier com.alpineclient.pinnacle | |
# --version "$VERSION" | |
# --install-location /Applications | |
# "build/out/AlpineClientSetup-${VERSION}-ARM64.pkg" | |
# | |
# - name: Upload artifact | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: macos-installers | |
# path: build/out | |
# retention-days: 1 | |
# | |
# merge_artifacts: | |
# needs: [ package_windows, package_linux, package_macos ] | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Download | |
# uses: actions/download-artifact@v4 | |
# with: | |
# path: all | |
# | |
# - name: Reorganize | |
# run: | | |
# mkdir -p merged/{binaries,installers} | |
# | |
# # Combine binaries | |
# cp -r all/windows-linux-binaries/*/ merged/binaries/ | |
# cp -r all/macos-binaries/* merged/binaries/ | |
# | |
# # Combine installers | |
# cp -r all/windows-installers/* merged/installers/ | |
# cp -r all/macos-installers/* merged/installers/ | |
# cp -r all/linux-installers/* merged/installers/ | |
# | |
# - name: Upload | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: all-artifacts-${{ env.RELEASE }} | |
# path: merged | |
# compression-level: 9 | |
# retention-days: 90 |