-
Notifications
You must be signed in to change notification settings - Fork 8
128 lines (110 loc) · 3.71 KB
/
Copy pathclients-node.yml
File metadata and controls
128 lines (110 loc) · 3.71 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: "Clients Node"
on:
push:
branches: ['**']
paths:
- 'clients/node/**'
- 'commons/swagger/**'
- '.github/workflows/clients-node.yml'
tags:
- 'node-api-*-v*'
jobs:
test:
name: Test (Node ${{ matrix.node }})
if: github.ref_type != 'tag'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['18', '20', '22']
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
- name: Install root devDependencies
working-directory: clients/node
run: npm ci
- name: commons
working-directory: clients/node/commons
run: npm ci && npm test
- name: api-entreprise
working-directory: clients/node/api-entreprise
run: npm ci && npm test
- name: api-particulier
working-directory: clients/node/api-particulier
run: npm ci && npm test
freshness:
name: sync-commons & scaffold-resources freshness
if: github.ref_type != 'tag'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-node@v7
with:
node-version: '22'
- name: Install root devDependencies
working-directory: clients/node
run: npm ci
- name: Verify vendored commons is up to date
run: npx tsx clients/node/bin/sync-commons.ts --check
- name: Verify scaffolded resources are up to date
run: npx tsx clients/node/bin/scaffold-resources.ts --api all --check
release:
name: Build & publish to npm
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
environment: npm
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v7.0.1
- name: Resolve package from tag
id: pkg
run: |
case "$GITHUB_REF_NAME" in
node-api-entreprise-v*)
echo "dir=clients/node/api-entreprise" >>"$GITHUB_OUTPUT"
;;
node-api-particulier-v*)
echo "dir=clients/node/api-particulier" >>"$GITHUB_OUTPUT"
;;
*)
echo "Unsupported tag: $GITHUB_REF_NAME" >&2
exit 1
;;
esac
- uses: actions/setup-node@v7
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Verify tag version matches package.json version
working-directory: ${{ steps.pkg.outputs.dir }}
run: |
tag_version="${GITHUB_REF_NAME##*-v}"
pkg_version=$(node -p "require('./package.json').version")
if [ "$tag_version" != "$pkg_version" ]; then
echo "Tag version '$tag_version' does not match package.json version '$pkg_version'" >&2
exit 1
fi
echo "Releasing $(node -p "require('./package.json').name") $pkg_version"
- name: Install and test
working-directory: ${{ steps.pkg.outputs.dir }}
run: npm ci && npm test
- name: Build
working-directory: ${{ steps.pkg.outputs.dir }}
run: npm run build
- name: Mint OIDC token for npm
id: npm-oidc
run: |
response=$(curl -sS -f \
-H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
-H "Accept: application/json" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://registry.npmjs.org")
echo "token=$(echo "$response" | jq -r '.value')" >> "$GITHUB_OUTPUT"
- name: Publish
working-directory: ${{ steps.pkg.outputs.dir }}
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ steps.npm-oidc.outputs.token }}