-
Notifications
You must be signed in to change notification settings - Fork 69
149 lines (130 loc) · 5.51 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: "Release - Create PR to trunk"
# This action will run inside the release code freeze workflow or when it is triggered manually
on:
workflow_call:
inputs:
releaseVersion:
description: 'The release version (e.g. 4.5.0)'
required: true
type: string
releaseDateString:
description: "The release date in human-readable format (default: 'next wednesday')."
required: false
default: "next wednesday"
type: string
skip-smoke-tests:
type: boolean
required: false
default: false
description: "Skip running smoke tests"
outputs:
release-pr-id:
description: "ID of the release PR created"
value: ${{ jobs.prepare-release.outputs.release-pr-id }}
workflow_dispatch:
inputs:
releaseVersion:
description: 'The release version (e.g. 4.5.0)'
required: true
type: string
releaseDateString:
description: "The release date in human-readable format (default: 'next wednesday')."
required: false
default: "next wednesday"
type: string
skip-build-zip:
type: boolean
required: false
default: true
description: "Skip building the zip file"
skip-smoke-tests:
type: boolean
required: false
default: false
description: "Skip running smoke tests"
defaults:
run:
shell: bash
jobs:
prepare-release:
name: "Prepare a stable release"
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.create_branch.outputs.branch-name }}
release-pr-id: ${{ steps.create-pr-to-trunk.outputs.RELEASE_PR_ID }}
env:
RELEASE_VERSION: ${{ inputs.releaseVersion }}
RELEASE_DATE_STRING: ${{ inputs.releaseDateString }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Set up repository"
uses: ./.github/actions/setup-repo
- name: "Create a release branch"
id: create_branch
uses: ./.github/actions/create-branch
with:
version: ${{ env.RELEASE_VERSION }}
is-pre-release: 'false'
- name: "Define the release date"
id: define_var
run: |
RELEASE_DATE=$( date "+%Y-%m-%d" -d "$RELEASE_DATE_STRING" ) # Release date formatted as YYYY-MM-DD
echo "RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_OUTPUT
- name: "Generate the changelog"
id: generate_changelog
uses: ./.github/actions/process-changelog
with:
release-version: ${{ steps.create_branch.outputs.trimmed-version }}
release-date: ${{ steps.define_var.outputs.RELEASE_DATE }}
- name: "Bump version"
env:
RELEASE_VERSION: ${{ steps.create_branch.outputs.trimmed-version }}
RELEASE_DATE: ${{ steps.define_var.outputs.RELEASE_DATE }}
CHANGELOG: ${{ steps.generate_changelog.outputs.changelog }}
run: |
CURRENT_VERSION=$(jq '.version' package.json -r)
# 'Version' header in woocommerce-payments.php
sed -i "s/^ \* Version: .*$/ * Version: $RELEASE_VERSION/" woocommerce-payments.php
# 'version' field in package.json and package-lock.json
npm version $RELEASE_VERSION --no-git-tag-version
# 'Stable tag' header in readme.txt;
sed -i "s/^Stable tag: .*$/Stable tag: $RELEASE_VERSION/" readme.txt
- name: "Commit and push changes"
env:
RELEASE_VERSION: ${{ steps.create_branch.outputs.trimmed-version }}
BRANCH_NAME: ${{ steps.create_branch.outputs.branch-name }}
uses: ./.github/actions/commit-push-as-bot
with:
release-version: ${{ env.RELEASE_VERSION }}
branch: ${{ env.BRANCH_NAME }}
- name: "Create a PR to trunk"
id: create-pr-to-trunk
env:
GITHUB_TOKEN: ${{ secrets.BOTWOO_TOKEN }}
BRANCH_NAME: ${{ steps.create_branch.outputs.branch-name }}
CHANGELOG: ${{ steps.generate_changelog.outputs.changelog }}
RELEASE_VERSION: ${{ steps.create_branch.outputs.trimmed-version }}
run: |
PR_BODY=$(echo -e ":warning: Please do not merge the PR from the GitHub interface. :warning:\n\n Instead, you can use the following command:\n\`\`\`\n git checkout $BRANCH_NAME && git pull \n git checkout trunk && git pull \n git merge --no-ff $BRANCH_NAME -m 'Merge $BRANCH_NAME into trunk' \n git push origin trunk \n\`\`\` \n Changelog: \n\`\`\`\n${CHANGELOG}\n\`\`\`")
PR_URL=$(gh pr create --title "Release branch for $RELEASE_VERSION" --body="$PR_BODY" --base="trunk")
PR_ID=${PR_URL##*/}
if [[ $PR_ID =~ ^[0-9]+$ ]]; then
echo "RELEASE_PR_ID=$PR_ID" >> $GITHUB_OUTPUT
fi
- name: Add comment to PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_PR_ID: ${{ steps.create-pr-to-trunk.outputs.RELEASE_PR_ID }}
run: |
gh pr comment https://github.com/Automattic/woocommerce-payments/pull/$RELEASE_PR_ID --body="### Release zip build & Smoke tests
Check status of zip file build & smoke tests at https://github.com/Automattic/woocommerce-payments/actions/runs/${GITHUB_RUN_ID}"
build-zip-and-run-smoke-tests:
name: "Build zip & Run smoke tests"
needs: prepare-release
if: ${{ ! inputs.skip-build-zip }}
uses: ./.github/workflows/build-zip-and-run-smoke-tests.yml
with:
skip-smoke-tests: ${{ inputs.skip-smoke-tests }}
repo-branch: ${{ needs.prepare-release.outputs.branch }}
secrets: inherit