Skip to content

Commit a4e1745

Browse files
committed
ci(release): run on main pushes; publish only on tags
1 parent 7d93d1a commit a4e1745

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ name: Release (npm)
22

33
on:
44
push:
5-
tags:
6-
- 'v*'
5+
branches: [ main ] # run on main pushes (build/test only)
6+
tags: [ 'v*' ] # run on version tags (full release)
77

88
permissions:
9-
contents: write # needed to create a GitHub Release
9+
contents: write # needed to create GitHub Releases
1010

1111
jobs:
12-
publish:
12+
release:
1313
runs-on: ubuntu-latest
14+
1415
steps:
1516
- name: Checkout
1617
uses: actions/checkout@v4
@@ -31,12 +32,16 @@ jobs:
3132
- name: Build
3233
run: npm run build
3334

35+
# Only publish to npm on version tags (refs/tags/vX.Y.Z)
3436
- name: Publish to npm
37+
if: startsWith(github.ref, 'refs/tags/v')
3538
env:
3639
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3740
run: npm publish --access public
3841

42+
# Only create a GitHub Release on version tags
3943
- name: Create GitHub Release
44+
if: startsWith(github.ref, 'refs/tags/v')
4045
uses: softprops/action-gh-release@v1
4146
with:
4247
generate_release_notes: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![npm version](https://img.shields.io/npm/v/string-utils-lite?color=blue)](https://www.npmjs.com/package/string-utils-lite)
44
[![npm downloads](https://img.shields.io/npm/dm/string-utils-lite.svg)](https://www.npmjs.com/package/string-utils-lite)
55
[![CI](https://img.shields.io/github/actions/workflow/status/jahirultusar/JavaScript-string-utils-lite/ci.yml?branch=main)](https://github.com/jahirultusar/JavaScript-string-utils-lite/actions/workflows/ci.yml)
6-
[![Release](https://img.shields.io/github/actions/workflow/status/jahirultusar/JavaScript-string-utils-lite/release.yml?branch=main)](https://github.com/jahirultusar/JavaScript-string-utils-lite/actions/workflows/release.yml)
6+
[![Release](https://github.com/jahirultusar/JavaScript-string-utils-lite/actions/workflows/release.yml/badge.svg)](https://github.com/jahirultusar/JavaScript-string-utils-lite/actions/workflows/release.yml)
77
[![license](https://img.shields.io/github/license/jahirultusar/JavaScript-string-utils-lite)](./LICENSE)
88

99

0 commit comments

Comments
 (0)