-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (44 loc) · 1.59 KB
/
auto-release.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
name: Auto Release on '#new-release' commit
on:
push:
branches:
- main
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check commit message for '#new-release'
id: check_message
run: |
commit_message=$(git log --format=%B -n 1)
if echo "$commit_message" | grep -q '#new-release'; then
new_release=$(echo "$commit_message" | sed -n 's/.*<new-release:\([^>]*\)>.*$/\1/p')
if [ -n "$new_release" ]; then
echo "Creating release $new_release"
git config --global user.name 'GitHub Actions Bot'
git config --global user.email '<>'
git tag -a "$new_release" -m "Release $new_release"
git push origin "$new_release"
echo "::set-output name=new_release::$new_release"
else
echo "Commit includes '#new-release' but no tag found in <new-release:tag> format. Skipping release."
exit 1
fi
else
echo "Commit does not include '#new-release'. Skipping release."
exit 0
fi
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
tag="${{ steps.check_message.outputs.new_release }}"
title="${tag#v}"
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="$title" \
--generate-notes