-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (77 loc) · 3.34 KB
/
draft-new-release.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
name: Draft new release
on:
workflow_dispatch
jobs:
draft-new-release:
name: Draft a new release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/fix/') || startsWith(github.ref, 'refs/heads/feature/')
steps:
- name: Checkout source branch
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set Node 16
uses: actions/setup-node@v3
with:
node-version: 16
# In order to make a commit, we need to initialize a user.
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
- name: Initialize mandatory git config
run: |
git config user.name "GitHub actions"
git config user.email noreply@github.com
# Calculate the next release version based on conventional semantic release
- name: Create release branch
id: create-release
env:
HUSKY: 0
run: |
source_branch_name=${GITHUB_REF##*/}
release_type=release
git fetch origin master --depth=1
git merge origin/master
current_version=$(jq -r .version package.json)
npx standard-version --skip.commit --skip.tag --skip.changelog
new_version=$(jq -r .version package.json)
git reset --hard
branch_name="${release_type}/${new_version}"
echo "Source branch for new release is $source_branch_name"
echo "Current version is $current_version"
echo "Release type is $release_type"
echo "New version is $new_version"
echo "New release branch name is $branch_name"
git checkout -b "$branch_name"
git push --set-upstream origin "$branch_name"
echo "source_branch_name=$source_branch_name" >> $GITHUB_OUTPUT
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
echo "NEW_VERSION_VALUE=$new_version" >> $GITHUB_ENV
- name: Update changelog & bump version
id: finish-release
env:
HUSKY: 0
run: |
npm i -g conventional-changelog-cli
SUMMARY=$(((npx conventional-changelog -u) 2>&1) | sed "s/*/<br> */g" | sed "s/#/ /g" | tr -d '\n' || true)
echo $SUMMARY
echo "Current version: $CURRENT_VERSION_VALUE"
echo "New version: $NEW_VERSION_VALUE"
npx replace $CURRENT_VERSION_VALUE $NEW_VERSION_VALUE README.md
git add README.md
echo ${{ steps.create-release.outputs.new_version }}
echo "commit_summary=$SUMMARY" >> $GITHUB_OUTPUT
npx standard-version -a
- name: Push new version in release branch & tag
run: |
git push --follow-tags
- name: Create pull request into master
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ steps.create-release.outputs.branch_name }}
destination_branch: 'master'
github_token: ${{ secrets.PAT }}
pr_title: "chore(release): pulling ${{ steps.create-release.outputs.branch_name }} into master"
pr_body: ":crown: *An automated PR*\n\n${{ steps.finish-release.outputs.commit_summary }}"
pr_reviewer: '@rudderlabs/sdk-ios'