Automatic Release Creation #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automatic Release Creation | |
on: | |
workflow_dispatch: | |
jobs: | |
create-metadata: | |
runs-on: ubuntu-latest | |
outputs: | |
hash: ${{ steps.last-release.outputs.hash }} | |
version: ${{ steps.create-version.outputs.version}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get last release hash | |
id: last-release | |
run: | | |
HASH=$(git rev-list --tags --max-count=1 || echo "HEAD~1") | |
echo "hash=${HASH}" >> $GITHUB_OUTPUT | |
echo "Using last release hash: ${HASH}" | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Create version name | |
id: create-version | |
run: echo "version=$(uv run --script scripts/release.py generate-version)" >> $GITHUB_OUTPUT | |
- name: Create notes | |
run: | | |
HASH="${{ steps.last-release.outputs.hash }}" | |
uv run --script scripts/release.py generate-notes --directory src/ $HASH > RELEASE_NOTES.md | |
- name: Release notes | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-notes | |
path: RELEASE_NOTES.md | |
update-packages: | |
needs: [create-metadata] | |
runs-on: ubuntu-latest | |
outputs: | |
changes_made: ${{ steps.commit.outputs.changes_made }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Update packages | |
run: | | |
HASH="${{ needs.detect-last-release.outputs.hash }}" | |
uv run --script scripts/release.py update-packages --directory src/ $HASH | |
- name: Configure git | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
- name: Commit changes | |
id: commit | |
run: | | |
VERSION="${{ needs.create-metadata.outputs.version }}" | |
git add -u | |
if git diff-index --quiet HEAD; then | |
echo "changes_made=false" >> $GITHUB_OUTPUT | |
else | |
git commit -m 'Automatic update of packages' | |
git tag -a "$VERSION" -m "Release $VERSION" | |
git push origin HEAD "$VERSION" | |
echo "changes_made=true" >> $GITHUB_OUTPUT | |
fi | |
create-release: | |
needs: [update-packages, create-metadata] | |
if: needs.update-packages.outputs.changes_made == 'true' | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download release notes | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-notes | |
- name: Create release | |
env: | |
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
run: | | |
VERSION="${{ needs.create-metadata.outputs.version }}" | |
gh release create "$VERSION" \ | |
--title "Release $VERSION" \ | |
--notes-file RELEASE_NOTES.md |