Skip to content

Merge pull request #545 from DEFRA/allow-optional-name-title-guidance #8

Merge pull request #545 from DEFRA/allow-optional-name-title-guidance

Merge pull request #545 from DEFRA/allow-optional-name-title-guidance #8

Workflow file for this run

name: Publish Model
on:
push:
branches:
- main
paths:
- 'model/.browserslistrc'
- 'model/babel.config.*'
- 'model/src/**'
- '!**/*.test.*'
concurrency:
group: publish-model
permissions:
contents: write
packages: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v4
id: npm-install-model-cache
with:
enableCrossOsArchive: true
key: npm-install-model-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
path: |
model/node_modules
node_modules
- name: Cache build
uses: actions/cache@v4
with:
enableCrossOsArchive: true
key: npm-build-model-${{ runner.os }}-${{ github.sha }}
path: model/dist
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version-file: .nvmrc
- name: Install dependencies
if: steps.npm-install-model-cache.outputs.cache-hit != 'true'
run: npm ci --workspace model --include-workspace-root
- name: Run build
run: npm run build --workspace model
publish:
name: Publish
runs-on: ubuntu-latest
needs: [build]
environment: production
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Restore dependencies
uses: actions/cache/restore@v4
with:
enableCrossOsArchive: true
fail-on-cache-miss: true
key: npm-install-model-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
path: |
model/node_modules
node_modules
- name: Restore build
uses: actions/cache/restore@v4
with:
enableCrossOsArchive: true
fail-on-cache-miss: true
key: npm-build-model-${{ runner.os }}-${{ github.sha }}
path: model/dist
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
scope: '@defra'
- name: Update package versions
run: npm version patch --workspaces --include-workspace-root --git-tag-version false --save
- name: Commit and push updates
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git commit -am "v$(npm pkg get version | tr -d \") [skip ci]" && git push
- name: Publish to npm
run: npm publish --workspace model --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}