Skip to content

Commit 2cedc05

Browse files
authored
ci(npm): migrate publishing to OIDC authentication (#1026)
Issue: DEVOPS-3952
1 parent abc391c commit 2cedc05

File tree

6 files changed

+87
-105
lines changed

6 files changed

+87
-105
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- master
77
pull_request:
8-
types: [ opened, synchronize, reopened ]
8+
types: [opened, synchronize, reopened]
99
workflow_dispatch:
1010

1111
env:
@@ -56,12 +56,12 @@ jobs:
5656

5757
checks:
5858
name: Checks [${{ matrix.os }}]
59+
needs: [formatting]
5960
runs-on: ${{ matrix.runner }}
60-
needs: formatting
6161
strategy:
6262
fail-fast: false
6363
matrix:
64-
os: [ windows, linux, macos ]
64+
os: [windows, linux, macos]
6565
include:
6666
- os: windows
6767
runner: windows-latest
@@ -75,17 +75,17 @@ jobs:
7575
uses: actions/checkout@v4
7676

7777
- name: Install devel packages
78-
if: runner.os == 'Linux'
78+
if: ${{ runner.os == 'Linux' }}
7979
run: |
8080
sudo apt-get -y install libasound2-dev
8181
8282
- name: Install NASM
83-
if: runner.os == 'Windows'
84-
shell: pwsh
83+
if: ${{ runner.os == 'Windows' }}
8584
run: |
8685
choco install nasm
8786
$Env:PATH += ";$Env:ProgramFiles\NASM"
8887
echo "PATH=$Env:PATH" >> $Env:GITHUB_ENV
88+
shell: pwsh
8989

9090
- name: Rust cache
9191
uses: Swatinem/rust-cache@v2.7.3
@@ -118,8 +118,8 @@ jobs:
118118

119119
fuzz:
120120
name: Fuzzing
121+
needs: [formatting]
121122
runs-on: ubuntu-latest
122-
needs: formatting
123123

124124
steps:
125125
- uses: actions/checkout@v4
@@ -147,8 +147,8 @@ jobs:
147147

148148
web:
149149
name: Web Client
150+
needs: [formatting]
150151
runs-on: ubuntu-latest
151-
needs: formatting
152152

153153
steps:
154154
- uses: actions/checkout@v4
@@ -173,8 +173,8 @@ jobs:
173173

174174
ffi:
175175
name: FFI
176+
needs: [formatting]
176177
runs-on: ubuntu-latest
177-
needs: formatting
178178

179179
steps:
180180
- uses: actions/checkout@v4
@@ -202,20 +202,14 @@ jobs:
202202

203203
success:
204204
name: Success
205-
runs-on: ubuntu-latest
206205
if: ${{ always() }}
207-
needs:
208-
- formatting
209-
- typos
210-
- checks
211-
- fuzz
212-
- web
213-
- ffi
206+
needs: [formatting, typos, checks, fuzz, web, ffi]
207+
runs-on: ubuntu-latest
214208

215209
steps:
216210
- name: Check success
217-
shell: pwsh
218211
run: |
219212
$results = '${{ toJSON(needs.*.result) }}' | ConvertFrom-Json
220213
$succeeded = $($results | Where { $_ -Ne "success" }).Count -Eq 0
221214
exit $(if ($succeeded) { 0 } else { 1 })
215+
shell: pwsh

.github/workflows/coverage.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- master
77
pull_request:
8-
types: [ opened, synchronize, reopened ]
8+
types: [opened, synchronize, reopened]
99
workflow_dispatch:
1010

1111
env:
@@ -32,19 +32,19 @@ jobs:
3232
run: cargo xtask cov install -v
3333

3434
- name: Generate PR report
35-
if: github.event.number != ''
35+
if: ${{ github.event.number != '' }}
36+
run: cargo xtask cov report-gh --repo "${{ github.repository }}" --pr "${{ github.event.number }}" -v
3637
env:
3738
GH_TOKEN: ${{ github.token }}
38-
run: cargo xtask cov report-gh --repo "${{ github.repository }}" --pr "${{ github.event.number }}" -v
3939

4040
- name: Configure Git Identity
41-
if: github.ref == 'refs/heads/master'
41+
if: ${{ github.ref == 'refs/heads/master' }}
4242
run: |
4343
git config --local user.name "github-actions[bot]"
4444
git config --local user.email "github-actions[bot]@users.noreply.github.com"
4545
4646
- name: Update coverage data
47-
if: github.ref == 'refs/heads/master'
47+
if: ${{ github.ref == 'refs/heads/master' }}
48+
run: cargo xtask cov update -v
4849
env:
4950
GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_TOKEN }}
50-
run: cargo xtask cov update -v

.github/workflows/fuzz.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ jobs:
3636

3737
fuzz:
3838
name: Fuzzing ${{ matrix.target }}
39+
needs: [corpus-download]
3940
runs-on: ubuntu-latest
40-
needs: corpus-download
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
target: [ pdu_decoding, rle_decompression, bitmap_stream, cliprdr_format, channel_processing ]
44+
target: [pdu_decoding, rle_decompression, bitmap_stream, cliprdr_format, channel_processing]
4545

4646
steps:
4747
- uses: actions/checkout@v4
@@ -108,9 +108,9 @@ jobs:
108108
109109
corpus-merge:
110110
name: Corpus merge artifacts
111-
runs-on: ubuntu-latest
112-
needs: fuzz
113111
if: ${{ always() && !cancelled() }}
112+
needs: [fuzz]
113+
runs-on: ubuntu-latest
114114

115115
steps:
116116
- name: Merge Artifacts
@@ -122,9 +122,9 @@ jobs:
122122

