Skip to content

Commit 2ec96b0

Browse files
authored
Fix NPM publishing (#562)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 921a708 commit 2ec96b0

File tree

1 file changed

+46
-18
lines changed

1 file changed

+46
-18
lines changed

.github/workflows/package.yml

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref_type }}
1212
cancel-in-progress: false
1313

14-
permissions:
15-
contents: write
16-
packages: write
17-
# See https://docs.npmjs.com/generating-provenance-statements#about-npm-provenance
18-
id-token: write
19-
2014
jobs:
2115
package:
2216
strategy:
@@ -131,6 +125,8 @@ jobs:
131125
publish:
132126
needs: [ package, snap ]
133127
runs-on: ubuntu-latest
128+
permissions:
129+
contents: write
134130
steps:
135131
- uses: actions/checkout@v4
136132
- uses: actions/download-artifact@v4
@@ -181,37 +177,71 @@ jobs:
181177
env:
182178
GH_TOKEN: ${{ github.token }}
183179

180+
publish-npm:
181+
needs: publish
182+
if: github.ref_type == 'tag'
183+
runs-on: ubuntu-latest
184+
permissions:
185+
contents: read
186+
id-token: write
187+
steps:
188+
- uses: actions/checkout@v4
189+
- uses: actions/setup-node@v4
190+
with:
191+
node-version: '22.x'
192+
registry-url: 'https://registry.npmjs.org'
193+
- name: Publish to NPM
194+
run: sudo npm install --global npm@latest && ./npm-deploy.sh ${{ github.ref_name }}
195+
196+
publish-pypi:
197+
needs: publish
198+
if: github.ref_type == 'tag'
199+
runs-on: ubuntu-latest
200+
permissions:
201+
contents: read
202+
steps:
203+
- uses: actions/checkout@v4
184204
- uses: actions/setup-python@v4
185205
with:
186206
python-version: '3.x'
187207
- run: python -m pip install --upgrade pip setuptools twine
188208
- name: Publish to PyPI
189209
run: ./pip-deploy.sh ${{ github.ref_name }}
190-
if: github.ref_type == 'tag'
191210
env:
192211
TWINE_USERNAME: __token__
193212
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
194213

195-
- uses: actions/setup-node@v4
214+
publish-snap:
215+
needs: publish
216+
if: github.ref_type == 'tag'
217+
runs-on: ubuntu-latest
218+
permissions:
219+
contents: read
220+
steps:
221+
- uses: actions/download-artifact@v4
196222
with:
197-
node-version: '22.x'
198-
registry-url: 'https://registry.npmjs.org'
199-
- name: Publish to NPM
200-
run: sudo npm install --global npm@latest && ./npm-deploy.sh ${{ github.ref_name }}
201-
if: github.ref_type == 'tag'
202-
223+
path: build/out/
224+
pattern: "snap-*"
225+
merge-multiple: true
203226
- name: Publish to Snap
204227
run: |
205228
sudo snap install snapcraft --classic
206229
snapcraft whoami
207230
snapcraft upload build/out/jsonschema_*_amd64.snap --release stable
208231
snapcraft upload build/out/jsonschema_*_arm64.snap --release stable
209-
if: github.ref_type == 'tag'
210232
env:
211233
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
212234

235+
publish-docker:
236+
needs: publish
237+
if: github.ref_type == 'tag'
238+
runs-on: ubuntu-latest
239+
permissions:
240+
contents: read
241+
packages: write
242+
steps:
243+
- uses: actions/checkout@v4
213244
- uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
214-
if: github.ref_type == 'tag'
215245
with:
216246
registry: ghcr.io
217247
username: ${{ github.actor }}
@@ -220,12 +250,10 @@ jobs:
220250
- uses: docker/setup-buildx-action@v3
221251
- uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
222252
id: meta-cli
223-
if: github.ref_type == 'tag'
224253
with:
225254
images: ghcr.io/${{ github.repository_owner }}/jsonschema
226255
- uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
227256
id: push-cli
228-
if: github.ref_type == 'tag'
229257
with:
230258
context: .
231259
file: Dockerfile

0 commit comments

Comments
 (0)