From d80792709780d6b9ff7086015e7ea8f6f935254c Mon Sep 17 00:00:00 2001 From: Rahul Krishna Date: Thu, 13 Feb 2025 15:33:42 -0500 Subject: [PATCH] Add release automation. Signed-off-by: Rahul Krishna --- .github/workflows/release.yml | 66 +++++++++++++++++++++++++++ .github/workflows/release_config.json | 35 ++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/release_config.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f30a343 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Rust Release + +on: + push: + tags: + - "v*.*.*" + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Build and Test + id: build + continue-on-error: true # Allow the workflow to continue if this fails + run: | + cargo build --release + cargo test --release + + - name: Delete tag on failure + if: steps.build.outcome != 'success' + run: | + git push --delete origin ${GITHUB_REF#refs/tags/} + exit 1 # Fail the workflow + + - name: Build Changelog + id: gen_changelog + uses: mikepenz/release-changelog-builder-action@v5 + with: + failOnError: "true" + configuration: .github/workflows/release_config.json + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Package Release Assets + run: | + cd target/release + # For Linux + tar -czf ../../my-app-linux.tar.gz my-app + # For Windows (if cross-compilation is set up) + # zip ../../my-app-windows.zip my-app.exe + cd ../.. + + - name: Publish Release + uses: softprops/action-gh-release@v1 + with: + files: | + my-app-linux.tar.gz + # my-app-windows.zip + body: ${{ steps.gen_changelog.outputs.changelog }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release_config.json b/.github/workflows/release_config.json new file mode 100644 index 0000000..7ddd165 --- /dev/null +++ b/.github/workflows/release_config.json @@ -0,0 +1,35 @@ +{ + "categories": [ + { + "title": "## 🚀 Features", + "labels": ["kind/feature", "enhancement"] + }, + { + "title": "## 🐛 Fixes", + "labels": ["fix", "bug"] + }, + { + "title": "## ♻️ Refactoring", + "labels": ["refactoring"] + }, + { + "title": "## ⚡️ Performance Improvements", + "labels": ["performance"] + }, + { + "title": "## \uD83D\uDCDA Documentation", + "labels": ["documentation", "doc"] + }, + { + "title": "## \uD83D\uDEA6 Tests", + "labels": ["test"] + }, + { + "title": "## \uD83D\uDEE0 Other Updates", + "labels": ["other", "kind/dependency-change"] + } + ], + "ignore_labels": [ + "ignore" + ] +} \ No newline at end of file