123123
corpus-upload:
124124
name: Upload corpus
125-
runs-on: ubuntu-latest
126-
needs: corpus-merge
127125
if: ${{ always() && !cancelled() }}
126+
needs: [corpus-merge]
127+
runs-on: ubuntu-latest
128128
env:
129129
AZURE_STORAGE_KEY: ${{ secrets.CORPUS_AZURE_STORAGE_KEY }}
130130

@@ -156,13 +156,13 @@ jobs:
156156
157157
notify:
158158
name: Notify failure
159-
runs-on: ubuntu-latest
160159
if: ${{ always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule' }}
161-
needs:
162-
- fuzz
160+
needs: [fuzz]
161+
runs-on: ubuntu-latest
163162
env:
164163
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ARCHITECTURE }}
165164
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
165+
166166
steps:
167167
- name: Send slack notification
168168
id: slack

.github/workflows/npm-publish.yml

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
steps:
2222
- name: Get dry run
2323
id: get-dry-run
24-
shell: pwsh
2524
run: |
2625
$IsDryRun = '${{ github.event.inputs.dry-run }}' -Eq 'true' -Or '${{ github.event_name }}' -Eq 'schedule'
2726
@@ -30,13 +29,12 @@ jobs:
3029
} else {
3130
echo "dry-run=false" >> $Env:GITHUB_OUTPUT
3231
}
32+
shell: pwsh
3333

3434
build:
3535
name: Build package [${{matrix.library}}]
36+
needs: [preflight]
3637
runs-on: ubuntu-latest
37-
needs:
38-
- preflight
39-
4038
strategy:
4139
fail-fast: false
4240
matrix:
@@ -49,33 +47,33 @@ jobs:
4947
uses: actions/checkout@v4
5048

5149
- name: Setup wasm-pack
52-
shell: bash
5350
run: |
5451
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
52+
shell: bash
5553

5654
- name: Install dependencies
57-
shell: pwsh
5855
run: |
5956
Set-Location -Path "./web-client/${{matrix.library}}/"
6057
npm install
58+
shell: pwsh
6159

6260
- name: Build package
63-
shell: pwsh
6461
run: |
6562
Set-PSDebug -Trace 1
6663
6764
Set-Location -Path "./web-client/${{matrix.library}}/"
6865
npm run build
6966
Set-Location -Path ./dist
7067
npm pack
68+
shell: pwsh
7169

7270
- name: Harvest package
73-
shell: pwsh
7471
run: |
7572
Set-PSDebug -Trace 1
7673
7774
New-Item -ItemType "directory" -Path . -Name "npm-packages"
7875
Get-ChildItem -Path ./web-client/ -Recurse *.tgz | ForEach { Copy-Item $_ "./npm-packages" }
76+
shell: pwsh
7977

8078
- name: Upload package artifact
8179
uses: actions/upload-artifact@v4
@@ -85,8 +83,8 @@ jobs:
8583

8684
npm-merge:
8785
name: Merge artifacts
86+
needs: [build]
8887
runs-on: ubuntu-latest
89-
needs: build
9088

9189
steps:
9290
- name: Merge Artifacts
@@ -98,12 +96,13 @@ jobs:
9896

9997
publish:
10098
name: Publish package
101-
runs-on: ubuntu-latest
102-
if: github.event_name == 'workflow_dispatch'
10399
environment: publish
104-
needs:
105-
- preflight
106-
- npm-merge
100+
if: ${{ github.event_name == 'workflow_dispatch' }}
101+
needs: [preflight, npm-merge]
102+
runs-on: ubuntu-latest
103+
permissions:
104+
contents: write
105+
id-token: write
107106

108107
steps:
109108
- name: Checkout repository
@@ -117,12 +116,7 @@ jobs:
117116
name: npm
118117
path: npm-packages
119118

120-
- name: Prepare npm
121-
shell: pwsh
122-
run: npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
123-
124119
- name: Publish
125-
shell: pwsh
126120
run: |
127121
Set-PSDebug -Trace 1
128122
@@ -168,15 +162,10 @@ jobs:
168162
$publishCmd = $publishCmd -Join ' '
169163
Invoke-Expression $publishCmd
170164
}
165+
shell: pwsh
171166

172167
- name: Create version tags
173168
if: ${{ needs.preflight.outputs.dry-run == 'false' }}
174-
shell: bash
175-
env:
176-
GIT_AUTHOR_NAME: github-actions
177-
GIT_AUTHOR_EMAIL: github-actions@github.com
178-
GIT_COMMITTER_NAME: github-actions
179-
GIT_COMMITTER_EMAIL: github-actions@github.com
180169
run: |
181170
set -e
182171
@@ -202,6 +191,12 @@ jobs:
202191
git tag "$tag" "$GITHUB_SHA"
203192
git push origin "$tag"
204193
done
194+
shell: bash
195+
env:
196+
GIT_AUTHOR_NAME: github-actions
197+
GIT_AUTHOR_EMAIL: github-actions@github.com
198+
GIT_COMMITTER_NAME: github-actions
199+
GIT_COMMITTER_EMAIL: github-actions@github.com
205200

206201
- name: Update Artifactory Cache
207202
if: ${{ needs.preflight.outputs.dry-run == 'false' }}
@@ -213,14 +208,13 @@ jobs:
213208

214209
notify:
215210
name: Notify failure
216-
runs-on: ubuntu-latest
217211
if: ${{ always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule' }}
218-
needs:
219-
- preflight
220-
- build
212+
needs: [preflight, build]
213+
runs-on: ubuntu-latest
221214
env:
222215
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ARCHITECTURE }}
223216
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
217+
224218
steps:
225219
- name: Send slack notification
226220
id: slack

0 commit comments

Comments
 (0)