1
- name : Create Release on PR merge
1
+ name : Update version and create Release's PR Workflow
2
2
3
3
on :
4
- pull_request :
5
- types : [closed]
6
- branches :
7
- - main
4
+ workflow_dispatch:
5
+ inputs :
6
+ version :
7
+ description : 'Version name'
8
+ required : true
9
+ default : 'minor'
10
+ type : choice
11
+ options :
12
+ - major
13
+ - minor
14
+ - patch
8
15
9
16
jobs :
10
- release :
11
- runs-on : ubuntu-latest
12
- steps :
13
- - name : Checkout repository
14
- uses : actions/checkout@v4
15
-
16
- - name : Set up Git
17
- uses : actions/setup-python@v5
18
- with :
19
- python-version : 3.x
20
-
21
- - name : Get the latest tag and increment version
22
- id : version
23
- run : |
24
- # Get the latest tag and strip the 'v' from the version
25
- latest_tag=$(git describe --tags --abbrev=0 2>/dev/null)
26
- echo "[DEBUG] Latest tag script exit code: $?"
27
-
28
- # If no tag exists, start from v1.0
29
- if [[ -z "$latest_tag" ]]; then
30
- latest_tag="v1.0"
31
- # Create the initial tag (v1.0)
32
- git tag $latest_tag
33
- git push origin $latest_tag
34
- fi
35
- echo "[DEBUG] Latest tag exit code: $?"
36
-
37
- # Increment the version (e.g., v1.1 -> v1.2)
38
- version_number=$(echo "$latest_tag" | sed 's/^v//')
39
- echo "[DEBUG] SED get version number exit code: $?"
40
-
41
- version_array=(${version_number//./ })
42
- major=${version_array[0]}
43
- minor=${version_array[1]}
44
-
45
- # Increment minor version by 1
46
- minor=$((minor + 1))
47
-
48
- # Ensure the version is in the form v1.x
49
- new_version="v$major.$minor"
50
-
51
- echo "New version: $new_version"
52
- echo "::set-output name=version::$new_version"
53
-
54
- - name : Create release files
55
- run : |
56
- version="${{ steps.version.outputs.version }}"
57
- # Make sure the config folder is in the tar and zip files
58
- mkdir -p release
59
- cp -r config/nvim release/
60
-
61
- # Create tar.gz file
62
- tar -czf "release/$version.tar.gz" -C release .
63
-
64
- # Create zip file
65
- zip -r "release/$version.zip" release
66
-
67
- - name : Create GitHub Release
68
- uses : softprops/action-gh-release@v2
69
- with :
70
- files : release/*.tar.gz,release/*.zip
71
- env :
72
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73
-
74
- - name : Clean up
75
- run : |
76
- rm -rf release
17
+ version :
18
+ runs-on : ubuntu-latest
19
+ steps :
20
+ - name : Checkout code
21
+ uses : actions/checkout@v3
22
+ - name : Setup Node.js
23
+ uses : actions/setup-node@v3
24
+ with :
25
+ node-version : "16.x"
26
+
27
+ - name : Install dependencies
28
+ run : npm install
29
+
30
+ - name : Set up Git
31
+ run : |
32
+ git config user.name "Your GitHub User Name"
33
+ git config user.email "Your GitHub User Email"
34
+
35
+ - name : Update the version
36
+ id : update_version
37
+ run : |
38
+ echo "version=$(npm version ${{ github.event.inputs.version }} --no-git- tag-version)" >> $GITHUB_OUTPUT
39
+
40
+ - name : Update Changelog
41
+ id : update_changelog
42
+ run : |
43
+ sed -i 's/Unreleased/${{ steps.update_version.outputs.version }}/g' CHANGELOG.md
44
+
45
+ - name : Create pull request
46
+ id : create_pr
47
+ uses : peter-evans/create-pull-request@v5
48
+ with :
49
+ token : ${{ secrets.GITHUB_TOKEN }}
50
+ branch : release/${{ steps.update_version.outputs.version }}
51
+ title : "Release: ${{ steps.update_version.outputs.version }} Pull Request"
52
+ body : "This pull request contains the updated package.json with the new release version"
53
+ base : main
0 commit comments