Files
Classic298 5ede3bdcc5 ci: Docker images are never tagged with the release version
The release workflow creates each version tag itself, and GitHub does not start other workflows from a tag created that way. The Docker build for the tag never ran, so images were only published as main, dev, latest and commit tags. The release now starts the Docker build on the new tag itself, so every release also gets an image tagged with its full version (like 0.0.22) and one tagged with its minor version (like 0.0).

Fixes #179
2026-11-29 15:58:42 +01:00

83 lines
3.1 KiB
YAML

name: Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for changes in pyproject.toml
run: |
git diff --cached --diff-filter=d pyproject.toml || {
echo "No changes to pyproject.toml"
exit 1
}
- name: Get version number from pyproject.toml
id: get_version
run: |
VERSION=$(awk -F' *= *' '$1 == "version" { gsub(/"/, "", $2); print $2 }' pyproject.toml)
echo "Detected version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Extract latest CHANGELOG entry
id: changelog
run: |
CHANGELOG_CONTENT=$(awk 'BEGIN {print_section=0;} /^## \[/ {if (print_section == 0) {print_section=1;} else {exit;}} print_section {print;}' CHANGELOG.md)
echo "Extracted latest release notes from CHANGELOG.md:"
echo -e "$CHANGELOG_CONTENT"
{
echo "content<<CHANGELOG_EOF"
echo "$CHANGELOG_CONTENT"
echo "CHANGELOG_EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub release
uses: actions/github-script@v7
env:
CHANGELOG: ${{ steps.changelog.outputs.content }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const changelog = process.env.CHANGELOG;
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${{ steps.get_version.outputs.version }}`,
name: `v${{ steps.get_version.outputs.version }}`,
body: changelog,
})
console.log(`Created release ${release.data.html_url}`)
- name: Upload package to GitHub release
uses: actions/upload-artifact@v4
with:
name: package
path: |
.
!.git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Tags created with GITHUB_TOKEN do not trigger the tag push build
- name: Trigger Docker build
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'docker-build.yaml',
ref: 'v${{ steps.get_version.outputs.version }}',
})