|
1 | 1 | on: |
2 | | - workflow_dispatch: |
3 | 2 | push: |
4 | 3 | branches: |
5 | 4 | - main |
6 | | - - ci-build |
7 | 5 | paths: |
8 | 6 | - '.github/workflows/generator.yml' |
9 | 7 | - 'generator/sonos-docs/src/**/*.ts' |
10 | | - - 'generator/sonos-docs/.releaserc' |
| 8 | + - 'generator/sonos-docs/package.json' |
11 | 9 |
|
12 | 10 | pull_request: |
13 | 11 | branches: |
14 | 12 | - main |
15 | 13 | paths: |
16 | 14 | - '.github/workflows/generator.yml' |
17 | 15 | - 'generator/sonos-docs/src/**/*.ts' |
| 16 | + - 'generator/sonos-docs/package.json' |
| 17 | + |
| 18 | + release: |
| 19 | + types: [published] |
18 | 20 |
|
19 | 21 | jobs: |
20 | 22 | test: |
21 | | - name: 'Build and test on Node v${{ matrix.node }}' |
| 23 | + name: 'Build and test on Node ${{ matrix.node }}' |
22 | 24 | runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + contents: read |
23 | 27 | strategy: |
24 | 28 | matrix: |
25 | | - node: [16, 18] |
| 29 | + node: [22, 24] |
26 | 30 | defaults: |
27 | 31 | run: |
28 | 32 | working-directory: generator/sonos-docs |
29 | 33 | steps: |
30 | | - - uses: actions/checkout@v4 |
31 | | - - uses: actions/setup-node@v4 |
| 34 | + - uses: actions/checkout@v7 |
| 35 | + - uses: actions/setup-node@v6 |
32 | 36 | with: |
33 | 37 | node-version: ${{ matrix.node }} |
34 | | - - name: Install depencencies |
| 38 | + - name: Install dependencies |
35 | 39 | run: npm ci |
36 | 40 | - name: Build library |
37 | | - run: npm run prepack |
| 41 | + run: npm run build |
| 42 | + - name: Run tests |
| 43 | + run: npm test |
38 | 44 |
|
39 | | - release: |
40 | | - name: 'Release generator' |
| 45 | + npm-publish: |
| 46 | + name: 'Publish to npm' |
41 | 47 | needs: [test] |
42 | 48 | runs-on: ubuntu-latest |
43 | | - if: github.event_name != 'pull_request' |
| 49 | + if: github.event_name == 'release' |
| 50 | + permissions: |
| 51 | + contents: read |
| 52 | + id-token: write |
| 53 | + packages: write |
44 | 54 | defaults: |
45 | 55 | run: |
46 | 56 | working-directory: generator/sonos-docs |
47 | 57 | steps: |
48 | | - - uses: actions/checkout@v4 |
49 | | - - uses: actions/setup-node@v4 |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v7 |
| 60 | + |
| 61 | + - name: Setup node for npm registry |
| 62 | + uses: actions/setup-node@v6 |
50 | 63 | with: |
51 | | - node-version: 16 |
52 | | - - name: Install depencencies |
| 64 | + node-version: 24 |
| 65 | + registry-url: 'https://registry.npmjs.org' |
| 66 | + |
| 67 | + - name: Install dependencies |
53 | 68 | run: npm ci |
54 | | - - name: Semantic Release |
55 | | - uses: cycjimmy/semantic-release-action@v4 |
56 | | - id: semantic |
57 | | - with: |
58 | | - working_directory: generator/sonos-docs |
59 | | - env: |
60 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
61 | | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
62 | | - - name: Setup node for Github Registry |
63 | | - if: steps.semantic.outputs.new_release_published == 'true' |
64 | | - uses: actions/setup-node@v4 |
| 69 | + |
| 70 | + - name: Set version from release tag |
| 71 | + run: npm version --no-git-tag-version "${{ github.event.release.tag_name }}" |
| 72 | + |
| 73 | + - name: Build library |
| 74 | + run: npm run prepack |
| 75 | + |
| 76 | + - name: Publish to npm |
| 77 | + run: npm publish --access public --provenance --tag ${{ github.event.release.prerelease && 'beta' || 'latest' }} |
| 78 | + |
| 79 | + - name: Setup node for GitHub Package Registry |
| 80 | + uses: actions/setup-node@v6 |
65 | 81 | with: |
66 | | - node-version: 16 |
| 82 | + node-version: 24 |
67 | 83 | registry-url: 'https://npm.pkg.github.com' |
68 | | - scope: 'svrooij' |
69 | | - - name: Publish To GitHub Package Registry |
70 | | - if: steps.semantic.outputs.new_release_published == 'true' |
71 | | - run: | |
72 | | - npm publish |
| 84 | + scope: '@svrooij' |
| 85 | + |
| 86 | + - name: Publish to GitHub Package Registry |
| 87 | + run: npm publish --tag ${{ github.event.release.prerelease && 'beta' || 'latest' }} |
73 | 88 | env: |
74 | | - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 89 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments