Merge pull request 'ci: release automation from Conventional Commits' (#126) from feat/release into main
This commit was merged in pull request #126.
This commit is contained in:
commit
b05f3dbdb0
8 files changed
+644
-5
No files matched your search
@@ -165,12 +165,21 @@ jobs:
|
||||
*) TAG="$(date -u +%Y%m%d%H%M%S)-$SHORT" ;;
|
||||
esac
|
||||
PUSH="--no-push"
|
||||
DEST="--destination ${IMAGE}:${TAG}"
|
||||
DEST="--destination ${IMAGE}:${TAG#v}"
|
||||
# Channels: edge follows main, beta the newest prerelease, latest
|
||||
# and stable the newest release, X.Y its newest patch.
|
||||
case "$GITHUB_REF" in
|
||||
refs/heads/main) CHANNELS="edge" ;;
|
||||
refs/tags/v*-beta.*) CHANNELS="beta" ;;
|
||||
refs/tags/v*)
|
||||
MINOR="$(printf '%s' "${TAG#v}" | cut -d. -f1-2)"
|
||||
CHANNELS="latest stable $MINOR" ;;
|
||||
esac
|
||||
case "$GITHUB_REF" in
|
||||
refs/heads/main|refs/tags/v*)
|
||||
if [ -n "${PACKAGE_TOKEN:-}" ]; then
|
||||
PUSH=""
|
||||
[ "$GITHUB_REF" = refs/heads/main ] && DEST="$DEST --destination ${IMAGE}:latest"
|
||||
for c in $CHANNELS; do DEST="$DEST --destination ${IMAGE}:$c"; done
|
||||
else
|
||||
echo "PACKAGE_TOKEN is not set; building without pushing."
|
||||
fi ;;
|
||||
|
||||
@@ -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