Spaces:
Running
Running
| name: Publish release binaries | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| binary-release-linux: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - goos: linux | |
| goarch: amd64 | |
| cc: gcc | |
| asset_arch: amd64 | |
| - goos: linux | |
| goarch: arm64 | |
| cc: aarch64-linux-gnu-gcc | |
| asset_arch: arm64 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| check-latest: true | |
| cache: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| cache: npm | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install build dependencies | |
| run: sudo apt-get update && sudo apt-get install -y build-essential gcc-aarch64-linux-gnu | |
| - name: Install frontend dependencies | |
| run: npm --prefix ./web ci | |
| - name: Build frontend | |
| run: npm --prefix ./web run build | |
| - name: Build binary package | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CC: ${{ matrix.cc }} | |
| ASSET_ARCH: ${{ matrix.asset_arch }} | |
| run: | | |
| set -euo pipefail | |
| package_name="cpa-usage-keeper_${VERSION}_${GOOS}_${ASSET_ARCH}" | |
| package_dir="dist/${package_name}" | |
| mkdir -p "${package_dir}/data" | |
| CGO_ENABLED=1 GOOS="${GOOS}" GOARCH="${GOARCH}" CC="${CC}" \ | |
| go build -trimpath -ldflags="-s -w" -o "${package_dir}/cpa-usage-keeper" ./cmd/server/main.go | |
| cp .env.example README.md README.en.md LICENSE CONTRIBUTORS.md "${package_dir}/" | |
| tar -czf "dist/${package_name}.tar.gz" -C dist "${package_name}" | |
| - name: Upload binary package artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: cpa-usage-keeper-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.asset_arch }} | |
| path: dist/cpa-usage-keeper_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.asset_arch }}.tar.gz | |
| if-no-files-found: error | |
| binary-release-darwin: | |
| runs-on: ${{ matrix.runs_on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - goos: darwin | |
| goarch: amd64 | |
| asset_arch: amd64 | |
| runs_on: macos-15-intel | |
| - goos: darwin | |
| goarch: arm64 | |
| asset_arch: arm64 | |
| runs_on: macos-15 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| check-latest: true | |
| cache: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| cache: npm | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install frontend dependencies | |
| run: npm --prefix ./web ci | |
| - name: Build frontend | |
| run: npm --prefix ./web run build | |
| - name: Build binary package | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| ASSET_ARCH: ${{ matrix.asset_arch }} | |
| run: | | |
| set -euo pipefail | |
| package_name="cpa-usage-keeper_${VERSION}_${GOOS}_${ASSET_ARCH}" | |
| package_dir="dist/${package_name}" | |
| mkdir -p "${package_dir}/data" | |
| CGO_ENABLED=1 GOOS="${GOOS}" GOARCH="${GOARCH}" \ | |
| go build -trimpath -ldflags="-s -w" -o "${package_dir}/cpa-usage-keeper" ./cmd/server/main.go | |
| cp .env.example README.md README.en.md LICENSE CONTRIBUTORS.md "${package_dir}/" | |
| tar -czf "dist/${package_name}.tar.gz" -C dist "${package_name}" | |
| - name: Upload binary package artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: cpa-usage-keeper-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.asset_arch }} | |
| path: dist/cpa-usage-keeper_${{ github.ref_name }}_${{ matrix.goos }}_${{ matrix.asset_arch }}.tar.gz | |
| if-no-files-found: error | |
| binary-release-windows: | |
| runs-on: ${{ matrix.runs_on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - goarch: amd64 | |
| asset_arch: amd64 | |
| runs_on: windows-2025 | |
| msystem: UCRT64 | |
| install: mingw-w64-ucrt-x86_64-gcc | |
| cc: gcc | |
| - goarch: arm64 | |
| asset_arch: arm64 | |
| runs_on: windows-11-arm | |
| msystem: CLANGARM64 | |
| install: mingw-w64-clang-aarch64-gcc | |
| cc: gcc | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| check-latest: true | |
| cache: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| cache: npm | |
| cache-dependency-path: web/package-lock.json | |
| - name: Set up MSYS2 | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: ${{ matrix.msystem }} | |
| update: true | |
| path-type: inherit | |
| install: ${{ matrix.install }} | |
| - name: Install frontend dependencies | |
| shell: bash | |
| run: npm --prefix ./web ci | |
| - name: Build frontend | |
| shell: bash | |
| run: npm --prefix ./web run build | |
| - name: Build binary package | |
| shell: msys2 {0} | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| GOOS: windows | |
| GOARCH: ${{ matrix.goarch }} | |
| ASSET_ARCH: ${{ matrix.asset_arch }} | |
| CC: ${{ matrix.cc }} | |
| run: | | |
| set -euo pipefail | |
| package_name="cpa-usage-keeper_${VERSION}_${GOOS}_${ASSET_ARCH}" | |
| package_dir="dist/${package_name}" | |
| mkdir -p "${package_dir}/data" | |
| CGO_ENABLED=1 GOOS="${GOOS}" GOARCH="${GOARCH}" CC="${CC}" \ | |
| go build -trimpath -ldflags="-s -w" -o "${package_dir}/cpa-usage-keeper.exe" ./cmd/server/main.go | |
| cp .env.example README.md README.en.md LICENSE CONTRIBUTORS.md "${package_dir}/" | |
| - name: Archive binary package | |
| shell: pwsh | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| ASSET_ARCH: ${{ matrix.asset_arch }} | |
| run: | | |
| $packageName = "cpa-usage-keeper_${env:VERSION}_windows_${env:ASSET_ARCH}" | |
| Compress-Archive -Path "dist/$packageName" -DestinationPath "dist/$packageName.zip" | |
| - name: Upload binary package artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: cpa-usage-keeper-${{ github.ref_name }}-windows-${{ matrix.asset_arch }} | |
| path: dist/cpa-usage-keeper_${{ github.ref_name }}_windows_${{ matrix.asset_arch }}.zip | |
| if-no-files-found: error | |
| publish-release: | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - binary-release-linux | |
| - binary-release-darwin | |
| - binary-release-windows | |
| steps: | |
| - name: Download binary package artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| set -euo pipefail | |
| cd dist | |
| sha256sum *.tar.gz *.zip > checksums.txt | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| dist/checksums.txt | |