Skip to content

Commit 0c931ca

Browse files
committed
added release notes automatic workflow on tag push (#813)
Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com> typo Signed-off-by: Tullio Sebastiani <tsebasti@redhat.com>
1 parent 075dbd1 commit 0c931ca

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

.github/release-template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Release {VERSION}
2+
3+
### Download Artifacts
4+
- 📦 Krkn sources (amd64): [krkn-{VERSION}-src.tar.gz](https://krkn-chaos.gateway.scarf.sh/krkn-src-{VERSION}.tar.gz)
5+
6+
### Changes
7+
{CHANGES}

.github/release.yml

Whitespace-only changes.

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create Release
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
jobs:
7+
release:
8+
permissions:
9+
contents: write
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: calculate previous tag
14+
run: |
15+
git fetch --tags origin
16+
PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n '2 p')
17+
echo $PREVIOUS_TAG
18+
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> "$GITHUB_ENV"
19+
- name: generate release notes from template
20+
id: release-notes
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: |
24+
NOTES=$(gh api \
25+
--method POST \
26+
-H "Accept: application/vnd.github+json" \
27+
-H "X-GitHub-Api-Version: 2022-11-28" \
28+
/repos/krkn-chaos/krkn/releases/generate-notes \
29+
-f "tag_name=${{ github.ref_name }}" -f "target_commitish=main" -f "previous_tag_name=${{ env.PREVIOUS_TAG }}" | jq -r .body)
30+
echo "NOTES<<EOF" >> $GITHUB_ENV
31+
echo "$NOTES" >> $GITHUB_ENV
32+
echo "EOF" >> $GITHUB_ENV
33+
34+
- name: replace placeholders in template
35+
run: |
36+
echo "${{ env.NOTES }}"
37+
TEMPLATE=$(cat .github/release-template.md)
38+
VERSION=${{ github.ref_name }}
39+
NOTES="${{ env.NOTES }}"
40+
OUTPUT=${TEMPLATE//\{VERSION\}/$VERSION}
41+
OUTPUT=${OUTPUT//\{CHANGES\}/$NOTES}
42+
echo "$OUTPUT" > release-notes.md
43+
- name: create release
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: |
47+
gh release create ${{ github.ref_name }} --title "${{ github.ref_name }}" -F release-notes.md

0 commit comments

Comments
 (0)