-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (86 loc) · 2.91 KB
/
kick-off-release.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Kick off release
run-name: Kick off release ${{ github.event.inputs.release-version }}
on:
workflow_dispatch:
inputs:
release-version:
description: Release version
required: true
permissions:
pull-requests: write
contents: write
jobs:
validate-version-format:
name: Validate Release Version Format
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
steps:
- name: Validate release version input
run: |
if [[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
echo "Valid version - $RELEASE_VERSION"
else
echo "Invalid version - $RELEASE_VERSION"
exit 1
fi
shell: bash
create-release-pr:
name: Create release PR for ${{ github.event.inputs.release-version }}
runs-on: ubuntu-latest
needs:
- validate-version-format
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
steps:
- name: Checkout Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Bump versions to ${{ env.RELEASE_VERSION }}
run: |
git checkout -b bump-version/$RELEASE_VERSION main
/bin/bash ./.github/scripts/bump-version.sh
git config user.name aws-amplify-ops
git config user.email [email protected]
git add -A
git commit -am "[bump version $RELEASE_VERSION]"
git push origin HEAD
shell: bash
- name: Generate CHANGELOG
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
shell: bash
run: |
LOGS=$(git log --pretty=format:%s origin/release..HEAD | awk -F '\n' '{print $1}')
GROUPED_LOGS=$(echo $LOGS | ./.github/scripts/group-commit-message.awk)
awk -v date=$(date +"%Y-%m-%d") \
-v version="$RELEASE_VERSION" '
NR == 2 {
print "\n"
print "## " version " - (" date ")"
while (getline line < "/dev/stdin") {
print line
}
next
}
{print}
' CHANGELOG.md < <(echo "$GROUPED_LOGS") > temp && mv temp CHANGELOG.md
- name: Create CHANGELOG commit
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
run: |
git add CHANGELOG.md
git commit -m "chore: update CHANGELOG for $RELEASE_VERSION"
git push origin HEAD
- name: Create Pull Request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr create \
--title "bump version to $RELEASE_VERSION" \
--body "bump version to $RELEASE_VERSION" \
--head bump-version/$RELEASE_VERSION \
--base release