11name : Release
22
33on :
4- push :
5- tags :
6- - " v*"
7-
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ type : choice
8+ required : true
9+ description : ' Version number to bump'
10+ options :
11+ - patch
12+ - minor
13+ - major
814
915permissions :
1016 contents : write
@@ -16,23 +22,24 @@ jobs:
1622 name : " Runs cargo publish --dry-run"
1723 runs-on : ubuntu-latest
1824 steps :
19- - uses : actions/checkout@v4
25+ - name : Checkout
26+ uses : actions/checkout@v4
2027
2128 - name : Setup Rust
2229 uses : dtolnay/rust-toolchain@stable
2330 with :
2431 targets : wasm32-unknown-unknown
2532
2633 - name : publish crate
27- run : cargo publish --dry-run
34+ run : cargo publish -p http-server - -dry-run
2835
2936 release :
3037 name : Create Release
3138 needs : publish-dry-run
3239 runs-on : ubuntu-latest
3340 steps :
34- - name : Checkout code
35- uses : actions/checkout@v2
41+ - name : Checkout
42+ uses : actions/checkout@v4
3643
3744 - name : Setup Rust
3845 uses : dtolnay/rust-toolchain@stable
@@ -44,23 +51,41 @@ jobs:
4451
4552 - name : Install Rust Binaries
4653 run : |
54+ cargo binstall -y --force cargo-edit
4755 cargo binstall -y --force leptosfmt
4856 cargo binstall -y --force trunk
4957
58+ - id : cargo-set-version
59+ name : Set Version
60+ run : cargo set-version -p http-server --bump ${{ inputs.version }}
61+
62+ - name : Set Crate Version as Environment Variable
63+ run : |
64+ CARGO_TOML_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' ./src/http-server/Cargo.toml)
65+ echo "CRATE_VERSION=$CARGO_TOML_VERSION" >> $GITHUB_ENV
66+
67+ - name : Create Commit
68+ run : |
69+ git config --global user.name 'github-actions[bot]'
70+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
71+ git add .
72+ git commit -m "chore: bump version to v$CRATE_VERSION"
73+ git push origin main --follow-tags
74+
5075 - name : Login to Crates.io
5176 run : cargo login ${CRATES_IO_TOKEN}
5277 env :
5378 CRATES_IO_TOKEN : ${{ secrets.CRATES_IO_TOKEN }}
5479
5580 - name : Publish crate
56- run : cargo publish
81+ run : cargo publish -p http-server
5782
5883 - name : Create Release
5984 id : create_release
6085 uses : actions/github-script@v5
6186 with :
6287 script : |
6388 await github.request(`POST /repos/${{ github.repository }}/releases`, {
64- tag_name: "${{ github.ref }}",
89+ tag_name: "v ${{ env.CRATE_VERSION }}",
6590 generate_release_notes: true
6691 });
0 commit comments