ci: use OIDC trusted publishing instead of NPM_TOKEN
- Added environment: npm + id-token: write permission - Added --provenance flag for supply chain security - Removed NPM_TOKEN secret dependency - Added setup-node with registry-url for OIDC auth
This commit is contained in:
@@ -28,8 +28,10 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
environment: npm
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -37,12 +39,14 @@ jobs:
|
|||||||
|
|
||||||
- uses: oven-sh/setup-bun@v2
|
- uses: oven-sh/setup-bun@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
- name: Configure npm auth
|
|
||||||
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
||||||
|
|
||||||
- name: Configure git
|
- name: Configure git
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
@@ -51,6 +55,8 @@ jobs:
|
|||||||
- name: Bump & publish core
|
- name: Bump & publish core
|
||||||
if: inputs.package == 'core' || inputs.package == 'both'
|
if: inputs.package == 'core' || inputs.package == 'both'
|
||||||
working-directory: packages/core
|
working-directory: packages/core
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ""
|
||||||
run: |
|
run: |
|
||||||
npm version ${{ inputs.bump }} --no-git-tag-version
|
npm version ${{ inputs.bump }} --no-git-tag-version
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
@@ -60,15 +66,17 @@ jobs:
|
|||||||
|
|
||||||
if [ "${{ inputs.dry-run }}" = "true" ]; then
|
if [ "${{ inputs.dry-run }}" = "true" ]; then
|
||||||
echo "🏜️ Dry run — would publish @pascal-app/core@$VERSION"
|
echo "🏜️ Dry run — would publish @pascal-app/core@$VERSION"
|
||||||
npm publish --dry-run
|
npm publish --dry-run --access public
|
||||||
else
|
else
|
||||||
npm publish --access public
|
npm publish --access public --provenance
|
||||||
echo "📦 Published @pascal-app/core@$VERSION"
|
echo "📦 Published @pascal-app/core@$VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Bump & publish viewer
|
- name: Bump & publish viewer
|
||||||
if: inputs.package == 'viewer' || inputs.package == 'both'
|
if: inputs.package == 'viewer' || inputs.package == 'both'
|
||||||
working-directory: packages/viewer
|
working-directory: packages/viewer
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ""
|
||||||
run: |
|
run: |
|
||||||
npm version ${{ inputs.bump }} --no-git-tag-version
|
npm version ${{ inputs.bump }} --no-git-tag-version
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
@@ -78,9 +86,9 @@ jobs:
|
|||||||
|
|
||||||
if [ "${{ inputs.dry-run }}" = "true" ]; then
|
if [ "${{ inputs.dry-run }}" = "true" ]; then
|
||||||
echo "🏜️ Dry run — would publish @pascal-app/viewer@$VERSION"
|
echo "🏜️ Dry run — would publish @pascal-app/viewer@$VERSION"
|
||||||
npm publish --dry-run
|
npm publish --dry-run --access public
|
||||||
else
|
else
|
||||||
npm publish --access public
|
npm publish --access public --provenance
|
||||||
echo "📦 Published @pascal-app/viewer@$VERSION"
|
echo "📦 Published @pascal-app/viewer@$VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user