-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (79 loc) · 3.68 KB
/
Copy pathdraft_new_release.yml
File metadata and controls
95 lines (79 loc) · 3.68 KB
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: Draft new release
on:
workflow_dispatch
permissions:
contents: read
jobs:
draft-new-release:
permissions:
contents: write # for Git to git push
name: Draft a new release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/develop-mpx') || startsWith(github.ref, 'refs/heads/hotfix-mpx')
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout source branch
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
fetch-depth: 0
- name: Set Node 16
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
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
run: |
source_branch_name=${GITHUB_REF##*/}
release_type=release
main_branch=master
branch_type=''
grep -q "hotfix/" <<< "${GITHUB_REF}" && release_type=hotfix-release
grep -q "mpx" <<< "${GITHUB_REF}" && branch_type=-mpx && main_branch=master-mpx
git fetch origin "$main_branch"
git fetch --tags origin
git merge "origin/$main_branch"
current_version=$(cat gradle.properties | grep "VERSION_NAME" | cut -d'=' -f2)
npm ci
npx standard-version --skip.commit --skip.tag --skip.changelog
new_version=$(cat gradle.properties | grep "VERSION_NAME" | cut -d'=' -f2)
git reset --hard
branch_name="${release_type}${branch_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 "::set-output name=source_branch_name::$source_branch_name"
echo "::set-output name=branch_name::$branch_name"
echo "::set-output name=new_version::$new_version"
echo "::set-output name=main_branch::$main_branch"
- name: Update changelog & bump version
id: finish-release
run: |
npm ci
npx standard-version
git add . && git commit --amend --no-edit
- name: Push new version in release branch & tag
run: |
git push --follow-tags
- name: Create pull request into main
uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5 # v2
with:
source_branch: ${{ steps.create-release.outputs.branch_name }}
destination_branch: ${{ steps.create-release.outputs.main_branch }}
github_token: ${{ secrets.PAT }}
pr_title: "chore(release): pulling ${{ steps.create-release.outputs.branch_name }} into ${{ steps.create-release.outputs.main_branch }}"
pr_body: ":crown: *An automated PR*"
pr_reviewer: '@rudderlabs/sdk-android'