-
Notifications
You must be signed in to change notification settings - Fork 22
78 lines (66 loc) · 2.58 KB
/
Copy pathPublishNpm.yml
File metadata and controls
78 lines (66 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Publish npm packages
on:
push:
tags:
- "pluggable-widgets-tools-v*"
- "generator-widget-v*"
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
discover:
name: Discover packages to publish
runs-on: ubuntu-latest
outputs:
releases: ${{ steps.export.outputs.releases }}
steps:
- name: Checking-out code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Get tags for HEAD
id: export
run: |
echo "releases=$(
(
for tag in $(git tag --points-at HEAD); do
package=${tag%-v*}
version=${tag##*-v}
# Without a file argument, jq will wait for stdin, unless you specify --null-input.
# By default jq pretty prints json. We need all of it on 1 line, so we use --compact-output here.
jq --null-input --compact-output --arg p $package --arg v $version '{ package: $p, version: $v }'
done
# The github outputs don't support unescaped newlines. So we use compact output here as well.
) | jq --compact-output --slurp '.'
)" >> "$GITHUB_OUTPUT"
publish:
name: "Publish NPM packages"
runs-on: ubuntu-latest
needs: discover
if: ${{ needs.discover.outputs.releases != '[]' }}
strategy:
fail-fast: false
matrix:
release: ${{ fromJSON(needs.discover.outputs.releases) }}
environment: ${{ matrix.release.package }}
steps:
- name: Check-out code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
- name: Setup node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: ".nvmrc"
cache: 'pnpm'
- name: Install dependencies
working-directory: ./packages/${{ matrix.release.package }}
run: pnpm install
- name: Pack package
working-directory: ./packages/${{ matrix.release.package }}
run: pnpm pack
- name: Setup node for npm publishing
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '24' # Includes a version of npm higher than 11.5.1, which is needed for OIDC
- name: Publish package
working-directory: ./packages/${{ matrix.release.package }}
run: npm publish mendix-${{ matrix.release.package }}-${{matrix.release.version }}.tgz