From 622a9081ea4555cb3e1bd7230e522f5541e26cbd Mon Sep 17 00:00:00 2001 From: bahdotsh Date: Mon, 21 Apr 2025 17:13:33 +0530 Subject: [PATCH] feat: release workflow --- .github/RELEASE.md | 59 ++++++++++++++++++++ .github/workflows/release.yml | 101 ++++++++++++++++++++++++++++++++++ cliff.toml | 60 ++++++++++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 .github/RELEASE.md create mode 100644 .github/workflows/release.yml create mode 100644 cliff.toml diff --git a/.github/RELEASE.md b/.github/RELEASE.md new file mode 100644 index 0000000..d3ac0e7 --- /dev/null +++ b/.github/RELEASE.md @@ -0,0 +1,59 @@ +# Release Process + +This document outlines the steps for creating a new release of wrkflw. + +## Automatic Release Process + +The project uses a GitHub Actions workflow to automate the release process. Here's how it works: + +1. Tag a new version with Git: + ```bash + git tag -a v0.x.y -m "Release v0.x.y" + ``` + +2. Push the tag to GitHub: + ```bash + git push origin v0.x.y + ``` + +3. The GitHub Actions workflow will automatically: + - Build release binaries for multiple platforms (Linux, macOS, Windows) + - Generate a changelog using git-cliff + - Create a GitHub release with the changelog and binaries + - Upload the release artifacts + +## Commit Message Format + +To ensure proper changelog generation, please follow the conventional commit format for your commit messages: + +- `feat: add new feature` - for new features +- `fix: resolve issue` - for bug fixes +- `docs: update documentation` - for documentation updates +- `style: format code` - for code style changes (no functional changes) +- `refactor: improve code structure` - for code refactoring +- `perf: improve performance` - for performance improvements +- `test: add or update tests` - for test updates +- `chore: update dependencies` - for maintenance tasks + +The changelog will be organized based on these commit types. + +## Manual Release Steps (if needed) + +If you need to create a release manually: + +1. Build the release binaries: + ```bash + cargo build --release + ``` + +2. Generate a changelog: + ```bash + git cliff --latest > CHANGELOG.md + ``` + +3. Create a new release on GitHub manually and upload the binaries. + +## Configuration + +- `cliff.toml` - Configuration for git-cliff to generate changelogs +- `.github/workflows/release.yml` - GitHub Actions workflow for releases \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a0bc31e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,101 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + create-release: + name: Create Release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install git-cliff + uses: kenji-miyake/setup-git-cliff@v1 + + - name: Generate Changelog + run: git cliff --latest --output CHANGELOG.md + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + name: "wrkflw ${{ github.ref_name }}" + body_path: CHANGELOG.md + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-release: + name: Build Release + needs: create-release + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + artifact_name: wrkflw + asset_name: wrkflw-${{ github.ref_name }}-linux-x86_64 + - os: macos-latest + target: x86_64-apple-darwin + artifact_name: wrkflw + asset_name: wrkflw-${{ github.ref_name }}-macos-x86_64 + - os: macos-latest + target: aarch64-apple-darwin + artifact_name: wrkflw + asset_name: wrkflw-${{ github.ref_name }}-macos-arm64 + - os: windows-latest + target: x86_64-pc-windows-msvc + artifact_name: wrkflw.exe + asset_name: wrkflw-${{ github.ref_name }}-windows-x86_64 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: ${{ matrix.target }} + override: true + + - name: Build Release Binary + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --target ${{ matrix.target }} + + - name: Compress Release Binary (Unix) + if: runner.os != 'Windows' + run: | + cd target/${{ matrix.target }}/release + tar czvf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }} + echo "ASSET=${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV + echo "ASSET_PATH=target/${{ matrix.target }}/release/${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV + + - name: Compress Release Binary (Windows) + if: runner.os == 'Windows' + run: | + cd target/${{ matrix.target }}/release + 7z a ${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }} + echo "ASSET=${{ matrix.asset_name }}.zip" >> $env:GITHUB_ENV + echo "ASSET_PATH=target/${{ matrix.target }}/release/${{ matrix.asset_name }}.zip" >> $env:GITHUB_ENV + shell: pwsh + + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.ASSET_PATH }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..76c8d34 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,60 @@ +[changelog] +# The header of the changelog +header = """ +# Changelog + +All notable changes to wrkflw will be documented in this file. +""" + +# Template for the changelog body +body = """ +{% if version %} +## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %} +## [unreleased] +{% endif %} + +{% for group, commits in commits | group_by(attribute="group") %} +### {{ group | upper_first }} +{% for commit in commits %} +- {% if commit.breaking %}**BREAKING:** {% endif %}{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id | github_link }})){% if commit.links %} ({% for link in commit.links %}[{{ link.text }}]({{ link.href }}){% if not loop.last %}, {% endif %}{% endfor %}){% endif %} +{% endfor %} +{% endfor %} +""" + +# Remove the leading and trailing whitespace from the template +trim = true + +# The footer of the changelog +footer = """ + +""" + +# This determines how the links to commits are formatted +[git] +conventional_commits = true +filter_unconventional = true +commit_parsers = [ + { message = "^feat", group = "Features" }, + { message = "^fix", group = "Bug Fixes" }, + { message = "^docs", group = "Documentation" }, + { message = "^style", group = "Styling" }, + { message = "^refactor", group = "Refactor" }, + { message = "^perf", group = "Performance" }, + { message = "^test", group = "Testing" }, + { message = "^chore\\(deps\\)", skip = true }, + { message = "^chore\\(release\\)", skip = true }, + { message = "^chore", group = "Miscellaneous Tasks" }, + { body = ".*security", group = "Security" }, +] + +# Format of the git commit link +link_parsers = [ + { pattern = "#(\\d+)", href = "https://github.com/bahdotsh/wrkflw/issues/$1" }, +] + +filter_commits = true +tag_pattern = "v[0-9]*" +ignore_tags = "" +date_format = "%Y-%m-%d" +sort_commits = "oldest" \ No newline at end of file