Skip to content

Commit 81b7143

Browse files
author
hitchclimber
committed
add release to CICD
1 parent 6a6d0e9 commit 81b7143

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

.github/workflows/rust.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ env:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
16-
1715
steps:
1816
- uses: actions/checkout@v4
1917
- name: Install cargo-audit
@@ -24,3 +22,40 @@ jobs:
2422
run: cargo build --verbose
2523
- name: Run tests
2624
run: cargo test --verbose
25+
26+
release:
27+
needs: build
28+
runs-on: ubuntu-latest
29+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
30+
permissions:
31+
contents: write
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Get version from Cargo.toml
36+
id: version
37+
run: |
38+
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
39+
echo "version=$VERSION" >> $GITHUB_OUTPUT
40+
41+
- name: Check if tag exists
42+
id: tag_check
43+
run: |
44+
if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.version.outputs.version }}$"; then
45+
echo "exists=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "exists=false" >> $GITHUB_OUTPUT
48+
fi
49+
50+
- name: Build release binary
51+
if: steps.tag_check.outputs.exists == 'false'
52+
run: cargo build --release
53+
54+
- name: Create Release
55+
if: steps.tag_check.outputs.exists == 'false'
56+
uses: softprops/action-gh-release@v2
57+
with:
58+
tag_name: v${{ steps.version.outputs.version }}
59+
name: v${{ steps.version.outputs.version }}
60+
generate_release_notes: true
61+
files: target/release/adaptable_rest

0 commit comments

Comments
 (0)