Skip to content

Commit

Permalink
ci: npm workflow: provenance, node action update, version check
Browse files Browse the repository at this point in the history
Improve the reusable npm workflow:
- Configure npm provenance for package publishing
- Update setup-node action to v4
- Relax node version to any Node 20 version. Our docker images behave the same.
- Explicitly set permissions for workflow
- Get package version from package.json instead of hardcoded env variable
  • Loading branch information
lucas-koehler committed Jun 6, 2024
1 parent 3e50954 commit 23d41f3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/reusable-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ on:
npm-token:
required: true

env:
VERSION: 0.11.0-next
permissions:
contents: read
id-token: write

jobs:
build:
Expand All @@ -25,9 +26,9 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"
node-version: 20

- name: Install dependencies
run: npm ci
Expand All @@ -49,16 +50,18 @@ jobs:
if: github.event_name == 'push'
id: version_check
run: |
VERSION=$(node --print "require('./package.json').version")
echo "Package version: ${VERSION}"
if [[ $VERSION == *"-next" ]]; then
echo "is_next_version=true" >> $GITHUB_OUTPUT
else
echo "is_next_version=false" >> $GITHUB_OUTPUT
fi
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "20.10.0"
node-version: 20
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
Expand All @@ -69,9 +72,11 @@ jobs:
run: npm run publish:next -w ${{ inputs.package_workspace }}
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-token }}
NPM_CONFIG_PROVENANCE: true

- name: Publish latest version
if: github.event_name == 'release'
run: npm run publish:latest -w ${{ inputs.package_workspace }}
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-token }}
NPM_CONFIG_PROVENANCE: true

0 comments on commit 23d41f3

Please sign in to comment.