File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed
Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Build
2+
3+ on :
4+ push :
5+ tags :
6+
7+ jobs :
8+ build_and_package :
9+ runs-on : ubuntu-latest
10+ container : rust:1.87
11+ permissions :
12+ contents : write
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : Cache Cargo directories
18+ uses : actions/cache@v4
19+ with :
20+ path : |
21+ ~/.cargo/bin/
22+ ~/.cargo/registry/index/
23+ ~/.cargo/registry/cache/
24+ target/ # Cache build target directory
25+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} # Cache key
26+ restore-keys : |
27+ ${{ runner.os }}-cargo-
28+
29+ - name : Build Rust binary
30+ run : cargo build --release --target x86_64-unknown-linux-gnu
31+
32+ - name : Release
33+ uses : softprops/action-gh-release@v2
34+ if : github.ref_type == 'tag'
35+ with :
36+ files : |
37+ target/release/hars-imp
38+
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ VERSION=$( grep -m 1 " ^version" Cargo.toml | sed -E ' s/version\s*=\s*"([^"]*)"/\1/' )
6+
7+ if [ -z " $VERSION " ]; then
8+ echo " Error: Could not determine version from Cargo.toml"
9+ exit 1
10+ fi
11+
12+ echo " Found version: $VERSION "
13+
14+ CURRENT_BRANCH=$( git branch --show-current)
15+ if [ " $CURRENT_BRANCH " != " main" ]; then
16+ echo " Not on main branch. Current branch: $CURRENT_BRANCH "
17+ exit 0
18+ fi
19+
20+ echo " Currently on main branch. Proceeding..."
21+
22+ # Check if tag already exists remotely
23+ if git ls-remote --tags origin | grep -q " refs/tags/$VERSION \$ " ; then
24+ echo " Tag $VERSION already exists in the remote repository."
25+ exit 0
26+ fi
27+
28+ echo " Tag $VERSION doesn't exist in the remote repository. Creating and pushing..."
29+
30+ git tag " $VERSION "
31+ git push origin " $VERSION "
32+
33+ echo " Tag $VERSION created and pushed successfully!"
You can’t perform that action at this time.
0 commit comments