-
Notifications
You must be signed in to change notification settings - Fork 2
188 lines (177 loc) · 6.25 KB
/
npm-publish.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
name: Publish release
on:
release:
types:
- published
jobs:
version-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get and validate version number
id: get-version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
./tasks/validate-version.sh "$VERSION"
outputs:
version: ${{ steps.get-version.outputs.VERSION }}
lint:
runs-on: ubuntu-latest
needs:
- version-check
steps:
- uses: actions/checkout@v4
- name: Lint
uses: ./.github/actions/lint
tests:
runs-on: ubuntu-latest
needs:
- version-check
steps:
- uses: actions/checkout@v4
- name: Tests
uses: ./.github/actions/tests
storybook-tests:
runs-on: ubuntu-latest
needs:
- version-check
steps:
- uses: actions/checkout@v4
- name: Tests
uses: ./.github/actions/storybook-tests
test-package:
runs-on: ubuntu-latest
needs:
- version-check
steps:
- uses: actions/checkout@v4
- name: Test build package
uses: ./.github/actions/test-package
prototype-kit:
runs-on: ubuntu-latest
needs:
- test-package
steps:
- uses: actions/checkout@v4
- name: GOV.UK prototype kit test
uses: ./.github/actions/prototype-kit-test
publish-npm:
runs-on: ubuntu-latest
needs:
- version-check
- lint
- tests
- storybook-tests
- prototype-kit
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org/
scope: '@nationalarchives'
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build:package
- name: Check npm credentials
run: npm whoami
- name: Publish to npm
run: cd package && npm publish
- name: Rename package directory
run: mv package "tna-frontend-${{ needs.version-check.outputs.version }}"
- name: Compress package
run: zip -r "tna-frontend-${{ needs.version-check.outputs.version }}.zip" "tna-frontend-${{ needs.version-check.outputs.version }}"
- name: Upload the package to the GitHub release
run: gh release upload "v${{ needs.version-check.outputs.version }}" "tna-frontend-${{ needs.version-check.outputs.version }}.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm-cookie-banner:
runs-on: ubuntu-latest
needs:
- publish-npm
- version-check
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org/
scope: '@nationalarchives'
- name: Install dependencies
run: npm ci
- name: Build package
run: ./tasks/cookie-banner/build-cookie-banner-package.sh
- name: Check npm credentials
run: npm whoami
- name: Publish to npm
run: cd package-cookie-banner && npm publish
- name: Rename package directory
run: mv package-cookie-banner "tna-frontend-cookie-banner-${{ needs.version-check.outputs.version }}"
- name: Compress package
run: zip -r "tna-frontend-cookie-banner-${{ needs.version-check.outputs.version }}.zip" "tna-frontend-cookie-banner-${{ needs.version-check.outputs.version }}"
- name: Upload the package to the GitHub release
run: gh release upload "v${{ needs.version-check.outputs.version }}" "tna-frontend-cookie-banner-${{ needs.version-check.outputs.version }}.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm-global-header:
runs-on: ubuntu-latest
needs:
- publish-npm
- version-check
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org/
scope: '@nationalarchives'
- name: Install dependencies
run: npm ci
- name: Build package
run: ./tasks/global-header/build-global-header-package.sh
- name: Check npm credentials
run: npm whoami
- name: Publish to npm
run: cd package-global-header && npm publish
- name: Rename package directory
run: mv package-global-header "tna-frontend-global-header-${{ needs.version-check.outputs.version }}"
- name: Compress package
run: zip -r "tna-frontend-global-header-${{ needs.version-check.outputs.version }}.zip" "tna-frontend-global-header-${{ needs.version-check.outputs.version }}"
- name: Upload the package to the GitHub release
run: gh release upload "v${{ needs.version-check.outputs.version }}" "tna-frontend-global-header-${{ needs.version-check.outputs.version }}.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-slack:
runs-on: ubuntu-latest
needs:
- version-check
- publish-npm-cookie-banner
- publish-npm-global-header
steps:
- uses: actions/checkout@v4
- name: Get the release notes
id: release-notes
run: |
{
echo 'RELEASE_NOTES<<EOF'
./tasks/get-release-notes.sh ${{ needs.version-check.outputs.version }}
echo EOF
} >> "$GITHUB_OUTPUT"
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_TITLE: "`v${{ needs.version-check.outputs.version }}` of `tna-frontend` has just been published"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: "https://raw.githubusercontent.com/nationalarchives/tna-frontend/main/src/nationalarchives/assets/images/apple-touch-icon.png"
MSG_MINIMAL: true
SLACKIFY_MARKDOWN: true
SLACK_MESSAGE: ${{ steps.release-notes.outputs.RELEASE_NOTES }}