-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (39 loc) · 1.46 KB
/
releases.yaml
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
name: Create Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
permissions: write-all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # This ensures all commits and tags are fetched
- name: Generate release notes
id: release_notes
run: |
TAG_NAME=${{ github.ref_name }}
LATEST_SHA=$(gh release view latest --json publishedAt -q ".publishedAt") || true
if [ -z "$LATEST_SHA" ]; then
NOTES=$(git log --pretty=format:"%s" $(git rev-list --max-parents=0 HEAD)..HEAD)
else
NOTES=$(git log --pretty=format:"%s" $LATEST_SHA..HEAD)
fi
INTRO="Version $TAG_NAME contains the following changes and improvements:"
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "text<<EOF"$'\n'"$INTRO"$'\n'"$NOTES"$'\n'EOF >> $GITHUB_OUTPUT
- name: Create Release
run: |
TAG_NAME=${{ github.ref_name }}
gh release create $TAG_NAME -t $TAG_NAME -n "${{ steps.release_notes.outputs.notes }}" --target main
- name: Move 'latest' tag
run: |
git tag -d latest || true # Delete local 'latest' tag if exists
git push origin :refs/tags/latest || true # Delete remote 'latest' tag if exists
git tag latest
git push origin refs/tags/latest