Skip to content

Commit af7e297

Browse files
committed
chore(ci): use trusted publishing instead of a token
1 parent f4edbcc commit af7e297

File tree

3 files changed

+21
-31
lines changed

3 files changed

+21
-31
lines changed

.github/workflows/npm-publish.yml

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches: [main]
66

7+
permissions:
8+
id-token: write # Required for OIDC https://docs.npmjs.com/trusted-publishers
9+
710
jobs:
811
dry-run:
912
runs-on: ubuntu-latest
@@ -15,33 +18,17 @@ jobs:
1518
node-version: "22"
1619
- run: npm ci
1720
- name: Check formatting
18-
run: |
19-
set -eo pipefail
20-
files_to_format=$(npm run format:check --silent || true)
21-
if [ -n "$files_to_format" ]; then
22-
echo "The following files are not formatted correctly:"
23-
echo "$files_to_format"
24-
{
25-
echo "formatted_files<<EOF"
26-
echo "$files_to_format"
27-
echo "EOF"
28-
echo "formatting_needed=true"
29-
} >> $GITHUB_OUTPUT
30-
exit 1
31-
else
32-
echo "All files are formatted correctly."
33-
echo "formatting_needed=false" >> $GITHUB_OUTPUT
34-
fi
35-
- run: npm test
36-
- uses: JS-DevTools/npm-publish@v3
21+
run: make format-check
22+
# Ensure npm 11.5.1 or later is installed
23+
- name: Update npm
24+
run: npm install -g npm@latest
25+
- name: Dry run
3726
if: github.actor != 'dependabot[bot]'
38-
with:
39-
token: ${{ secrets.NPM_TOKEN }}
40-
dry-run: true
27+
run: npm publish --dry-run
4128

4229
publish:
4330
needs: dry-run
44-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
31+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]'
4532
runs-on: ubuntu-latest
4633
timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }}
4734
steps:
@@ -50,8 +37,8 @@ jobs:
5037
with:
5138
node-version: "22"
5239
- run: npm ci
53-
- run: npm test
54-
- uses: JS-DevTools/npm-publish@v3
55-
if: github.actor != 'dependabot[bot]'
56-
with:
57-
token: ${{ secrets.NPM_TOKEN }}
40+
# Ensure npm 11.5.1 or later is installed
41+
- name: Update npm
42+
run: npm install -g npm@latest
43+
- name: Publish
44+
run: npm publish

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ bun:
2020
bun run dev
2121

2222
format:
23-
npm run format-all
23+
npm run format
24+
25+
format-check:
26+
npm run format:check
2427

2528
dry:
2629
npm run dry

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"svelte": "index.mjs",
88
"scripts": {
99
"test": "echo test",
10-
"format-all": "prettier --write .",
11-
"format:check": "prettier --list-different .",
10+
"format": "prettier --write .",
11+
"format:check": "prettier --check .",
1212
"dev": "sass components/global.scss components/global.css; storybook dev -p 6007",
1313
"build": "sass components/global.scss components/global.css; storybook build",
1414
"dry": "npx semantic-release --dry-run",

0 commit comments

Comments
 (0)