Files
scratchbox/.gitea/workflows/release.yaml
T
s1d3sw1ped 7968d47030
CI / Go Tests (push) Successful in 13s
CI / Build (push) Successful in 12s
Format / gofmt (push) Successful in 7s
Release Artifacts / Build and publish release (push) Successful in 12s
Enhance release workflow and documentation for tag validation and release notes generation
- Added validation for accepted release tag formats in the release workflow.
- Implemented a step to generate release notes based on changes since the last tag.
- Updated README.md to include accepted tag formats for stable and prerelease versions.
- Adjusted archive naming convention for consistency in release artifacts.
2026-06-01 02:33:47 -05:00

137 lines
4.0 KiB
YAML

name: Release Artifacts
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
release:
name: Build and publish release
runs-on: ubuntu-latest
steps:
- name: Validate tag and determine prerelease flag
id: release_meta
shell: bash
run: |
set -eu
tag="${{ github.ref_name }}"
# Allowed tags:
# - Stable: 1.2.3
# - Prerelease: 1.2.3-alpha1 | 1.2.3-beta1 | 1.2.3-rc1
if [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "prerelease=false" >> "${GITHUB_OUTPUT}"
elif [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)[0-9]+$ ]]; then
echo "prerelease=true" >> "${GITHUB_OUTPUT}"
else
echo "Invalid tag format: ${tag}"
echo "Expected one of:"
echo " - 1.2.3"
echo " - 1.2.3-alpha1"
echo " - 1.2.3-beta1"
echo " - 1.2.3-rc1"
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: web/ui/package-lock.json
- name: Install UI deps
run: npm --prefix ./web/ui ci
- name: Build UI assets
run: npm --prefix ./web/ui run build
- name: Build release binaries
shell: bash
run: |
set -eu
mkdir -p dist
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: |
set -eu
rm -rf release-packages
mkdir -p release-packages
for bin in dist/scratchbox-linux-*; do
name="$(basename "${bin}")"
archive="scratchbox-${{ github.ref_name }}-${name#scratchbox-}.tar.gz"
stage="release-packages/${name}"
rm -rf "${stage}"
mkdir -p "${stage}"
cp README.md "${stage}/"
cp "${bin}" "${stage}/"
tar -C "${stage}" -czf "${archive}" .
done
- name: Generate release notes
shell: bash
run: |
set -eu
current_tag="${{ github.ref_name }}"
prev_tag="$(git tag --sort=-creatordate | awk -v cur="${current_tag}" '$0 != cur { print; exit }')"
{
echo "## Release ${current_tag}"
echo
if [ -n "${prev_tag}" ]; then
echo "Changes since \`${prev_tag}\`:"
echo
git log --pretty='- %h %s' "${prev_tag}..${current_tag}"
else
echo "Changes in this release:"
echo
git log --pretty='- %h %s' "${current_tag}"
fi
echo
echo "## Artifacts"
echo
echo "- \`linux-amd64-default\`"
echo "- \`linux-amd64-static\`"
echo "- \`linux-arm64-default\`"
echo "- \`linux-arm64-static\`"
} > RELEASE_NOTES.md
- name: Create release and upload archives
uses: https://gitea.com/actions/gitea-release-action@v1
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
prerelease: ${{ steps.release_meta.outputs.prerelease }}
body_path: RELEASE_NOTES.md
files: |-
scratchbox-${{ github.ref_name }}-linux-*.tar.gz