Skip to content

Commit

Permalink
Update publish-with-provenance.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
feelepxyz authored Aug 25, 2023
1 parent 9049c39 commit 7d2d8b7
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions .github/workflows/publish-with-provenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ name: publish-with-provenance
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to publish to'
required: true
default: 'production'
type: choice
options:
- staging
- production
cli_version:
description: 'npm CLI version to install'
required: true
Expand All @@ -24,7 +16,7 @@ jobs:
contents: read
uses: bdehamer/workflows/.github/workflows/oidc-dump.yml@main
publish:
runs-on: ${{ github.event.inputs.environment == 'production' && 'ubuntu-latest' || 'self-hosted' }}
runs-on: 'ubuntu-latest'
permissions:
contents: read
id-token: write
Expand All @@ -35,20 +27,18 @@ jobs:
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3
with:
node-version: 18
registry-url: ${{ github.event.inputs.environment == 'production' && 'https://registry.npmjs.com' || secrets.NPM_REGISTRY_STAGING }}
registry-url: 'https://registry.npmjs.com'
check-latest: true
- name: Bump package versions
run: |
sed -i "s/1.0.0/1.0.0-${GITHUB_RUN_ID}.${GITHUB_RUN_ATTEMPT}/" "package.json"
- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ github.event.inputs.environment == 'production' && secrets.NPM_TOKEN_PRODUCTION || secrets.NPM_TOKEN_STAGING }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PRODUCTION }}
run: |
npm install -g npm@${{ github.event.inputs.cli_version }} --registry https://registry.npmjs.com
npm install --registry https://registry.npmjs.com
npm pack --json
TARBALL=$(readlink -f *.tgz)
npm publish ${TARBALL} --provenance --access public --registry ${{ github.event.inputs.environment == 'production' && 'https://registry.npmjs.com' || secrets.NPM_REGISTRY_STAGING }}
npm install -g npm@${{ github.event.inputs.cli_version }}
npm install
npm publish --provenance --access public
- uses: actions/upload-artifact@v3
with:
name: package.tgz
Expand Down

0 comments on commit 7d2d8b7

Please sign in to comment.