feat: release workflow

This commit is contained in:
bahdotsh
2025-04-21 17:13:33 +05:30
parent 2a85734ead
commit 622a9081ea
3 changed files with 220 additions and 0 deletions

59
.github/RELEASE.md vendored Normal file
View File

@@ -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

101
.github/workflows/release.yml vendored Normal file
View File

@@ -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 }}

60
cliff.toml Normal file
View File

@@ -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 = """
<!-- generated by git-cliff -->
"""
# 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"