Skip to content

Commit ff4ec6d

Browse files
committed
Add release automation.
Signed-off-by: Rahul Krishna <[email protected]>
1 parent b2327b0 commit ff4ec6d

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeanalyzer-rs.iml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Rust Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
toolchain: stable
23+
24+
- name: Cache dependencies
25+
uses: Swatinem/rust-cache@v2
26+
27+
- name: Build and Test
28+
id: build
29+
continue-on-error: true # Allow the workflow to continue if this fails
30+
run: |
31+
cargo build --release
32+
cargo test --release
33+
34+
- name: Delete tag on failure
35+
if: steps.build.outcome != 'success'
36+
run: |
37+
git push --delete origin ${GITHUB_REF#refs/tags/}
38+
exit 1 # Fail the workflow
39+
40+
- name: Build Changelog
41+
id: gen_changelog
42+
uses: mikepenz/release-changelog-builder-action@v5
43+
with:
44+
failOnError: "true"
45+
configuration: .github/workflows/release_config.json
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Package Release Assets
50+
run: |
51+
cd target/release
52+
# For Linux
53+
tar -czf ../../my-app-linux.tar.gz my-app
54+
# For Windows (if cross-compilation is set up)
55+
# zip ../../my-app-windows.zip my-app.exe
56+
cd ../..
57+
58+
- name: Publish Release
59+
uses: softprops/action-gh-release@v1
60+
with:
61+
files: |
62+
my-app-linux.tar.gz
63+
# my-app-windows.zip
64+
body: ${{ steps.gen_changelog.outputs.changelog }}
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)