Fix GitHub Workflow (#18) #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Release CLI Packages | |
on: | |
push: | |
tags: | |
- "cli-v*" # e.g., cli-v0.1.0 | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Build CLI | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
arch: x86_64 | |
platform: unknown-linux-gnu | |
- os: ubuntu-22.04 | |
target: aarch64-unknown-linux-gnu | |
arch: aarch64 | |
platform: unknown-linux-gnu | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
arch: x86_64 | |
platform: apple-darwin | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
arch: aarch64 | |
platform: apple-darwin | |
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 (Linux aarch64) | |
if: matrix.target == 'aarch64-unknown-linux-gnu' | |
run: | | |
# --- Definitive APT Configuration --- | |
# 1. Clean up any previous configurations and cache to ensure a fresh start | |
sudo rm -f /etc/apt/sources.list.d/* | |
sudo rm -rf /var/lib/apt/lists/* | |
# 2. Add arm64 architecture | |
sudo dpkg --add-architecture arm64 | |
# 3. Force-create a clean main sources.list, EXPLICITLY for amd64 | |
# This is the CRITICAL step to stop apt from looking for arm64 in the wrong place. | |
sudo tee /etc/apt/sources.list > /dev/null <<EOF | |
deb [arch=amd64] http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse | |
deb [arch=amd64] http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse | |
deb [arch=amd64] http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-backports main restricted universe multiverse | |
deb [arch=amd64] http://security.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse | |
EOF | |
# 4. Create a clean sources.list for arm64 from the correct ports repository | |
sudo tee /etc/apt/sources.list.d/arm64.list > /dev/null <<EOF | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs) main restricted universe multiverse | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs)-updates main restricted universe multiverse | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs)-backports main restricted universe multiverse | |
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -cs)-security main restricted universe multiverse | |
EOF | |
# 5. Final update and install | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends \ | |
gcc-aarch64-linux-gnu \ | |
libssl-dev:arm64 \ | |
libc6-dev:arm64 | |
- name: 🛠️ Build CLI Binary | |
working-directory: cli | |
run: | | |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then | |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
export PKG_CONFIG_ALLOW_CROSS=1 | |
export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig | |
fi | |
cargo build --release --target ${{ matrix.target }} | |
- name: 🏷️ Get version from tag | |
id: version | |
run: | | |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
else | |
# For workflow_dispatch, use a default version with commit hash | |
VERSION="cli-v0.0.0-dev-$(git rev-parse --short HEAD)" | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
echo "Version: $VERSION" | |
- name: 📦 Create Package | |
run: | | |
chmod +x ./scripts/package-release.sh | |
./scripts/package-release.sh \ | |
--binary ./target/${{ matrix.target }}/release/humaan \ | |
--version ${{ steps.version.outputs.VERSION }} \ | |
--arch ${{ matrix.arch }} \ | |
--platform ${{ matrix.platform }} \ | |
--output-dir ./dist | |
- name: 📤 Upload Package Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: humaan-${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}-${{ matrix.platform }} | |
path: | | |
dist/*.tar.gz | |
dist/*.sha256 | |
release: | |
name: Create GitHub Release | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: 📥 Download All Packages | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./packages | |
merge-multiple: true | |
- name: 📋 List Downloaded Packages | |
run: | | |
echo "=== Downloaded Packages ===" | |
ls -la ./packages/ | |
echo "==========================" | |
- name: 🏷️ Get version from tag | |
id: version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
echo "Version: $VERSION" | |
- name: 📝 Generate Release Notes | |
run: | | |
cat > release-notes.md << EOF | |
# Humaan CLI ${{ steps.version.outputs.VERSION }} | |
## Installation | |
### Quick Install (Linux & macOS) | |
\`\`\`bash | |
curl -fsSL https://raw.githubusercontent.com/humaan-ai/humaan/main/tools/install.sh | bash | |
\`\`\` | |
### Manual Installation | |
1. Download the appropriate package for your platform below | |
2. Extract the archive: \`tar -xzf humaan-*.tar.gz\` | |
3. Run the installer: \`cd humaan-* && ./install.sh\` | |
## Platform Support | |
- **Linux x86_64**: \`humaan-${{ steps.version.outputs.VERSION }}-x86_64-unknown-linux-gnu.tar.gz\` | |
- **Linux aarch64**: \`humaan-${{ steps.version.outputs.VERSION }}-aarch64-unknown-linux-gnu.tar.gz\` | |
- **macOS x86_64**: \`humaan-${{ steps.version.outputs.VERSION }}-x86_64-apple-darwin.tar.gz\` | |
- **macOS Apple Silicon**: \`humaan-${{ steps.version.outputs.VERSION }}-aarch64-apple-darwin.tar.gz\` | |
## Verification | |
Each package includes a SHA256 checksum file. Verify your download: | |
\`\`\`bash | |
sha256sum -c humaan-*.tar.gz.sha256 | |
\`\`\` | |
## What's New | |
<!-- Add release notes here --> | |
EOF | |
- name: 🚀 Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
packages/*.tar.gz | |
packages/*.sha256 | |
body_path: release-notes.md | |
draft: false | |
prerelease: ${{ contains(steps.version.outputs.VERSION, 'alpha') || contains(steps.version.outputs.VERSION, 'beta') || contains(steps.version.outputs.VERSION, 'rc') }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |