Skip to content

Commit 4b69927

Browse files
authored
feat: release via gh action (#482)
1 parent 675ff3b commit 4b69927

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: Release
22

33
on:
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

915
permissions:
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
});

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/http-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "http-server"
3-
version = "1.0.0-draft+1"
3+
version = "0.8.9"
44
authors = ["Esteban Borai <[email protected]>"]
55
edition = "2021"
66
description = "Simple and configurable command-line HTTP server"

0 commit comments

Comments
 (0)