Skip to content

Commit c7e4da9

Browse files
authored
[WTF-2433]: Make widgets-tools publishing actions "trusted publishers" with npm (#144)
2 parents 1c2760e + 0b3ce44 commit c7e4da9

File tree

1 file changed

+45
-25
lines changed

1 file changed

+45
-25
lines changed

.github/workflows/PublishNpm.yml

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,64 @@ on:
77
- "generator-widget-v*"
88

99
jobs:
10+
discover:
11+
name: Discover packages to publish
12+
runs-on: ubuntu-latest
13+
outputs:
14+
releases: ${{ steps.export.outputs.releases }}
15+
steps:
16+
- name: Checking-out code
17+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
18+
19+
- name: Get tags for HEAD
20+
id: export
21+
run: |
22+
echo "releases=$(
23+
(
24+
for tag in $(git tag --points-at HEAD); do
25+
echo "{ \"package\": \"${tag%-v*}\", \"version\": \"${tag##*-v}\" }"
26+
done
27+
) | jq --slurp '.'
28+
)" >> "$GITHUB_OUTPUT"
29+
1030
publish:
1131
name: "Publish NPM packages"
1232
runs-on: ubuntu-latest
1333

34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
release: ${{ fromJSON(needs.discover.outputs.releases) }}
38+
environment: ${{ matrix.release.package }}
39+
1440
steps:
15-
- name: "Checking-out code"
16-
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2
41+
- name: Check-out code
42+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
43+
44+
- name: Setup node
45+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1746
with:
18-
submodules: false
47+
node-version-file: ".nvmrc"
48+
cache: 'pnpm'
1949

2050
- name: Setup pnpm
2151
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
2252
with:
2353
version: 10
2454

25-
- name: "Defining Environment Variables"
26-
id: variables
27-
run: echo "::set-output name=tag::$(git tag --points-at HEAD)"
28-
29-
- name: "Defining node version"
30-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
31-
with:
32-
node-version-file: ".nvmrc"
33-
cache: 'pnpm'
34-
35-
- name: "Installing generator-widget dependencies"
55+
- name: Install dependencies
56+
working-directory: ./packages/${{ matrix.release.package }}
3657
run: pnpm install
3758

38-
- name: "Targeting Pluggable Widgets Tools"
39-
if: contains(steps.variables.outputs.tag, 'pluggable-widgets-tools-v')
40-
uses: JS-DevTools/npm-publish@0f451a94170d1699fd50710966d48fb26194d939 # v1
41-
with:
42-
package: "./packages/pluggable-widgets-tools/package.json"
43-
token: ${{ secrets.NPM_TOKEN }}
59+
- name: Pack package
60+
working-directory: ./packages/${{ matrix.release.package }}
61+
run: pnpm pack
4462

45-
- name: "Targeting Pluggable Widgets Generator"
46-
if: contains(steps.variables.outputs.tag, 'generator-widget-v')
47-
uses: JS-DevTools/npm-publish@0f451a94170d1699fd50710966d48fb26194d939 # v1
63+
- name: Setup node for npm publishing
64+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
4865
with:
49-
package: "./packages/generator-widget/package.json"
50-
token: ${{ secrets.NPM_TOKEN }}
66+
node-version: '24' # Includes a version of npm higher than 11.5.1, which is needed for OIDC
67+
68+
- name: Publish package
69+
working-directory: ./packages/${{ matrix.release.package }}
70+
run: npm publish mendix-${{ matrix.release.package }}-${{matrix.release.version }}.tgz

0 commit comments

Comments
 (0)