ci: trigger release build on published release instead of tag push
Both workflows now run on `release: published` and attach the built archives to the release the user creates, rather than pushing a tag and having the workflow create the release. Tag comes from the release event; GitHub no longer regenerates release notes. Docs updated accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,9 +11,8 @@ name: Release
|
|||||||
# Settings -> Actions -> Secrets. Without it the build still runs; only the
|
# Settings -> Actions -> Secrets. Without it the build still runs; only the
|
||||||
# upload step is skipped.
|
# upload step is skipped.
|
||||||
on:
|
on:
|
||||||
push:
|
release:
|
||||||
tags:
|
types: [published]
|
||||||
- "v*"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -71,8 +70,9 @@ jobs:
|
|||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
- name: Derive version
|
- name: Derive version
|
||||||
# On a tag push, strip the leading "v" so artifact names and the injected
|
# On a release, strip the leading "v" so artifact names and the injected
|
||||||
# app version match the release tag.
|
# app version match the release tag (the release event still sets
|
||||||
|
# GITHUB_REF_TYPE=tag / GITHUB_REF_NAME=<tag>).
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
|
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
|
||||||
@@ -93,14 +93,16 @@ jobs:
|
|||||||
mkdir -p dist/release
|
mkdir -p dist/release
|
||||||
cp dist/linux/*.tar.gz dist/windows/*.zip dist/release/
|
cp dist/linux/*.tar.gz dist/windows/*.zip dist/release/
|
||||||
|
|
||||||
- name: Publish release
|
- name: Attach assets to release
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
# Only runs for the release event; the release already exists, so this
|
||||||
|
# uploads the built archives to it. Skipped on workflow_dispatch.
|
||||||
|
if: ${{ github.event_name == 'release' }}
|
||||||
uses: https://code.forgejo.org/actions/forgejo-release@v2
|
uses: https://code.forgejo.org/actions/forgejo-release@v2
|
||||||
with:
|
with:
|
||||||
direction: upload
|
direction: upload
|
||||||
url: https://codeberg.org
|
url: https://codeberg.org
|
||||||
repo: ${{ github.repository }}
|
repo: ${{ github.repository }}
|
||||||
tag: ${{ github.ref_name }}
|
tag: ${{ github.event.release.tag_name }}
|
||||||
release-dir: dist/release
|
release-dir: dist/release
|
||||||
token: ${{ secrets.RELEASE_TOKEN }}
|
token: ${{ secrets.RELEASE_TOKEN }}
|
||||||
override: true
|
override: true
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
name: Release
|
name: Release
|
||||||
|
|
||||||
# Build the Linux (amd64/arm64) and Windows (amd64) binaries whenever a version
|
# Build the Linux (amd64/arm64) and Windows (amd64) binaries whenever a GitHub
|
||||||
# tag is pushed, then attach the packaged archives to a GitHub Release.
|
# Release is published, then attach the packaged archives to that release.
|
||||||
#
|
#
|
||||||
# Everything runs inside golang:1.22-bookworm — the same base image as the
|
# Everything runs inside golang:1.22-bookworm — the same base image as the
|
||||||
# repo Dockerfile — so the CGO/Fyne toolchain matches the local release builds.
|
# repo Dockerfile — so the CGO/Fyne toolchain matches the local release builds.
|
||||||
# The Windows binary is cross-compiled with MinGW-w64 from the same Linux job,
|
# The Windows binary is cross-compiled with MinGW-w64 from the same Linux job,
|
||||||
# which is why no windows-latest runner is needed.
|
# which is why no windows-latest runner is needed.
|
||||||
on:
|
on:
|
||||||
push:
|
release:
|
||||||
tags:
|
types: [published]
|
||||||
- "v*"
|
# Allow a manual run (from the Actions tab) to smoke-test the build without
|
||||||
# Allow a manual run (from the Actions tab) to smoke-test the build without a
|
# publishing a release. Manual runs build the artifacts but upload nothing.
|
||||||
# tag. Manual runs build the artifacts but do not publish a release.
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -58,9 +57,11 @@ jobs:
|
|||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
- name: Derive version
|
- name: Derive version
|
||||||
# For a tag push, use the tag without its leading "v" so the artifact
|
# For a release, use the tag without its leading "v" so the artifact
|
||||||
# names and the injected app version match the release. Otherwise fall
|
# names and the injected app version match the release (the release
|
||||||
# back to the version in source (handled by the build script).
|
# event still sets GITHUB_REF_TYPE=tag / GITHUB_REF_NAME=<tag>).
|
||||||
|
# Otherwise fall back to the version in source (handled by the build
|
||||||
|
# script).
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
ref="${GITHUB_REF_NAME:-}"
|
ref="${GITHUB_REF_NAME:-}"
|
||||||
@@ -83,11 +84,13 @@ jobs:
|
|||||||
dist/linux/*.tar.gz
|
dist/linux/*.tar.gz
|
||||||
dist/windows/*.zip
|
dist/windows/*.zip
|
||||||
|
|
||||||
- name: Publish release
|
- name: Attach assets to release
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
# Only runs for the release event; the release already exists, so this
|
||||||
|
# just uploads the built archives to it. Skipped on workflow_dispatch.
|
||||||
|
if: github.event_name == 'release'
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
|
tag_name: ${{ github.event.release.tag_name }}
|
||||||
files: |
|
files: |
|
||||||
dist/linux/*.tar.gz
|
dist/linux/*.tar.gz
|
||||||
dist/windows/*.zip
|
dist/windows/*.zip
|
||||||
generate_release_notes: true
|
|
||||||
|
|||||||
+8
-5
@@ -144,17 +144,20 @@ The Windows binary is cross-compiled with MinGW-w64 from the Linux job, so no
|
|||||||
Windows runner is required. Each archive contains the executable plus `README.md`
|
Windows runner is required. Each archive contains the executable plus `README.md`
|
||||||
and `CHANGELOG.md`, matching the local `package-*` scripts.
|
and `CHANGELOG.md`, matching the local `package-*` scripts.
|
||||||
|
|
||||||
To cut a release, bump `src/app/version.go` and push a matching `v` tag:
|
To cut a release, bump `src/app/version.go`, then create and publish a release
|
||||||
|
with a matching `v` tag on the forge (GitHub Releases / Codeberg releases). You
|
||||||
|
can do that from the web UI or the CLI, e.g.:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git tag v0.11.5
|
git tag v0.11.5
|
||||||
git push origin v0.11.5 # and to the Codeberg remote
|
git push origin v0.11.5 # and to the Codeberg remote
|
||||||
|
gh release create v0.11.5 --generate-notes # GitHub; publishes the release
|
||||||
```
|
```
|
||||||
|
|
||||||
The workflow strips the leading `v` from the tag and injects it as the version,
|
Publishing the release triggers the workflow: it strips the leading `v` from
|
||||||
so the tag must match `version.go`. Pushing the tag triggers the build and
|
the tag and injects it as the version (so the tag must match `version.go`),
|
||||||
attaches the archives to a release on that forge. `workflow_dispatch` also allows
|
builds the archives, and attaches them to that release. `workflow_dispatch`
|
||||||
a manual, publish-free build to smoke-test the pipeline.
|
also allows a manual, upload-free build to smoke-test the pipeline.
|
||||||
|
|
||||||
Codeberg publishing needs a repository secret named `RELEASE_TOKEN` (a Codeberg
|
Codeberg publishing needs a repository secret named `RELEASE_TOKEN` (a Codeberg
|
||||||
access token with the `write:repository` scope) under
|
access token with the `write:repository` scope) under
|
||||||
|
|||||||
Reference in New Issue
Block a user