Skip to content

Commit 8a48556

Browse files
committed
build and publish to npm
1 parent 4409f2e commit 8a48556

File tree

1 file changed

+86
-21
lines changed

1 file changed

+86
-21
lines changed

.github/workflows/publish.yml

Lines changed: 86 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,109 @@
1-
name: Publish
1+
name: Publish Model
22

33
on:
44
push:
55
branches:
66
- main
7-
87
paths:
98
- '.browserslistrc'
109
- 'babel.config.*'
11-
- 'postcss.config.*'
12-
- 'webpack.config.*'
13-
- 'Dockerfile'
1410
- 'src/**'
1511
- '!**/*.test.*'
1612

17-
workflow_dispatch:
18-
inputs:
19-
version:
20-
description: 'Version number manual override'
21-
required: false
22-
2313
concurrency:
24-
group: publish
14+
group: publish-engine-plugin
2515

2616
permissions:
27-
id-token: write
2817
contents: write
29-
pull-requests: write
30-
31-
env:
32-
AWS_REGION: eu-west-2
33-
AWS_ACCOUNT_ID: '094954420758'
18+
packages: write
3419

3520
jobs:
3621
build:
37-
if: github.run_number != 1
38-
name: CDP-build-workflow
22+
name: Build
23+
runs-on: ubuntu-24.04
24+
25+
steps:
26+
- name: Check out code
27+
uses: actions/checkout@v4
28+
29+
- name: Cache dependencies
30+
uses: actions/cache@v4
31+
id: npm-install-cache
32+
with:
33+
enableCrossOsArchive: true
34+
key: npm-install-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
35+
path: node_modules
36+
37+
- name: Cache build
38+
uses: actions/cache@v4
39+
with:
40+
enableCrossOsArchive: true
41+
key: npm-build-${{ runner.os }}-${{ github.sha }}
42+
path: |
43+
.server
44+
.public
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
cache: 'npm'
50+
node-version-file: .nvmrc
51+
52+
- name: Install dependencies
53+
if: steps.npm-install-cache.outputs.cache-hit != 'true'
54+
run: npm ci
55+
56+
- name: Run build
57+
run: npm run build
58+
59+
publish:
60+
name: Publish
3961
runs-on: ubuntu-24.04
62+
needs: [build]
63+
environment: production
64+
4065
steps:
4166
- name: Check out code
4267
uses: actions/checkout@v4
68+
with:
69+
fetch-depth: 0
70+
ref: main
71+
72+
- name: Restore dependencies
73+
uses: actions/cache/restore@v4
74+
with:
75+
enableCrossOsArchive: true
76+
fail-on-cache-miss: true
77+
key: npm-install-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
78+
path: node_modules
79+
80+
- name: Restore build
81+
uses: actions/cache/restore@v4
82+
with:
83+
enableCrossOsArchive: true
84+
fail-on-cache-miss: true
85+
key: npm-build-${{ runner.os }}-${{ github.sha }}
86+
path: |
87+
.server
88+
.public
89+
90+
- name: Setup Node.js
91+
uses: actions/setup-node@v4
92+
with:
93+
node-version-file: .nvmrc
94+
registry-url: https://registry.npmjs.org
95+
scope: '@defra'
96+
97+
- name: Update package versions
98+
run: npm version patch --git-tag-version false --save
99+
100+
- name: Commit and push updates
101+
run: |
102+
git config user.name github-actions
103+
git config user.email github-actions@github.com
104+
git commit -am "v$(npm pkg get version | tr -d \") [skip ci]" && git push
43105
44-
# TODO
106+
- name: Publish to npm
107+
run: npm publish --access public
108+
env:
109+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

0 commit comments

Comments
 (0)