@@ -2,29 +2,96 @@ name: Release
22
33on :
44 push :
5- tags :
6- - ' v* '
5+ branches :
6+ - main
77
88jobs :
9- create- release :
9+ release :
1010 runs-on : ubuntu-latest
1111 outputs :
1212 release_id : ${{ steps.create-release.outputs.id }}
1313 release_upload_url : ${{ steps.create-release.outputs.upload_url }}
14+ new_version : ${{ steps.version-bump.outputs.new_version }}
1415 steps :
1516 - name : Checkout repository
1617 uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0
20+ token : ${{ secrets.GITHUB_TOKEN }}
21+
22+ - name : Read current version
23+ id : read-version
24+ run : |
25+ CURRENT_VERSION=$(jq -r '.version' src-tauri/tauri.conf.json)
26+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
27+ echo "Current version: $CURRENT_VERSION"
28+
29+ - name : Check if tag already exists
30+ id : check-tag
31+ run : |
32+ CURRENT_VERSION="${{ steps.read-version.outputs.current_version }}"
33+ if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
34+ echo "tag_exists=true" >> $GITHUB_OUTPUT
35+ echo "Tag v$CURRENT_VERSION already exists"
36+ else
37+ echo "tag_exists=false" >> $GITHUB_OUTPUT
38+ echo "Tag v$CURRENT_VERSION does not exist"
39+ fi
40+
41+ - name : Bump version
42+ id : version-bump
43+ if : steps.check-tag.outputs.tag_exists == 'false'
44+ run : |
45+ CURRENT_VERSION="${{ steps.read-version.outputs.current_version }}"
46+ # Split version and increment patch
47+ NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{print $1"."$2"."$3+1}')
48+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
49+ echo "New version: $NEW_VERSION"
50+
51+ - name : Update tauri.conf.json
52+ if : steps.check-tag.outputs.tag_exists == 'false'
53+ run : |
54+ NEW_VERSION="${{ steps.version-bump.outputs.new_version }}"
55+ jq --arg new_version "$NEW_VERSION" '.version = $new_version' src-tauri/tauri.conf.json > src-tauri/tauri.conf.json.tmp
56+ mv src-tauri/tauri.conf.json.tmp src-tauri/tauri.conf.json
57+
58+ - name : Update package.json
59+ if : steps.check-tag.outputs.tag_exists == 'false'
60+ run : |
61+ NEW_VERSION="${{ steps.version-bump.outputs.new_version }}"
62+ jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json > package.json.tmp
63+ mv package.json.tmp package.json
64+
65+ - name : Commit version bump
66+ if : steps.check-tag.outputs.tag_exists == 'false'
67+ run : |
68+ git config --local user.email "action@github.com"
69+ git config --local user.name "GitHub Action"
70+ NEW_VERSION="${{ steps.version-bump.outputs.new_version }}"
71+ git add src-tauri/tauri.conf.json package.json
72+ git commit -m "chore: bump version to v$NEW_VERSION [skip ci]"
73+
74+ - name : Create and push tag
75+ if : steps.check-tag.outputs.tag_exists == 'false'
76+ run : |
77+ NEW_VERSION="${{ steps.version-bump.outputs.new_version }}"
78+ git tag "v$NEW_VERSION"
79+ git push origin "v$NEW_VERSION"
80+
81+ - name : Push version bump commit
82+ if : steps.check-tag.outputs.tag_exists == 'false'
83+ run : |
84+ git push origin main
1785
1886 - name : Create Release
1987 id : create-release
20- uses : actions/create-release@v1
21- env :
22- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
88+ if : steps.check-tag.outputs.tag_exists == 'false'
89+ uses : softprops/action-gh-release@v1
2390 with :
24- tag_name : ${{ github.ref_name }}
25- release_name : Prasaran ${{ github.ref_name }}
91+ tag_name : v ${{ steps.version-bump.outputs.new_version }}
92+ name : Prasaran v ${{ steps.version-bump.outputs.new_version }}
2693 body : |
27- ## Prasaran ${{ github.ref_name }}
94+ ## Prasaran v ${{ steps.version-bump.outputs.new_version }}
2895
2996 Lightweight stream viewer for Facebook Live and YouTube Live.
3097 Designed for OBS Window Capture on low-power hardware.
@@ -35,9 +102,12 @@ jobs:
35102 - **Linux**: `.deb`, `.rpm`, or `.AppImage`
36103 draft : false
37104 prerelease : false
105+ env :
106+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38107
39108 build-tauri :
40- needs : create-release
109+ needs : release
110+ if : needs.release.outputs.new_version != ''
41111 permissions :
42112 contents : write
43113 strategy :
57127 steps :
58128 - name : Checkout repository
59129 uses : actions/checkout@v4
130+ with :
131+ ref : v${{ needs.release.outputs.new_version }}
60132
61133 - name : Setup Node.js
62134 uses : actions/setup-node@v4
83155 env :
84156 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85157 with :
86- releaseId : ${{ needs.create- release.outputs.release_id }}
87- args : ${{ matrix.args }}
158+ releaseId : ${{ needs.release.outputs.release_id }}
159+ args : ${{ matrix.args }}
0 commit comments