Skip to content

Commit

Permalink
feat: Add build and release workflow
Browse files Browse the repository at this point in the history
This commit introduces a new GitHub Actions workflow for building and releasing the `aicommit` binary for multiple platforms and architectures.

The workflow is triggered on push events to tags matching the `v*` pattern
  • Loading branch information
suenot committed Jan 23, 2025
1 parent dcd1ead commit 9b39a2c
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Build and Release

on:
push:
tags:
- 'v*'

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux x86_64
- os: ubuntu-latest
artifact_name: aicommit
asset_name: aicommit-linux-x86_64
target: x86_64-unknown-linux-gnu
# Linux ARM64
- os: ubuntu-latest
artifact_name: aicommit
asset_name: aicommit-linux-aarch64
target: aarch64-unknown-linux-gnu
# Linux RISC-V 64
- os: ubuntu-latest
artifact_name: aicommit
asset_name: aicommit-linux-riscv64
target: riscv64gc-unknown-linux-gnu
# macOS Intel
- os: macos-latest
artifact_name: aicommit
asset_name: aicommit-macos-x86_64
target: x86_64-apple-darwin
# macOS Apple Silicon
- os: macos-latest
artifact_name: aicommit
asset_name: aicommit-macos-aarch64
target: aarch64-apple-darwin
# Windows x86_64
- os: windows-latest
artifact_name: aicommit.exe
asset_name: aicommit-windows-x86_64
target: x86_64-pc-windows-msvc
# Windows ARM64
- os: windows-latest
artifact_name: aicommit.exe
asset_name: aicommit-windows-aarch64
target: aarch64-pc-windows-msvc

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross-compilation tools
if: matrix.os == 'ubuntu-latest' && (contains(matrix.target, 'aarch64') || contains(matrix.target, 'riscv64'))
run: |
sudo apt-get update
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
sudo apt-get install -y gcc-aarch64-linux-gnu
elif [[ "${{ matrix.target }}" == "riscv64gc-unknown-linux-gnu" ]]; then
sudo apt-get install -y gcc-riscv64-linux-gnu
fi
- name: Build
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER: riscv64-linux-gnu-gcc

- name: Prepare asset
shell: bash
run: |
cd target/${{ matrix.target }}/release
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a ../../../${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
else
tar -czf ../../../${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
fi
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ matrix.asset_name }}.*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 9b39a2c

Please sign in to comment.