Skip to content

feat: Production-grade multi-platform distribution and authentication #1

feat: Production-grade multi-platform distribution and authentication

feat: Production-grade multi-platform distribution and authentication #1

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: ".github/changelog-config.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
## What's Changed
${{ steps.changelog.outputs.changelog }}
## Installation
### macOS/Linux
```bash
curl -fsSL https://get.kanuni.dev | sh
```
### Homebrew
```bash
brew install v-lawyer/tap/kanuni
```
### npm
```bash
npm install -g kanuni-cli
```
### Cargo
```bash
cargo install kanuni
```
See full installation instructions in the [documentation](https://docs.v-lawyer.ai/docs/cli/installation).
draft: false
prerelease: false
build-release:
name: Build Release
needs: create-release
strategy:
matrix:
include:
# macOS builds
- target: x86_64-apple-darwin
os: macos-latest
name: kanuni-darwin-x64
- target: aarch64-apple-darwin
os: macos-latest
name: kanuni-darwin-arm64
# Linux builds
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: kanuni-linux-x64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: kanuni-linux-arm64
# Windows builds
- target: x86_64-pc-windows-msvc
os: windows-latest
name: kanuni-windows-x64.exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build release binary
run: |
cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Prepare binary
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp target/${{ matrix.target }}/release/kanuni.exe ${{ matrix.name }}
else
cp target/${{ matrix.target }}/release/kanuni ${{ matrix.name }}
fi
# Create tarball for non-Windows
if [[ "${{ matrix.os }}" != "windows-latest" ]]; then
tar czf ${{ matrix.name }}.tar.gz ${{ matrix.name }}
else
# Create zip for Windows
7z a ${{ matrix.name }}.zip ${{ matrix.name }}
fi
- name: Generate SHA256
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
certutil -hashfile ${{ matrix.name }}.zip SHA256 > ${{ matrix.name }}.zip.sha256
else
shasum -a 256 ${{ matrix.name }}.tar.gz > ${{ matrix.name }}.tar.gz.sha256
fi
- name: Upload Release Asset (Archive)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.os == 'windows-latest' && format('{0}.zip', matrix.name) || format('{0}.tar.gz', matrix.name) }}
asset_name: ${{ matrix.os == 'windows-latest' && format('{0}.zip', matrix.name) || format('{0}.tar.gz', matrix.name) }}
asset_content_type: ${{ matrix.os == 'windows-latest' && 'application/zip' || 'application/gzip' }}
- name: Upload Release Asset (Checksum)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.os == 'windows-latest' && format('{0}.zip.sha256', matrix.name) || format('{0}.tar.gz.sha256', matrix.name) }}
asset_name: ${{ matrix.os == 'windows-latest' && format('{0}.zip.sha256', matrix.name) || format('{0}.tar.gz.sha256', matrix.name) }}
asset_content_type: text/plain
publish-crate:
name: Publish to crates.io
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}
continue-on-error: true # Don't fail the whole release if crates.io publish fails
publish-npm:
name: Publish to npm
needs: [create-release, build-release]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Update package version
working-directory: ./kanuni-npm
run: |
npm version ${{ needs.create-release.outputs.version }} --no-git-tag-version
- name: Publish to npm
working-directory: ./kanuni-npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
continue-on-error: true # Don't fail if npm publish fails
update-homebrew:
name: Update Homebrew Formula
needs: [create-release, build-release]
runs-on: ubuntu-latest
steps:
- name: Checkout tap repository
uses: actions/checkout@v4
with:
repository: v-lawyer/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update Formula
run: |
# This would update the formula with new URLs and SHA256
echo "Updating Homebrew formula for version ${{ needs.create-release.outputs.version }}"
# Script to update formula would go here
continue-on-error: true