Skip to content

Commit 0305280

Browse files
committed
feat: 🚀 create a release script for npm publishing
1 parent 04c703f commit 0305280

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Create release from version bump
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create-release:
13+
name: Create GitHub Release
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 2
21+
22+
- name: Extract version from tag
23+
id: version_extract
24+
run: |
25+
# Remove 'v' prefix from tag name to get version
26+
VERSION=${GITHUB_REF#refs/tags/v}
27+
echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV
28+
echo "Extracted version: $VERSION"
29+
30+
- name: Create Release
31+
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: |
34+
gh release create "${{ github.ref_name }}" \
35+
--repo="${{ github.repository }}" \
36+
--title="Release ${{ github.ref_name }}" \
37+
--generate-notes
38+
39+
publish-npm:
40+
name: Publish to NPM
41+
needs: create-release
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
packages: write
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: actions/setup-node@v4
49+
with:
50+
node-version: "20.x"
51+
registry-url: https://registry.npmjs.org
52+
- run: |
53+
npm ci
54+
npm run build
55+
npm publish --registry=https://registry.npmjs.org
56+
env:
57+
NODE_AUTH_TOKEN: ${{secrets.GLIDE_ORG_NPM_TOKEN}}

0 commit comments

Comments
 (0)