|
1 | | -name: Publish |
| 1 | +name: Publish Model |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
7 | | - |
8 | 7 | paths: |
9 | 8 | - '.browserslistrc' |
10 | 9 | - 'babel.config.*' |
11 | | - - 'postcss.config.*' |
12 | | - - 'webpack.config.*' |
13 | | - - 'Dockerfile' |
14 | 10 | - 'src/**' |
15 | 11 | - '!**/*.test.*' |
16 | 12 |
|
17 | | - workflow_dispatch: |
18 | | - inputs: |
19 | | - version: |
20 | | - description: 'Version number manual override' |
21 | | - required: false |
22 | | - |
23 | 13 | concurrency: |
24 | | - group: publish |
| 14 | + group: publish-engine-plugin |
25 | 15 |
|
26 | 16 | permissions: |
27 | | - id-token: write |
28 | 17 | contents: write |
29 | | - pull-requests: write |
30 | | - |
31 | | -env: |
32 | | - AWS_REGION: eu-west-2 |
33 | | - AWS_ACCOUNT_ID: '094954420758' |
| 18 | + packages: write |
34 | 19 |
|
35 | 20 | jobs: |
36 | 21 | 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 |
39 | 61 | runs-on: ubuntu-24.04 |
| 62 | + needs: [build] |
| 63 | + environment: production |
| 64 | + |
40 | 65 | steps: |
41 | 66 | - name: Check out code |
42 | 67 | 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 |
43 | 105 |
|
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