Skip to content

Commit 9595484

Browse files
authored
Merge pull request #122 from imagekit-developer/ci/npm-oidc-trusted-publishing
ci: publish to npm with OIDC trusted publishing
2 parents 2bd8b81 + e86d6b6 commit 9595484

2 files changed

Lines changed: 36 additions & 38 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
id-token: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Use Node.js 20.x
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 20.x
19+
registry-url: https://registry.npmjs.org/
20+
- name: Upgrade npm for OIDC trusted publishing
21+
run: npm install -g npm@latest
22+
- name: NPM Publish
23+
run: |
24+
npm install
25+
npm run build
26+
VERSION=$(node -p "require('./package.json').version")
27+
# Only publish stable versions to the latest tag
28+
if [[ "$VERSION" =~ ^[^-]+$ ]]; then
29+
NPM_TAG="latest"
30+
else
31+
NPM_TAG="beta"
32+
fi
33+
echo "Publishing $VERSION with $NPM_TAG tag."
34+
npm publish --tag $NPM_TAG --provenance --access public
35+
env:
36+
CI: true

0 commit comments

Comments
 (0)