From 4ce6fb588d6eb2473fe35a73bac75cb48a59444b Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Sun, 2 Nov 2025 20:03:01 +0100 Subject: [PATCH] Adds GitHub Actions workflow for releases Sets up a GitHub Actions workflow to automate the release process. The workflow triggers on tagged commits (v*.*.*), extracts the version number from the tag, and retrieves the corresponding changelog section from CHANGELOG.md. It then creates a GitHub release with the extracted version and changelog. If no changelog is found, a default message is used. The automation streamlines the release creation process and ensures consistency. --- .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3251cf4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + create-release: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - name: Extract version from tag + id: version + run: | + # Remove 'v' prefix from tag to get version number + VERSION=${GITHUB_REF#refs/tags/v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + + - name: Extract changelog for this version + id: changelog + run: | + VERSION="${{ steps.version.outputs.version }}" + + # Extract the section for this version from CHANGELOG.md + # This captures everything between ## [VERSION] and the next ## [ or end of file + CHANGELOG=$(awk -v ver="$VERSION" ' + /^## \['"$VERSION"'\]/ { found=1; next } + found && /^## \[/ { exit } + found { print } + ' CHANGELOG.md) + + # If changelog is empty, provide a default message + if [ -z "$CHANGELOG" ]; then + CHANGELOG="See [CHANGELOG.md](CHANGELOG.md) for details." + fi + + # Write to output using heredoc to handle multiline content + { + echo 'notes<> $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: ${{ steps.version.outputs.version }} + body: ${{ steps.changelog.outputs.notes }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}