Skip to content

fmt

fmt #142

name: Release hypecli Binary
on:
push:
tags:
- "hypecli-v*"
branches:
- main
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g., hypecli-v1.0.0)"
required: true
type: string
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release_id: ${{ steps.create_release.outputs.id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
tag: ${{ steps.extract_version.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Extract version
id: extract_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
VERSION=${TAG#hypecli-v}
elif [ "${{ github.ref_type }}" = "tag" ]; then
TAG="${{ github.ref_name }}"
VERSION=${TAG#hypecli-v}
else
# Push to main branch
TAG="hypecli-main-latest"
VERSION="main-${{ github.sha }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "is_main_build=${{ github.ref_type != 'tag' && github.event_name != 'workflow_dispatch' }}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_version.outputs.tag }}
name: hypecli ${{ steps.extract_version.outputs.version }}
draft: false
prerelease: ${{ steps.extract_version.outputs.is_main_build == 'true' }}
make_latest: ${{ steps.extract_version.outputs.is_main_build != 'true' }}
build:
needs: create-release
permissions:
contents: write
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: hypecli-linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: hypecli-linux-aarch64
- target: x86_64-apple-darwin
os: macos-latest
name: hypecli-macos-x86_64
- target: aarch64-apple-darwin
os: macos-latest
name: hypecli-macos-aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: hypecli-windows-x86_64.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools pkg-config
- name: Configure cross-compilation (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- name: Build binary
run: |
cd hypecli
cargo build --release --target ${{ matrix.target }}
- name: Package binary (Unix)
if: matrix.os != 'windows-latest'
run: |
cd hypecli/target/${{ matrix.target }}/release
tar czf ${{ matrix.name }}.tar.gz hypecli
mv ${{ matrix.name }}.tar.gz ../../../..
- name: Package binary (Windows)
if: matrix.os == 'windows-latest'
run: |
cd hypecli/target/${{ matrix.target }}/release
7z a ${{ matrix.name }}.zip hypecli.exe
move ${{ matrix.name }}.zip ../../../..
- name: Upload Release Asset (Unix)
if: matrix.os != 'windows-latest'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-release.outputs.tag }}
files: ./${{ matrix.name }}.tar.gz
- name: Upload Release Asset (Windows)
if: matrix.os == 'windows-latest'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-release.outputs.tag }}
files: ./${{ matrix.name }}.zip