Refactor release workflow to streamline binary builds and packaging
CI / Go Tests (push) Successful in 13s
CI / Build (push) Successful in 11s
Format / gofmt (push) Successful in 8s
Release Artifacts / Build and publish release (push) Successful in 14s

- 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.
This commit is contained in:
2026-06-01 02:17:42 -05:00
parent 051e3c3c64
commit 56fd479761
2 changed files with 40 additions and 51 deletions
+39 -50
View File
@@ -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
+1 -1
View File
@@ -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: