Skip to content

Commit d5a4baa

Browse files
committed
2 parents 088cbe9 + 2ef2ceb commit d5a4baa

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ name: Node.js Package
66
on:
77
release:
88
types: [created]
9-
109
workflow_dispatch:
10+
workflow_run:
11+
workflows: release
1112

1213
jobs:
1314
build:

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
create-release:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
# Step 1: Check out the code
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
# Step 2: Set up Node.js
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '16' # Use the latest LTS version of Node.js
21+
22+
# Step 3: Read the version from package.json
23+
- name: Get version from package.json
24+
id: get_version
25+
run: |
26+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
27+
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
28+
29+
# Step 4: Create the tag
30+
- name: Create tag
31+
run: |
32+
git config user.name "github-actions[bot]"
33+
git config user.email "github-actions[bot]@users.noreply.github.com"
34+
git tag -a "${PACKAGE_VERSION}" -m "Release ${PACKAGE_VERSION}"
35+
git push origin "${PACKAGE_VERSION}"
36+
37+
# Step 5: Create GitHub release
38+
- name: Create GitHub Release
39+
uses: actions/create-release@v1
40+
with:
41+
tag_name: "${{ env.PACKAGE_VERSION }}"
42+
release_name: "Release ${{ env.PACKAGE_VERSION }}"
43+
draft: false
44+
prerelease: false
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)