-
Notifications
You must be signed in to change notification settings - Fork 1.4k
120 lines (103 loc) · 4.35 KB
/
release-new-version.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Release a new version
on:
schedule:
- cron: "30 14 * * 0-4" # Run workflow at 8 PM IST every Sunday-Thursday
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
jobs:
create-release:
name: Release a new version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.AUTO_RELEASE_PAT }}
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable 2 weeks ago
- name: Install cocogitto
uses: baptiste0928/[email protected]
with:
crate: cocogitto
version: 5.4.0
- name: Install git-cliff
uses: baptiste0928/[email protected]
with:
crate: git-cliff
version: 1.2.0
- name: Install changelog-gh-usernames
uses: baptiste0928/[email protected]
with:
crate: changelog-gh-usernames
git: https://github.com/SanchithHegde/changelog-gh-usernames
rev: dab6da3ff99dbbff8650c114984c4d8be5161ac8
- name: Set Git Configuration
shell: bash
run: |
git config --local user.name 'github-actions'
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Update Postman collection files from Postman directories
shell: bash
run: |
# maybe we need to move this package.json as we need it in multiple workflows
npm ci
POSTMAN_DIR=postman/collection-dir
POSTMAN_JSON_DIR=postman/collection-json
NEWMAN_PATH=$(pwd)/node_modules/.bin
export PATH=${NEWMAN_PATH}:${PATH}
# generate postman collections for all postman directories
for connector_dir in ${POSTMAN_DIR}/*
do
connector=$(basename ${connector_dir})
newman dir-import ${POSTMAN_DIR}/${connector} -o ${POSTMAN_JSON_DIR}/${connector}.postman_collection.json
done
if git add postman && ! git diff --staged --quiet postman; then
git commit --message 'test(postman): update postman collection files'
echo "Changes detected and commited."
fi
- name: Obtain previous and new tag information
shell: bash
# Only consider tags on current branch when setting PREVIOUS_TAG
run: |
PREVIOUS_TAG="$(git tag --sort='version:refname' --merged | tail --lines 1)"
if [[ "$(cog bump --auto --dry-run)" == *"No conventional commits for your repository that required a bump"* ]]; then
NEW_TAG="$(cog bump --patch --dry-run)"
elif [[ "${PREVIOUS_TAG}" != "${NEW_TAG}" ]]; then
NEW_TAG="$(cog bump --auto --dry-run)"
fi
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV
- name: Update changelog and create tag
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
# Remove prefix 'v' from 'NEW_TAG' as cog bump --version expects only the version number
run: |
cog bump --version ${NEW_TAG#v}
- name: Push created commit and tag
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
run: |
git push
git push --tags
- name: Generate release notes and create GitHub release
shell: bash
if: ${{ env.NEW_TAG != env.PREVIOUS_TAG }}
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ secrets.AUTO_RELEASE_PAT }}
# Need to consider commits inclusive of previous tag to generate diff link between versions.
# This would also then require us to remove the last few lines from the changelog.
run: |
git-cliff --config .github/git-cliff-release.toml "${PREVIOUS_TAG}^..${NEW_TAG}" | changelog-gh-usernames | sed "/## ${PREVIOUS_TAG#v}/,\$d" > release-notes.md
gh release create "${NEW_TAG}" --notes-file release-notes.md --verify-tag --title "Hyperswitch ${NEW_TAG}"