ci: release automation from Conventional Commits
tools/release derives the next version from the commits since the last stable release and renders the changelog. `make release` tags it on main, CHANNEL=beta a numbered prerelease of the coming version; pushing the tag runs the release workflow, which publishes the release with its notes, Linux binaries and checksums. Images get channel tags: edge for main, beta for prereleases, latest, stable and X.Y for releases. Closes #33 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
1ad68e2e87
commit
68a7827475
8 files changed
+644
-5
No files matched your search
@@ -0,0 +1,58 @@
|
||||
name: release
|
||||
|
||||
# Runs for release tags, which `make release` creates. The image of a tag
|
||||
# is built by the ci workflow.
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
# The notes need the history back to the previous release.
|
||||
fetch-depth: 0
|
||||
- name: Install Go
|
||||
run: |
|
||||
v="$(awk '/^go /{print $2}' go.mod)"
|
||||
curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz
|
||||
echo /usr/local/go/bin >> "$GITHUB_PATH"
|
||||
- name: Check tag
|
||||
run: go run ./tools/release check "$GITHUB_REF_NAME"
|
||||
- name: Build frontend
|
||||
run: npm ci --no-audit --no-fund && npm run build
|
||||
- name: Build binaries
|
||||
run: |
|
||||
set -eu
|
||||
pkg=git.zb-server.de/ZB-Server/uptimesebi/internal/buildinfo
|
||||
commit="$(git rev-parse --short=12 HEAD)"
|
||||
for platform in linux/amd64 linux/arm64; do
|
||||
os=${platform%/*} arch=${platform#*/}
|
||||
dir="uptimesebi_${GITHUB_REF_NAME#v}_${os}_${arch}"
|
||||
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath \
|
||||
-ldflags "-s -w -X $pkg.Version=$GITHUB_REF_NAME -X $pkg.Commit=$commit" \
|
||||
-o "dist/$dir/" ./cmd/...
|
||||
cp LICENSE README.md .env.example "dist/$dir/"
|
||||
tar -C dist -czf "dist/$dir.tar.gz" "$dir"
|
||||
done
|
||||
(cd dist && sha256sum ./*.tar.gz | sed 's| \./| |' > SHA256SUMS)
|
||||
cat dist/SHA256SUMS
|
||||
- name: Publish release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY"
|
||||
if curl -fsS -o /dev/null -H "Authorization: token $TOKEN" "$api/releases/tags/$GITHUB_REF_NAME"; then
|
||||
echo "Release $GITHUB_REF_NAME exists already; delete it to publish again." >&2
|
||||
exit 1
|
||||
fi
|
||||
go run ./tools/release notes -json "$GITHUB_REF_NAME" > release.json
|
||||
id="$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
--data-binary @release.json "$api/releases" | grep -o '"id":[0-9]*' | head -n1 | cut -d: -f2)"
|
||||
for f in dist/*.tar.gz dist/SHA256SUMS; do
|
||||
curl -fsS -o /dev/null -X POST -H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$f" "$api/releases/$id/assets?name=$(basename "$f")"
|
||||
done
|
||||
Reference in new issue
Block a user