forked from Amsterdam/mijn-amsterdam-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (61 loc) · 2.24 KB
/
release-notification.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Release Notes
on:
push:
branches:
- main
run-name: Generating release notifications for ${{ github.base_ref }}
permissions:
contents: write
jobs:
create-publish-release-notes:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Fetch all tags
run: git fetch --tags
- name: Get latest and previous tags
id: tags
run: |
all_tags=$(git tag -l --sort=-creatordate)
latest_tag=$(echo "$all_tags" | sed -n '1p')
previous_tag=$(echo "$all_tags" | sed -n '2p')
echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT"
echo "previous_tag=$previous_tag" >> "$GITHUB_OUTPUT"
# Debug output
echo "Latest tag: $latest_tag"
echo "Second to latest tag: $previous_tag"
- name: Generate Release Notes
env:
PREVIOUS_TAG: ${{ steps.tags.outputs.previous_tag }}
LATEST_TAG: ${{ steps.tags.outputs.latest_tag }}
run: |
echo "Changes between $PREVIOUS_TAG and $LATEST_TAG:" > release-notes.txt
git log "$PREVIOUS_TAG..$LATEST_TAG" --oneline >> release-notes.txt
RELEASE_NOTES=$(cat release-notes.txt)
echo "RELEASE_NOTES<<EOF" >> "$GITHUB_ENV"
echo "$RELEASE_NOTES" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
- name: Create or Update Release
env:
LATEST_TAG: ${{ steps.tags.outputs.latest_tag }}
run: |
if gh release view "$LATEST_TAG" &>/dev/null; then
echo "Release exists. Updating..."
gh release edit "$LATEST_TAG" --notes "$RELEASE_NOTES"
else
echo "Creating new release..."
gh release create "$LATEST_TAG" --notes "$RELEASE_NOTES"
fi
- name: Update Release with Custom Notes
env:
RELEASE_NOTES: ${{ env.RELEASE_NOTES }}
LATEST_TAG: ${{ steps.tags.outputs.latest_tag }}
run: |
CUSTOM_NOTES=$(echo $RELEASE_NOTES | py ./scripts/sort-release-notes.py)
gh release edit "$LATEST_TAG" --notes "$CUSTOM_NOTES"