11name : release
22
3- on :
3+ on :
4+ workflow_dispatch :
45 push :
5- tags :
6- - " v* "
6+ branches :
7+ - main
78
89jobs :
910 release :
@@ -14,11 +15,50 @@ jobs:
1415
1516 - name : Checkout
1617 uses : actions/checkout@v4
18+
19+ - name : Check version
20+ id : version-check
21+ run : |
22+ chmod +x ./scripts/is-newer-version.bash
23+ chmod +x ./scripts/get-version.bash
24+ VERSION=$(./scripts/is-newer-version.bash)
25+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
26+ if [ "$VERSION" != "0" ]; then
27+ echo "New version detected: $VERSION"
28+ else
29+ echo "No new version to release"
30+ fi
31+
32+ - name : Push tag
33+ if : steps.version-check.outputs.version != '0'
34+ run : |
35+ tag="v${{ steps.version-check.outputs.version }}"
36+ git config user.name "${GITHUB_ACTOR}"
37+ git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
38+ git tag -a "${tag}" -m "Release ${tag}"
39+ git push origin "${tag}"
40+
41+ - name : Checkout
42+ uses : actions/checkout@v4
43+
44+ - name : Setup Rust
45+ uses : MatteoH2O1999/setup-rust@v1
46+
47+ - name : Build project
48+ run : cargo build --release
49+ shell : bash
50+ working-directory : ${{ github.action_path }}
51+
52+ - name : Generate minimized HTML
53+ run : cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
54+ shell : bash
55+ working-directory : ${{ github.action_path }}
1756
1857 - name : Create release
58+ if : steps.version-check.outputs.version != '0'
1959 uses : ncipollo/release-action@v1
2060 with :
2161 token : ${{ secrets.TOKEN }}
2262 generateReleaseNotes : true
23- tag : ${{ github.ref_name }}
63+ tag : " v ${{ steps.version-check.outputs.version }}"
2464 artifacts : " index.html,index.min.html"
0 commit comments