-
Notifications
You must be signed in to change notification settings - Fork 1
280 lines (243 loc) · 9.38 KB
/
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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
name: Release
on:
workflow_dispatch:
push:
branches:
- main
env:
GITHUB_USERNAME: "bichard7"
GITHUB_EMAIL: "bichard7@users.noreply.github.com"
jobs:
bump-package-version:
name: Bump package version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
persist-credentials: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.6.1
- name: Bump output package version (and capture it)
id: bump
run: echo "version=$(npm version patch | tr -d 'v')" >> "$GITHUB_OUTPUT"
working-directory: output-data
- name: Check new version
run: if [ -z "${{ steps.bump.outputs.version }}" ]; then exit 1; else echo "${{ steps.bump.outputs.version }}"; fi
- name: Update pom.xml with new version number
run: envsubst '$PACKAGE_JSON_VERSION' < pom.template.xml > pom.xml
env:
PACKAGE_JSON_VERSION: ${{ steps.bump.outputs.version }}
- name: Commit output package version bump
run: |
git config user.name ${{ env.GITHUB_USERNAME }}
git config user.email ${{ env.GITHUB_EMAIL }}
git add output-data/package*.json pom.xml
git commit -m "Bump package version [skip actions]"
git tag v${{ steps.bump.outputs.version }}
- name: Push new commit and tag
run: git push --follow-tags
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notification_title: 'GitHub action failed: Bump package version'
message_format: ':elmo-fire: *{workflow}* {status_message} in <{repo_url}|{repo}>'
notify_when: 'failure'
footer: 'Linked to Repo <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
release-npm-package:
name: Release NPM package
needs: bump-package-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# We need to specify the branch name, so that we get the updated package.json
# If we don't specify this, the default is to fetch the commit that triggered
# the workflow (which won't include the updated package.json)
ref: ${{ github.ref_name }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.6.1
- name: Install top-level NPM dependencies
run: npm ci
- name: Generate triggers.properties files
run: npm run generate-trigger-config
- name: Install output package NPM dependencies
run: npm ci
working-directory: output-data
- name: Build output package
working-directory: output-data
run: npm run build
- name: Publish output package
run: npm publish
working-directory: output-data
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notification_title: 'GitHub action failed: Release npm package'
message_format: ':elmo-fire: *{workflow}* {status_message} in <{repo_url}|{repo}>'
notify_when: 'failure'
footer: 'Linked to Repo <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
release-maven-package:
name: Release Maven package
needs: bump-package-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# We need to specify the branch name, so that we get the updated package.json
# If we don't specify this, the default is to fetch the commit that triggered
# the workflow (which won't include the updated package.json)
ref: ${{ github.ref_name }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.6.1
- name: Install top-level NPM dependencies
run: npm ci
- name: Generate triggers.properties files
run: npm run generate-trigger-config
- name: Setup Java and Maven
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: 17
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Package the data with maven
run: mvn package --no-transfer-progress
- name: Publish maven package
run: mvn deploy
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notification_title: 'GitHub action failed: Release Maven package'
message_format: ':elmo-fire: *{workflow}* {status_message} in <{repo_url}|{repo}>'
notify_when: 'failure'
footer: 'Linked to Repo <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
update-core-repo:
name: Update NPM package in core repo
needs:
- bump-package-version
- release-npm-package
runs-on: ubuntu-latest
steps:
- name: Check out core repo
uses: actions/checkout@v4
with:
repository: ministryofjustice/bichard7-next-core
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Update standing data npm package
run: >
npm install
bichard7-next-data-latest@npm:@moj-bichard7-developers/bichard7-next-data@${VERSION}
-w packages/core
env:
VERSION: ${{ needs.bump-package-version.outputs.version }}
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notification_title: 'GitHub action failed: Update core repo'
message_format: ':elmo-fire: *{workflow}* {status_message} in <{repo_url}|{repo}>'
notify_when: 'failure'
footer: 'Linked to Repo <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
branch: auto/update-standing-data
delete-branch: true
token: ${{ secrets.GH_ACCESS_TOKEN }}
committer: ${{ env.GITHUB_USERNAME }} <${{ env.GITHUB_EMAIL }}>
author: ${{ env.GITHUB_USERNAME }} <${{ env.GITHUB_EMAIL }}>
commit-message: Update standing data dependency
title: Update standing data
body: >
Automated standing data update generated by the
[Release](https://github.com/ministryofjustice/bichard7-next-data/actions/workflows/release.yml)
workflow.
- name: PR information
run: |
echo "PR #${{ steps.cpr.outputs.pull-request-number }}"
echo "${{ steps.cpr.outputs.pull-request-url }}"
update-b7-repo:
name: Update maven package in bichard7-next repo
needs:
- bump-package-version
- release-maven-package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ministryofjustice/bichard7-next
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Update standing data gradle dependency
run: |
sed -i -r "s/bichardDataVersion = \"[0-9]+\.[0-9]+\.[0-9]+\"$/bichardDataVersion = \"$VERSION\"/g" build.gradle
env:
VERSION: ${{ needs.bump-package-version.outputs.version }}
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notification_title: 'GitHub action failed: Update Bichard 7 next'
message_format: ':elmo-fire: *{workflow}* {status_message} in <{repo_url}|{repo}>'
notify_when: 'failure'
footer: 'Linked to Repo <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
branch: auto/update-standing-data
delete-branch: true
token: ${{ secrets.GH_ACCESS_TOKEN }}
committer: ${{ env.GITHUB_USERNAME }} <${{ env.GITHUB_EMAIL }}>
author: ${{ env.GITHUB_USERNAME }} <${{ env.GITHUB_EMAIL }}>
commit-message: Update standing data
title: Update standing data
body: >
Automated standing data update generated by the
[Release](https://github.com/ministryofjustice/bichard7-next-data/actions/workflows/release.yml)
workflow.
- name: PR information
run: |
echo "PR #${{ steps.cpr.outputs.pull-request-number }}"
echo "${{ steps.cpr.outputs.pull-request-url }}"