Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 30f959c

Browse files
committed
fix: add npm publish with provenance support
1 parent c8d981e commit 30f959c

File tree

5 files changed

+143
-4
lines changed

5 files changed

+143
-4
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Clone repository
2929
uses: actions/checkout@v4
3030
with:
31-
fetch-depth: 3
31+
fetch-depth: 0
3232

3333
- name: Set Node.js version
3434
uses: actions/setup-node@v4
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: 🏷️👀 Publish (dry-run)
2+
3+
on: workflow_dispatch
4+
5+
permissions:
6+
contents: write
7+
id-token: write
8+
9+
jobs:
10+
deploy-npm-latest:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
steps:
14+
- name: Retrieve current Date Time in EST
15+
shell: bash
16+
run: echo "START_TIME=$(TZ=":America/New_York" date -R|sed 's/.....$//')" >> $GITHUB_ENV
17+
18+
- name: Current datetime - ${{ env.START_TIME }}
19+
run: echo ${{ env.START_TIME }}
20+
21+
- name: Clone repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- if: ${{ github.event.pull_request.merged != true && contains('["ghiscoding"]', github.actor) != true }}
28+
name: Ensure current actor is allowed to run the workflow
29+
run: |
30+
echo "Error: Your GitHub username (${{ github.actor }}) is not on the allowed list of admins for this workflow"
31+
exit 1
32+
33+
- name: Set NodeJS
34+
uses: actions/setup-node@v4
35+
with:
36+
registry-url: 'https://registry.npmjs.org/'
37+
node-version: 20
38+
39+
- name: Get yarn cache directory path
40+
id: yarn-cache-dir-path
41+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
42+
43+
- uses: actions/cache@v3
44+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
45+
with:
46+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
47+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
48+
restore-keys: |
49+
${{ runner.os }}-yarn-
50+
51+
- name: Run yarn install dependencies
52+
run: yarn --frozen-lockfile
53+
54+
- name: Run Project Build
55+
run: yarn run build
56+
57+
- name: "[dry-run] 🧪 NPM Release"
58+
env:
59+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
NPM_CONFIG_PROVENANCE: true
62+
run: |
63+
git config --global user.name "${{ github.actor }}"
64+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
65+
npm whoami
66+
npx release-it --ci --dry-run
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: 🏷️ Publish NPM Latest
2+
3+
on: workflow_dispatch
4+
5+
permissions:
6+
contents: write
7+
id-token: write
8+
9+
jobs:
10+
deploy-npm-latest:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
steps:
14+
- name: Retrieve current Date Time in EST
15+
shell: bash
16+
run: echo "START_TIME=$(TZ=":America/New_York" date -R|sed 's/.....$//')" >> $GITHUB_ENV
17+
18+
- name: Current datetime - ${{ env.START_TIME }}
19+
run: echo ${{ env.START_TIME }}
20+
21+
- name: Clone repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- if: ${{ github.event.pull_request.merged != true && contains('["ghiscoding"]', github.actor) != true }}
28+
name: Ensure current actor is allowed to run the workflow
29+
run: |
30+
echo "Error: Your GitHub username (${{ github.actor }}) is not on the allowed list of admins for this workflow"
31+
exit 1
32+
33+
- name: Set NodeJS
34+
uses: actions/setup-node@v4
35+
with:
36+
registry-url: 'https://registry.npmjs.org/'
37+
node-version: 20
38+
39+
- name: Get yarn cache directory path
40+
id: yarn-cache-dir-path
41+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
42+
43+
- uses: actions/cache@v3
44+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
45+
with:
46+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
47+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
48+
restore-keys: |
49+
${{ runner.os }}-yarn-
50+
51+
- name: Run yarn install dependencies
52+
run: yarn --frozen-lockfile
53+
54+
- name: Run Project Build
55+
run: yarn run build
56+
57+
- name: OTP
58+
uses: step-security/wait-for-secrets@v1
59+
id: wait-for-secrets
60+
with:
61+
secrets: |
62+
OTP:
63+
name: 'OTP to publish package'
64+
description: 'OTP from authenticator app'
65+
66+
- name: GitHub Release 🏷️ / NPM Publish 📦
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
NPM_CONFIG_PROVENANCE: true
71+
run: |
72+
git config --global user.name "${{ github.actor }}"
73+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
74+
npm whoami
75+
npx release-it --ci --npm.otp=${{ steps.wait-for-secrets.outputs.OTP }}

.npmrc

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"repository": {
3939
"type": "git",
40-
"url": "http://github.com/ghiscoding/angular-slickgrid"
40+
"url": "git+ssh://git@github.com/ghiscoding/angular-slickgrid.git"
4141
},
4242
"main": "src/app/modules/angular-slickgrid/index",
4343
"private": false,

0 commit comments

Comments
 (0)