|
1 | | -name: Publish GitHub Package |
| 1 | +name: Publish to npm |
2 | 2 |
|
3 | 3 | on: |
| 4 | + release: |
| 5 | + types: [published] |
4 | 6 | workflow_dispatch: |
5 | 7 | inputs: |
6 | 8 | version: |
|
18 | 20 | type: string |
19 | 21 |
|
20 | 22 | permissions: |
21 | | - contents: read |
22 | | - packages: write |
| 23 | + contents: write |
| 24 | + id-token: write |
23 | 25 |
|
24 | 26 | jobs: |
25 | | - release: |
| 27 | + publish: |
26 | 28 | runs-on: ubuntu-latest |
27 | 29 | steps: |
28 | 30 | - name: Checkout |
29 | | - uses: actions/checkout@v6 |
| 31 | + uses: actions/checkout@v4 |
30 | 32 |
|
31 | 33 | - name: Setup Node |
32 | | - uses: actions/setup-node@v6 |
| 34 | + uses: actions/setup-node@v4 |
33 | 35 | with: |
34 | 36 | node-version: 20 |
35 | | - registry-url: https://npm.pkg.github.com |
36 | | - scope: '@fergusbisset' |
| 37 | + registry-url: 'https://registry.npmjs.org' |
37 | 38 |
|
38 | | - - name: Install |
| 39 | + - name: Install dependencies |
39 | 40 | run: npm ci |
40 | 41 |
|
41 | 42 | - name: Optionally bump version (manual dispatch only) |
42 | 43 | if: ${{ github.event_name == 'workflow_dispatch' && inputs.version != '' }} |
43 | 44 | run: | |
| 45 | + git config user.name github-actions |
| 46 | + git config user.email [email protected] |
44 | 47 | if [ "${{ inputs.version }}" = "prerelease" ]; then |
45 | 48 | npm version prerelease --preid=${{ inputs.preid || 'alpha' }} -m "chore(release): %s" |
46 | 49 | else |
47 | 50 | npm version ${{ inputs.version }} -m "chore(release): %s" |
48 | 51 | fi |
49 | 52 |
|
50 | | - - name: Build & Test |
| 53 | + - name: Run tests |
51 | 54 | run: | |
52 | 55 | 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 |
56 | 61 |
|
57 | | - - name: Publish (GitHub Packages) |
| 62 | + - name: Publish to npm |
58 | 63 | env: |
59 | | - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
60 | 65 | run: | |
61 | 66 | if [ -n "${{ inputs.tag }}" ] && [ "${{ inputs.tag }}" != "latest" ]; then |
62 | 67 | npm publish --access public --tag ${{ inputs.tag }} |
63 | 68 | else |
64 | 69 | npm publish --access public |
65 | 70 | fi |
66 | 71 |
|
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 != '' }} |
69 | 74 | run: | |
70 | 75 | 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 |
73 | 77 | git tag v$VERSION |
74 | 78 | git push origin v$VERSION |
75 | 79 |
|
76 | 80 | - 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 |
0 commit comments