-
Notifications
You must be signed in to change notification settings - Fork 48
124 lines (101 loc) · 2.93 KB
/
npm-publish.yml
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
name: Publish npm package
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run'
required: true
type: boolean
default: true
schedule:
- cron: '48 3 * * 1' # 3:48 AM UTC every Monday
jobs:
preflight:
name: Preflight
runs-on: ubuntu-20.04
outputs:
dry-run: ${{ steps.get-dry-run.outputs.dry-run }}
steps:
- name: Get dry run
id: get-dry-run
shell: pwsh
run: |
$IsDryRun = '${{ github.event.inputs.dry-run }}' -Eq 'true' -Or '${{ github.event_name }}' -Eq 'schedule'
if ($IsDryRun) {
echo "dry-run=true" >> $Env:GITHUB_OUTPUT
} else {
echo "dry-run=false" >> $Env:GITHUB_OUTPUT
}
build:
name: Build package
runs-on: ubuntu-20.04
needs:
- preflight
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup wasm-pack
shell: bash
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install dependencies
shell: pwsh
run: |
Set-Location -Path ./web-client/iron-remote-gui/
npm install
- name: Build package
shell: pwsh
run: |
Set-PSDebug -Trace 1
Set-Location -Path ./web-client/iron-remote-gui/
npm run build
Set-Location -Path ./dist
npm pack
- name: Harvest package
shell: pwsh
run: |
Set-PSDebug -Trace 1
New-Item -ItemType "directory" -Path . -Name "npm-packages"
Get-ChildItem -Path ./web-client/ -Recurse *.tgz | ForEach { Copy-Item $_ "./npm-packages" }
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: npm
path: npm-packages/*.tgz
publish:
name: Publish package
runs-on: ubuntu-20.04
if: github.event_name == 'workflow_dispatch'
environment: publish
needs:
- preflight
- build
steps:
- name: Download NPM packages artifact
uses: actions/download-artifact@v4
with:
name: npm
path: npm-packages
- name: Prepare npm
shell: pwsh
run: npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
- name: Publish
shell: pwsh
run: |
Set-PSDebug -Trace 1
$isDryRun = '${{ needs.preflight.outputs.dry-run }}' -Eq 'true'
$files = Get-ChildItem -Recurse npm-packages/*.tgz
foreach ($file in $files) {
Write-Host "Publishing $($File.Name)..."
$publishCmd = @(
'npm',
'publish',
"$File",
'--access=public'
)
if ($isDryRun) {
$publishCmd += '--dry-run'
}
$publishCmd = $publishCmd -Join ' '
Invoke-Expression $publishCmd
}