-
Notifications
You must be signed in to change notification settings - Fork 69
143 lines (133 loc) · 5.34 KB
/
release-code-freeze.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
name: "Release - Code freeze"
# This action will run according to the cron schedule or when triggered manually
on:
schedule:
- cron: '0 12 * * 0' # Run at 1200 UTC on Sundays.
workflow_dispatch:
inputs:
skipSlackPing:
description: "Skip the Slack ping"
type: boolean
required: false
default: false
defaults:
run:
shell: bash
jobs:
check-code-freeze:
name: "Check that today is the day of the code freeze"
runs-on: ubuntu-latest
outputs:
freeze: ${{ steps.check-freeze.outputs.FREEZE }}
nextReleaseVersion: ${{ steps.next-version.outputs.NEXT_RELEASE_VERSION }}
nextReleaseDate: ${{ steps.define_var.outputs.RELEASE_PLANNED_DATE }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
with:
ref: 'develop'
- name: "Get current version"
id: current-version
run: |
VERSION=$(jq '.version' package.json -r)
echo "Current version found: $VERSION" >> $GITHUB_STEP_SUMMARY
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: "Set up repository"
uses: ./.github/actions/setup-repo
- name: "Calculate the next version"
id: next-version
env:
RELEASE_VERSION: ${{ steps.current-version.outputs.VERSION }}
run: php .github/workflows/scripts/get-next-version.php
- name: "Define the release planned date"
id: define_var
run: |
RELEASE_PLANNED_DATE=$( date "+%Y-%m-%d" -d "next Wednesday" ) # Date formatted as YYYY-MM-DD
echo "RELEASE_PLANNED_DATE=$RELEASE_PLANNED_DATE" >> $GITHUB_OUTPUT
- name: "Check if the next version needs a code freeze"
id: check-freeze
env:
NEXT_VERSION: ${{ steps.next-version.outputs.NEXT_RELEASE_VERSION }}
run: |
git fetch --tags origin
NEXT_VERSION_TAG_STABLE=$(git tag -l "${{ env.NEXT_VERSION }}" | tail -1)
NEXT_VERSION_TAG_FROM_WEEK_2=$(git tag -l "${{ env.NEXT_VERSION }}-test-2" | tail -1)
if [[ -z "$NEXT_VERSION_TAG_FROM_WEEK_2" ]]; then
echo "Code freeze is not needed :x:" >> $GITHUB_STEP_SUMMARY
echo "FREEZE=0" >> $GITHUB_OUTPUT
elif [[ -z "$NEXT_VERSION_TAG_STABLE" ]]; then
echo "Code freeze is needed :white_check_mark:" >> $GITHUB_STEP_SUMMARY
echo "FREEZE=1" >> $GITHUB_OUTPUT
fi
create-release-pr:
name: "Raise a PR to trunk"
needs: check-code-freeze
if: needs.check-code-freeze.outputs.freeze == 1
uses: ./.github/workflows/release-pr.yml
with:
releaseVersion: ${{ needs.check-code-freeze.outputs.nextReleaseVersion }}
secrets: inherit
slack-notification:
name: "Send notification to Slack"
needs: [check-code-freeze, create-release-pr]
if: ${{ ! ( inputs.skipSlackPing && needs.create-release-pr.outputs.release-pr-id ) }}
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ needs.check-code-freeze.outputs.nextReleaseVersion }}
RELEASE_DATE: ${{ needs.check-code-freeze.outputs.nextReleaseDate }}
RELEASE_PR_ID: ${{ needs.create-release-pr.outputs.release-pr-id }}
steps:
- name: "Slack ping"
uses: slackapi/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.CODE_FREEZE_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
# For posting a rich message using Block Kit (https://api.slack.com/messaging/interactivity)
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Code freeze notification",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "The automated workflow just did the following actions:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "• Created a release branch `release/${{ env.RELEASE_VERSION }}` \n • Raised a <https://github.com/Automattic/woocommerce-payments/pull/${{ env.RELEASE_PR_ID }}|Pull Request> to `trunk`\n • Built a <https://github.com/Automattic/woocommerce-payments/actions/runs/${{ github.run_id }}|zip file and ran smoke tests> against it"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "If you absolutely need to include a PR that was not merged in `develop` yet, please consult the release lead."
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Version:*\n${{ env.RELEASE_VERSION }}"
},
{
"type": "mrkdwn",
"text": "*Planned date:*\n<https://wcpay.wordpress.com/dev-resources/wc-payments-release-calendar/|${{ env.RELEASE_DATE }}>"
}
]
}
]
}