Skip to content

Commit e9a1d63

Browse files
authored
chore: support semver releases using gh actions (#8)
1 parent f98edd7 commit e9a1d63

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'New semver version (e.g., 1.2.3)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20'
28+
registry-url: 'https://registry.npmjs.org'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Update package.json version
34+
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version
35+
36+
- name: Build package
37+
run: npm run build
38+
39+
- name: Configure Git
40+
run: |
41+
git config --local user.email "action@github.com"
42+
git config --local user.name "GitHub Action"
43+
44+
- name: Commit and push changes
45+
run: |
46+
git add package.json package-lock.json
47+
git commit -m "chore: release v${{ github.event.inputs.version }}"
48+
git push origin main
49+
50+
- name: Create Git tag
51+
run: |
52+
git tag v${{ github.event.inputs.version }}
53+
git push origin v${{ github.event.inputs.version }}
54+
55+
- name: Publish to npm
56+
run: npm publish --access public
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
59+
60+
- name: Create GitHub Release
61+
uses: actions/create-release@v1
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
tag_name: v${{ github.event.inputs.version }}
66+
release_name: Release v${{ github.event.inputs.version }}
67+
draft: false
68+
prerelease: false
69+
generate_release_notes: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ npm install @layercode/react-sdk
1010

1111
## Usage
1212

13-
Read the docs: [https://docs.layercode.com/sdk-reference/react_sdk](https://docs.layercode.com/sdk-reference/react_sdk)
13+
Read the docs: [https://docs.layercode.com/sdk-reference/react-sdk](https://docs.layercode.com/sdk-reference/react-sdk)

0 commit comments

Comments
 (0)