Skip to content

Commit 83fdaa3

Browse files
authored
Merge pull request #189 from codex-team/ci/reusable-publish-workflow
ci: publish-package workflow with npm version check
2 parents bff695e + e1063e2 commit 83fdaa3

3 files changed

Lines changed: 57 additions & 21 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish package to NPM
1+
name: Publish packages to NPM
22

33
on:
44
push:
@@ -7,26 +7,22 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
publish:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
- uses: actions/setup-node@v6
15-
with:
16-
node-version-file: '.nvmrc'
17-
registry-url: https://registry.npmjs.org/
18-
- run: corepack enable
19-
- run: yarn
20-
- run: yarn lint-test
21-
- run: yarn build:all
22-
- run: yarn workspace @hawk.so/core npm publish --access=public
23-
env:
24-
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
25-
- run: yarn workspace @hawk.so/javascript npm publish --access=public
26-
env:
27-
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10+
publish-core:
11+
uses: ./.github/workflows/publish-package.yml
12+
with:
13+
workspace: '@hawk.so/core'
14+
path: packages/core
15+
secrets: inherit
16+
17+
publish-javascript:
18+
uses: ./.github/workflows/publish-package.yml
19+
with:
20+
workspace: '@hawk.so/javascript'
21+
path: packages/javascript
22+
secrets: inherit
23+
2824
notify:
29-
needs: publish
25+
needs: [publish-core, publish-javascript]
3026
runs-on: ubuntu-latest
3127
steps:
3228
- uses: actions/checkout@v4
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish package to NPM
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
workspace:
7+
required: true
8+
type: string
9+
description: 'Yarn workspace name'
10+
path:
11+
required: true
12+
type: string
13+
description: 'Package directory relative to repo root'
14+
secrets:
15+
NPM_TOKEN:
16+
required: true
17+
18+
jobs:
19+
publish:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-node@v6
24+
with:
25+
node-version-file: '.nvmrc'
26+
registry-url: https://registry.npmjs.org/
27+
- run: corepack enable
28+
- run: yarn
29+
- run: yarn lint-test
30+
- run: yarn build:all
31+
- name: Publish ${{ inputs.workspace }}
32+
run: |
33+
VERSION=$(node -p "require('./${{ inputs.path }}/package.json').version")
34+
if npm view "${{ inputs.workspace }}@$VERSION" version &>/dev/null; then
35+
echo "${{ inputs.workspace }}@$VERSION already published, skipping"
36+
else
37+
yarn workspace ${{ inputs.workspace }} npm publish --access=public
38+
fi
39+
env:
40+
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

packages/javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hawk.so/javascript",
3-
"version": "3.3.4",
3+
"version": "3.3.5",
44
"description": "JavaScript errors tracking for Hawk.so",
55
"files": [
66
"dist"

0 commit comments

Comments
 (0)