Skip to content

feat!: improve developer experience with breaking API changes #3

feat!: improve developer experience with breaking API changes

feat!: improve developer experience with breaking API changes #3

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract changelog for this version
id: changelog
run: |
# Extract the changelog section for this version
version="${{ steps.version.outputs.version }}"
# Use awk to extract the section between this version and the next
changelog=$(awk -v ver="$version" '
/^## \[/ {
if (found) exit
if ($0 ~ "\\[" ver "\\]") found=1
next
}
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md)
# Write to file to preserve formatting
echo "$changelog" > /tmp/release_notes.md
# Set output (escape newlines for GitHub Actions)
{
echo 'notes<<EOF'
cat /tmp/release_notes.md
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.version.outputs.version }}
body: ${{ steps.changelog.outputs.notes }}
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}