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.
This commit is contained in:
@@ -7,29 +7,9 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
release:
|
||||||
name: Build ${{ matrix.goos }}/${{ matrix.goarch }} (${{ matrix.variant }})
|
name: Build and publish release
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -53,40 +33,49 @@ jobs:
|
|||||||
- name: Build UI assets
|
- name: Build UI assets
|
||||||
run: npm --prefix ./web/ui run build
|
run: npm --prefix ./web/ui run build
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build release binaries
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
set -eu
|
||||||
mkdir -p dist
|
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
|
for arch in amd64 arm64; do
|
||||||
if: ${{ matrix.static }}
|
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
|
shell: bash
|
||||||
run: |
|
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
|
for bin in dist/scratchbox-linux-*; do
|
||||||
shell: bash
|
name="$(basename "${bin}")"
|
||||||
run: |
|
archive="scratchbox-${{ github.ref_name }}-${name}.tar.gz"
|
||||||
mkdir -p artifacts
|
stage="release-packages/${name}"
|
||||||
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" .
|
|
||||||
|
|
||||||
- name: Upload artifact
|
rm -rf "${stage}"
|
||||||
uses: https://gitea.com/actions/gitea-upload-artifact@v4
|
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:
|
with:
|
||||||
name: scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}
|
tag_name: ${{ github.ref_name }}
|
||||||
path: scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}.tar.gz
|
name: ${{ github.ref_name }}
|
||||||
|
files: |-
|
||||||
|
scratchbox-${{ github.ref_name }}-linux-*.tar.gz
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ Variant guide:
|
|||||||
| Variant | Recommended for | Notes |
|
| Variant | Recommended for | Notes |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `default` | Most Linux distributions (Ubuntu, Debian, Fedora, Arch, etc.) | Smaller, dynamically linked Linux build |
|
| `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:
|
To unpack an artifact:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user