forked from CiscoDevNet/terraform-provider-aci
-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (74 loc) · 3.08 KB
/
release_pr.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
76
77
78
79
80
name: release_pr
on:
push:
branches:
- master
jobs:
release-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Unshallow
run: git fetch --prune --unshallow
# git-cliff generates CHANGELOG.md
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install git-cliff typos
- name: Check new changlog entry for version bump type
id: type
run: |
changelog=$(git cliff --unreleased)
case $changelog in
*"BREAKING CHANGES:"* )
echo "MAJOR"
echo "bump="MAJOR: version change"" >> $GITHUB_OUTPUT
;;
*"IMPROVEMENTS:"* )
echo "MINOR"
echo "bump="MINOR: version change"" >> $GITHUB_OUTPUT
;;
*"DEPRECATIONS:"* )
echo "MINOR"
echo "bump="MINOR: version change"" >> $GITHUB_OUTPUT
;;
* )
echo "PATCH"
echo "bump="PATCH: version change"" >> $GITHUB_OUTPUT
;;
esac
# The --with-commit inserts a commit message to git-cliff without it being in the history.
# It is used here to dynamically add version bump commands.
- name: Get next version
id: vars
run: echo "version=$(git cliff --bumped-version --with-commit "${{ steps.type.outputs.bump }}")" >> $GITHUB_OUTPUT
- name: Generate changelog output
run: git cliff --bump --unreleased --with-commit "${{ steps.type.outputs.bump }}"
- name: Prepend new changelog entry
run: git cliff --bump --unreleased -p CHANGELOG.md --with-commit "${{ steps.type.outputs.bump }}"
# Generate annotation_unsupported.go
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Generate annotation unsupported provider code
run: go generate
env:
GEN_ANNOTATION_UNSUPPORTED: '1'
# Commit changes to release_pr branch
- name: Set git config
run: git config user.email "[email protected]" && git config user.name "dcn-ecosystem"
- name: Commit
run: git add -u && git status && git commit -m "[ignore] Update Changelog and annotation_unsupported.go for new release (${{ steps.vars.outputs.version }})"
- name: Branch & Push
run: git checkout -b release_pr && git push --set-upstream origin release_pr --force && git clean -f -d
# Create or update release PR
- run: gh pr create --base master --head release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})" --body ""
id: pr
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: gh pr edit release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})"
if: steps.pr.outcome == 'failure'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}