Skip to content

Commit 3da6d60

Browse files
committed
chore(*): update release workflow for npm publishing
1 parent 5419fab commit 3da6d60

1 file changed

Lines changed: 34 additions & 24 deletions

File tree

.github/workflows/release.yml

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,46 @@ on:
33
push:
44
branches:
55
- master
6-
jobs:
76

7+
jobs:
88
build:
9-
name: build-package
10-
runs-on: ubuntu-latest
11-
steps:
9+
name: build-and-publish
10+
runs-on: ubuntu-latest
11+
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v3
14-
- name: Setup node
15-
uses: actions/setup-node@v1
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v3
1617
with:
17-
node-version: '18.13.0'
18-
- name: Restore npm packages
18+
node-version: 18
19+
registry-url: "https://registry.npmjs.org"
20+
21+
- name: Install dependencies
1922
run: npm ci
20-
- name: Install Angular
23+
24+
- name: Install Angular CLI
2125
run: npm install -g @angular/cli
26+
2227
- name: Build package
2328
run: npm run build:lib
24-
- name: Publish if version has been updated
25-
if: github.ref == 'refs/heads/master'
26-
uses: pascalgn/npm-publish-action@1.3.9
27-
with:
28-
tag_name: "v%s"
29-
tag_message: "v%s"
30-
create_tag: "true"
31-
commit_pattern: "^chore\\(release\\): (\\S+)"
32-
workspace: "./@packaged/angular-star-rating"
33-
publish_command: "yarn"
34-
publish_args: "--non-interactive"
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3829

30+
- name: Publish to npm (only on chore(release): x.x.x commits)
31+
if: startsWith(github.event.head_commit.message, 'chore(release):')
32+
working-directory: ./@packaged/angular-star-rating
33+
run: |
34+
VERSION=$(node -p "require('./package.json').version")
35+
echo "Publishing version $VERSION"
36+
37+
# publish to npm
38+
npm publish --access public
39+
40+
# configure git
41+
git config user.name "${{ github.actor }}"
42+
git config user.email "${{ github.actor }}@users.noreply.github.com"
43+
44+
# create + push tag
45+
git tag "v$VERSION"
46+
git push origin "v$VERSION"
47+
env:
48+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)