From 56fd47976196ce44338c1131d74f38ffc58a2130 Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Mon, 1 Jun 2026 02:17:42 -0500 Subject: [PATCH] Refactor release workflow to streamline binary builds and packaging - Updated the release workflow to consolidate build steps for different architectures. - Changed the variant name in README.md for clarity on static binaries compatibility. - Enhanced the packaging process to create release archives for each binary built. - Removed the matrix strategy for builds, simplifying the CI configuration. --- .gitea/workflows/release.yaml | 89 +++++++++++++++-------------------- README.md | 2 +- 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index a5e7d98..1c6191d 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -7,29 +7,9 @@ on: workflow_dispatch: jobs: - build: - name: Build ${{ matrix.goos }}/${{ matrix.goarch }} (${{ matrix.variant }}) + release: + name: Build and publish release runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - goos: linux - goarch: amd64 - variant: default - static: false - - goos: linux - goarch: amd64 - variant: alpine-static - static: true - - goos: linux - goarch: arm64 - variant: default - static: false - - goos: linux - goarch: arm64 - variant: alpine-static - static: true steps: - name: Checkout uses: actions/checkout@v4 @@ -53,40 +33,49 @@ jobs: - name: Build UI assets run: npm --prefix ./web/ui run build - - name: Build binary + - name: Build release binaries shell: bash run: | + set -eu mkdir -p dist - if [[ "${{ matrix.static }}" == "true" ]]; then - CGO_ENABLED=0 GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" \ - go build -trimpath -tags "netgo osusergo" \ - -ldflags "-s -w" \ - -o "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" \ - ./cmd/scratchbox - else - CGO_ENABLED=0 GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" \ - go build -trimpath \ - -ldflags "-s -w" \ - -o "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" \ - ./cmd/scratchbox - fi - - name: Verify static linux binary - if: ${{ matrix.static }} + for arch in amd64 arm64; do + base="scratchbox-linux-${arch}" + + CGO_ENABLED=0 GOOS=linux GOARCH="${arch}" \ + go build -trimpath -ldflags "-s -w" \ + -o "dist/${base}-default" ./cmd/scratchbox + + CGO_ENABLED=0 GOOS=linux GOARCH="${arch}" \ + go build -trimpath -tags "netgo osusergo" -ldflags "-s -w" \ + -o "dist/${base}-static" ./cmd/scratchbox + + file "dist/${base}-static" | grep -q "statically linked" + done + + - name: Package release archives shell: bash run: | - file "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" | grep -q "statically linked" + set -eu + rm -rf release-packages + mkdir -p release-packages - - name: Package artifact - shell: bash - run: | - mkdir -p artifacts - cp README.md artifacts/ - cp "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" artifacts/ - tar -C artifacts -czf "scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}.tar.gz" . + for bin in dist/scratchbox-linux-*; do + name="$(basename "${bin}")" + archive="scratchbox-${{ github.ref_name }}-${name}.tar.gz" + stage="release-packages/${name}" - - name: Upload artifact - uses: https://gitea.com/actions/gitea-upload-artifact@v4 + rm -rf "${stage}" + mkdir -p "${stage}" + cp README.md "${stage}/" + cp "${bin}" "${stage}/" + tar -C "${stage}" -czf "${archive}" . + done + + - name: Create release and upload archives + uses: https://gitea.com/actions/gitea-release-action@v1 with: - name: scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }} - path: scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}.tar.gz + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} + files: |- + scratchbox-${{ github.ref_name }}-linux-*.tar.gz diff --git a/README.md b/README.md index 62c5665..368912b 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Variant guide: | Variant | Recommended for | Notes | | --- | --- | --- | | `default` | Most Linux distributions (Ubuntu, Debian, Fedora, Arch, etc.) | Smaller, dynamically linked Linux build | -| `alpine-static` | Alpine Linux / musl-based environments | Statically linked for better compatibility | +| `static` | Any Linux distro (including Alpine/musl) | Statically linked for maximum Linux compatibility | To unpack an artifact: