File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,9 @@ name: Node.js Package
6
6
on :
7
7
release :
8
8
types : [created]
9
-
10
9
workflow_dispatch :
10
+ workflow_run :
11
+ workflows : release
11
12
12
13
jobs :
13
14
build :
Original file line number Diff line number Diff line change
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 }}
You can’t perform that action at this time.
0 commit comments