name: Release
on:
push:
tags:
- "*.*.*"
permissions:
contents: write
env:
BINARY_NAME: ik-mini-epub-cli
jobs:
build-mac:
runs-on: macos-26
steps:
- uses: actions/checkout@v6
- name: Add Intel target
run: rustup target add x86_64-apple-darwin
- name: Build for Apple Silicon (ARM64)
run: cargo build --release --target aarch64-apple-darwin
- name: Build for Intel (x86_64)
run: cargo build --release --target x86_64-apple-darwin
- name: Package binaries
run: |
# Get version from the tag, e.g., "1.0.0" from "refs/tags/1.0.0"
VERSION=${GITHUB_REF_NAME}
# Create archives for each target
tar -czvf ${{ env.BINARY_NAME }}-v${VERSION}-aarch64-apple-darwin.tar.gz -C target/aarch64-apple-darwin/release ${{ env.BINARY_NAME }}
tar -czvf ${{ env.BINARY_NAME }}-v${VERSION}-x86_64-apple-darwin.tar.gz -C target/x86_64-apple-darwin/release ${{ env.BINARY_NAME }}
- name: Upload macOS artifacts
uses: actions/upload-artifact@v5
with:
name: macos-binaries
path: |
${{ env.BINARY_NAME }}-v*-aarch64-apple-darwin.tar.gz
${{ env.BINARY_NAME }}-v*-x86_64-apple-darwin.tar.gz
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Add targets
run: |
rustup target add i686-pc-windows-msvc
rustup target add aarch64-pc-windows-msvc
- name: Build for all targets
run: |
cargo build --release --target x86_64-pc-windows-msvc
cargo build --release --target i686-pc-windows-msvc
cargo build --release --target aarch64-pc-windows-msvc
- name: Package binaries
shell: pwsh
run: |
# Get version from the tag
$VERSION = $env:GITHUB_REF_NAME
# Create archives for each target
Compress-Archive -Path "target\x86_64-pc-windows-msvc\release\${{ env.BINARY_NAME }}.exe" -DestinationPath "${{ env.BINARY_NAME }}-v${VERSION}-x86_64-pc-windows-msvc.zip"
Compress-Archive -Path "target\i686-pc-windows-msvc\release\${{ env.BINARY_NAME }}.exe" -DestinationPath "${{ env.BINARY_NAME }}-v${VERSION}-i686-pc-windows-msvc.zip"
Compress-Archive -Path "target\aarch64-pc-windows-msvc\release\${{ env.BINARY_NAME }}.exe" -DestinationPath "${{ env.BINARY_NAME }}-v${VERSION}-aarch64-pc-windows-msvc.zip"
- name: Upload Windows artifacts
uses: actions/upload-artifact@v5
with:
name: windows-binaries
path: |
${{ env.BINARY_NAME }}-v*-x86_64-pc-windows-msvc.zip
${{ env.BINARY_NAME }}-v*-i686-pc-windows-msvc.zip
${{ env.BINARY_NAME }}-v*-aarch64-pc-windows-msvc.zip
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Add targets
run: |
rustup target add i686-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
- name: Build for 64-bit Linux (x86_64)
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Package binaries
run: |
# Get version from the tag
VERSION=${GITHUB_REF_NAME}
# Create archives for each target
tar -czvf ${{ env.BINARY_NAME }}-v${VERSION}-x86_64-unknown-linux-gnu.tar.gz -C target/x86_64-unknown-linux-gnu/release ${{ env.BINARY_NAME }}
# tar -czvf ${{ env.BINARY_NAME }}-v${VERSION}-i686-unknown-linux-gnu.tar.gz -C target/i686-unknown-linux-gnu/release ${{ env.BINARY_NAME }}
# tar -czvf ${{ env.BINARY_NAME }}-v${VERSION}-aarch64-unknown-linux-gnu.tar.gz -C target/aarch64-unknown-linux-gnu/release ${{ env.BINARY_NAME }}
- name: Upload Linux artifacts
uses: actions/upload-artifact@v5
with:
name: linux-binaries
path: |
${{ env.BINARY_NAME }}-v*-x86_64-unknown-linux-gnu.tar.gz
# ${{ env.BINARY_NAME }}-v*-i686-unknown-linux-gnu.tar.gz
# ${{ env.BINARY_NAME }}-v*-aarch64-unknown-linux-gnu.tar.gz
create-release:
runs-on: ubuntu-latest
needs: [build-mac, build-windows, build-linux]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v6
with:
path: release-assets
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release-assets/**/*