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,52 @@ jobs:
1415
1516 - name : Checkout
1617 uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0
20+
21+ - name : Check version
22+ id : version-check
23+ run : |
24+ chmod +x ./scripts/is-newer-version.bash
25+ chmod +x ./scripts/get-version.bash
26+ VERSION=$(./scripts/is-newer-version.bash)
27+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
28+ if [ "$VERSION" != "0" ]; then
29+ echo "New version detected: $VERSION"
30+ else
31+ echo "No new version to release"
32+ fi
33+
34+ - name : Push tag
35+ if : steps.version-check.outputs.version != '0'
36+ run : |
37+ tag="v${{ steps.version-check.outputs.version }}"
38+ git config user.name "${GITHUB_ACTOR}"
39+ git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
40+ git tag -a "${tag}" -m "Release ${tag}"
41+ git push origin "${tag}"
42+
43+ - name : Checkout
44+ uses : actions/checkout@v4
45+
46+ - name : Setup Rust
47+ uses : MatteoH2O1999/setup-rust@v1
48+
49+ - name : Build project
50+ run : cargo build --release
51+ shell : bash
52+ working-directory : ${{ github.action_path }}
53+
54+ - name : Generate minimized HTML
55+ run : cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
56+ shell : bash
57+ working-directory : ${{ github.action_path }}
1758
1859 - name : Create release
60+ if : steps.version-check.outputs.version != '0'
1961 uses : ncipollo/release-action@v1
2062 with :
2163 token : ${{ secrets.TOKEN }}
2264 generateReleaseNotes : true
23- tag : ${{ github.ref_name }}
65+ tag : " v ${{ steps.version-check.outputs.version }}"
2466 artifacts : " index.html,index.min.html"
0 commit comments