-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.49 KB
/
pr-merged.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
69
70
71
72
73
74
75
on:
pull_request:
branches:
- main
types: [closed]
name: '[autorelease] PR merged'
permissions:
contents: write
jobs:
merge:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'autorelease')
steps:
- uses: actions/checkout@v4
- name: Get release version
id: get-release-version
run: |
# Head branch should be named autorelease/<version>
if ! [[ "${{ github.event.pull_request.head.ref }}" =~ ^autorelease\/[A-Za-z0-9.+-]+$ ]]; then
echo "::error::Invalid branch '${{ github.event.pull_request.head.ref }}'"
exit 1
fi
VERSION=$(echo "${{ github.event.pull_request.head.ref }}" | awk -F/ '{print $2}')
echo "VERSION=$VERSION"
RE='^[vV]?([0-9]+)[.]([0-9]+)[.]([0-9]+)(-[0-9A-Za-z.+-]*)?'
if [[ $VERSION =~ $RE ]]; then
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
PRERELEASE="${BASH_REMATCH[4]}"
else
echo "::error::Version '$VERSION' is not in a valid format" && exit 1
fi
if [[ "$PRERELEASE" ]]; then pre=true; else pre=false; fi
if [[ -f $GITHUB_OUTPUT ]]; then
echo "release-version=$VERSION" >> $GITHUB_OUTPUT
echo "is-prerelease=$pre" >> $GITHUB_OUTPUT
else
echo "::set-output name=release-version::$VERSION"
echo "::set-output name=is-prerelease::$pre"
fi
- name: Get release notes
id: get-release-notes
uses: ./
with:
command: query
version: ${{ steps.get-release-version.outputs.release-version}}
- name: Display release notes
run: |
echo "${{ steps.get-release-notes.outputs.release-notes }}"
- name: Create Draft Release
id: create_release
uses: release-flow/.github/actions/release/create@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
tag-name: 'v${{ steps.get-release-version.outputs.release-version }}'
release-name: 'Release ${{ steps.get-release-version.outputs.release-version }}'
draft: true
prerelease: ${{ steps.get-release-version.outputs.is-prerelease}}
body: ${{ steps.get-release-notes.outputs.release-notes }}
- name: Display Instructions
run: |
echo "::notice title=Draft Release Prepared::A draft release has been prepared for you to approve: ${{ steps.create_release.outputs.html-url }}"