fix publish workflow #8
Workflow file for this run
This file contains hidden or 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: Draft release on tag | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| draft-release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version from tag | |
| id: version | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| # Strip leading 'v' if present (e.g. v1.0.1 -> 1.0.1) | |
| VERSION="${TAG#v}" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Extract changelog for version | |
| id: changelog | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Extract from "## [VERSION]" up to (but not including) the next "## [" | |
| awk ' | |
| /^## \['"$VERSION"'\]/ { found=1; print; next } | |
| found { if (/^## \[/) exit; print } | |
| ' CHANGELOG.md > release_notes.md | |
| echo "---" | |
| cat release_notes.md | |
| echo "---" | |
| # Default body if section missing (e.g. typo in tag) | |
| if [ ! -s release_notes.md ]; then | |
| echo "Release ${{ steps.version.outputs.tag }}" > release_notes.md | |
| fi | |
| - name: Create draft release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: ${{ steps.version.outputs.tag }} | |
| body_path: release_notes.md | |
| draft: true | |
| generate_release_notes: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |