-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (59 loc) · 2.21 KB
/
release.yml
File metadata and controls
65 lines (59 loc) · 2.21 KB
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
name: Create Release
on:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
is_release: ${{ steps.check.outputs.is_release }}
tags: ${{ steps.check.outputs.tags }}
first_tag: ${{ steps.check.outputs.first_tag }}
title: ${{ steps.check.outputs.title }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Check for version bump commit
id: check
run: |
MSG=$(git log -1 --format=%s)
if echo "$MSG" | grep -qE '^chore\(release\):'; then
echo "is_release=true" >> "$GITHUB_OUTPUT"
TAGS=$(echo "$MSG" | grep -oE '[a-z][-a-z]*/v[0-9]+\.[0-9]+\.[0-9]+')
echo "tags<<EOF" >> "$GITHUB_OUTPUT"
echo "$TAGS" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
FIRST_TAG=$(echo "$TAGS" | head -1)
echo "first_tag=$FIRST_TAG" >> "$GITHUB_OUTPUT"
TITLE=$(echo "$MSG" | sed 's/^chore(release): //')
echo "title=$TITLE" >> "$GITHUB_OUTPUT"
BODY=$(git log -1 --format=%b)
echo "body<<EOF" >> "$GITHUB_OUTPUT"
echo "$BODY" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
else
echo "is_release=false" >> "$GITHUB_OUTPUT"
fi
- name: Create git tags
if: steps.check.outputs.is_release == 'true' && steps.check.outputs.tags != ''
run: |
echo "${{ steps.check.outputs.tags }}" | while read -r TAG; do
[ -z "$TAG" ] && continue
echo "Creating tag: $TAG"
git tag "$TAG"
git push origin "$TAG"
done
- name: Create GitHub Release
if: steps.check.outputs.is_release == 'true' && steps.check.outputs.first_tag != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.check.outputs.first_tag }}" \
--title "${{ steps.check.outputs.title }}" \
--notes "${{ steps.check.outputs.body }}"