sonda/.forgejo/workflows/release.yml
tgiachi 9905c4788f ci: pin the release tools to versions that work together
The preset of the commit messages in its 10th version cannot be read by the generator of
the release notes that semantic-release 25 comes with: use its 8th, and pin the
analyzer and the generator too. Found by a dry run before the first release.
2026-11-16 13:08:58 +01:00

88 lines
3.6 KiB
YAML

# What happens at every merge into main:
# 1. semantic-release reads the commits since the last release (Conventional Commits), works out the next version,
# writes CHANGELOG.md, makes the release on the forge and tags it. A merge with nothing to release (docs, tests, ci)
# makes none.
# 2. When there is a release, the image is built from the tag and pushed to git.kmalloc.org/squid/sonda as
# X.Y.Z, X.Y and latest.
# The runner has no Docker, so the image is built with kaniko, which needs no daemon.
# Secret needed: FORGEJO_TOKEN, a token of the owner with the scopes write:repository and write:package.
name: release
on:
push:
branches: [main]
# One release at a time: two merges close together must not make two versions at once.
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: docker
# The commit that the release makes (CHANGELOG.md) says [skip ci]; this is the belt for those braces.
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # the whole history: the next version depends on every commit since the last tag
token: ${{ secrets.FORGEJO_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Release
env:
GITEA_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
GITEA_URL: https://git.kmalloc.org
GIT_AUTHOR_NAME: sonda-release
GIT_AUTHOR_EMAIL: squid@kmalloc.org
GIT_COMMITTER_NAME: sonda-release
GIT_COMMITTER_EMAIL: squid@kmalloc.org
run: >
npx --yes
-p semantic-release@25
-p @semantic-release/commit-analyzer@13.0.1
-p @semantic-release/release-notes-generator@14.1.1
-p @semantic-release/changelog@7.0.0
-p @semantic-release/git@11.0.1
-p conventional-changelog-conventionalcommits@8.0.0
-p @saithodev/semantic-release-gitea@2.1.0
semantic-release
- name: Which version was made, if any
id: version
run: |
# The tag of a release points at the commit the release made, which is where the checkout now is.
tag="$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)"
echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
echo "released: ${tag:-nothing}"
image:
needs: release
if: ${{ needs.release.outputs.version != '' }}
runs-on: docker
container:
image: gcr.io/kaniko-project/executor:v1.23.2-debug
steps:
- name: Build the image from the tag and push it
env:
VERSION: ${{ needs.release.outputs.version }}
REGISTRY_USER: squid
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: |
set -eu
mkdir -p /kaniko/.docker
auth="$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" | base64 | tr -d '\n')"
printf '{"auths":{"git.kmalloc.org":{"auth":"%s"}}}' "$auth" > /kaniko/.docker/config.json
image=git.kmalloc.org/squid/sonda
minor="${VERSION%.*}"
/kaniko/executor \
--dockerfile Dockerfile \
--context "git://git.kmalloc.org/squid/sonda.git#refs/tags/v${VERSION}" \
--build-arg "VERSION=${VERSION}" \
--label "org.opencontainers.image.version=${VERSION}" \
--destination "${image}:${VERSION}" \
--destination "${image}:${minor}" \
--destination "${image}:latest" \
--verbosity info