Skip to content

Commit a18c17e

Browse files
committed
Update CI/CD for npm public registry publishing
- Added npm-publish.yml workflow for publishing to npm public registry - Triggers on release or manual workflow dispatch - Supports version bumping (patch, minor, major, prerelease) - Publishes to https://registry.npmjs.org/ - Uses NPM_TOKEN secret for authentication - Removed release.yml (old GitHub Packages workflow) - Removed visual-testing.yml (Chromatic workflow - dependency removed) Note: NPM_TOKEN secret must be configured in repository settings
1 parent 9af2e62 commit a18c17e

File tree

2 files changed

+26
-86
lines changed

2 files changed

+26
-86
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
name: Publish GitHub Package
1+
name: Publish to npm
22

33
on:
4+
release:
5+
types: [published]
46
workflow_dispatch:
57
inputs:
68
version:
@@ -18,60 +20,64 @@ on:
1820
type: string
1921

2022
permissions:
21-
contents: read
22-
packages: write
23+
contents: write
24+
id-token: write
2325

2426
jobs:
25-
release:
27+
publish:
2628
runs-on: ubuntu-latest
2729
steps:
2830
- name: Checkout
29-
uses: actions/checkout@v6
31+
uses: actions/checkout@v4
3032

3133
- name: Setup Node
32-
uses: actions/setup-node@v6
34+
uses: actions/setup-node@v4
3335
with:
3436
node-version: 20
35-
registry-url: https://npm.pkg.github.com
36-
scope: '@fergusbisset'
37+
registry-url: 'https://registry.npmjs.org'
3738

38-
- name: Install
39+
- name: Install dependencies
3940
run: npm ci
4041

4142
- name: Optionally bump version (manual dispatch only)
4243
if: ${{ github.event_name == 'workflow_dispatch' && inputs.version != '' }}
4344
run: |
45+
git config user.name github-actions
46+
git config user.email [email protected]
4447
if [ "${{ inputs.version }}" = "prerelease" ]; then
4548
npm version prerelease --preid=${{ inputs.preid || 'alpha' }} -m "chore(release): %s"
4649
else
4750
npm version ${{ inputs.version }} -m "chore(release): %s"
4851
fi
4952
50-
- name: Build & Test
53+
- name: Run tests
5154
run: |
5255
npm run lint
53-
npm run verify:schema-macro
54-
npm run verify:macro-parity
55-
npm run build
56+
npm run test:components
57+
npm run test:ssr-components
58+
59+
- name: Build
60+
run: npm run build
5661

57-
- name: Publish (GitHub Packages)
62+
- name: Publish to npm
5863
env:
59-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6065
run: |
6166
if [ -n "${{ inputs.tag }}" ] && [ "${{ inputs.tag }}" != "latest" ]; then
6267
npm publish --access public --tag ${{ inputs.tag }}
6368
else
6469
npm publish --access public
6570
fi
6671
67-
- name: Create Git Tag (when version bumped)
68-
if: ${{ inputs.version != '' }}
72+
- name: Push version bump (when version bumped)
73+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.version != '' }}
6974
run: |
7075
VERSION=$(node -p "require('./package.json').version")
71-
git config user.name github-actions
72-
git config user.email [email protected]
76+
git push origin HEAD
7377
git tag v$VERSION
7478
git push origin v$VERSION
7579
7680
- name: Summary
77-
run: echo "Published @fergusbisset/nhs-fdp-design-system@$(node -p "require('./package.json').version") to GitHub Packages" >> $GITHUB_STEP_SUMMARY
81+
run: |
82+
VERSION=$(node -p "require('./package.json').version")
83+
echo "Published @nhsdigital/nhs-fdp-design-system@$VERSION to npm" >> $GITHUB_STEP_SUMMARY

.github/workflows/visual-testing.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)