Skip to content

Commit

Permalink
Create Release with GHA && attach release-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
danroux committed Mar 26, 2024
1 parent 7a9fd53 commit 15d49b9
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
workflow_dispatch:

permissions:
contents: write
Expand All @@ -15,10 +16,25 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Get Latest Tag
id: latest-tag
run: |
git fetch --tags
latest_tag=$(git tag -l --sort=-v:refname | head -n 1)
echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Release Notes
run: sed -n -e "1{/# /d;}" -e "2{/^$/d;}" -e "/# $(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags | tr -d v)/q;p" CHANGELOG.md > release-notes.txt
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
run: |
latest_entry=$(sed -n '/^##/,$p' CHANGELOG.md | awk '/^##/ {if (version) {print entry; exit} version=$0} {entry = entry ORS $0}')
echo "$latest_entry" > release-notes.md
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: release-notes
path: release-notes.txt
path: release-notes.md
retention-days: 1
- name: GH Release
run: |
gh release create "${{ steps.latest-tag.outputs.latest_tag }}" --notes-file release-notes.md --title "${{ steps.latest-tag.outputs.latest_tag }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 15d49b9

Please sign in to comment.