name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v0.1.0)'
required: false
type: string
env:
PACKAGE_NAME: ccgo
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTUP_MAX_RETRIES: 10
permissions:
contents: write
id-token: write
jobs:
sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
linux:
name: Build Linux ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-24.04-arm
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --locked --out dist
manylinux: '2_17'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: dist
- name: Archive binary
run: |
ARCH=${{ matrix.target }}
if [ "$ARCH" = "x86_64" ]; then
TARGET=x86_64-unknown-linux-gnu
else
TARGET=aarch64-unknown-linux-gnu
fi
ARCHIVE_NAME=${{ env.PACKAGE_NAME }}-$TARGET
ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz
mkdir -p $ARCHIVE_NAME
cp target/$TARGET/release/${{ env.PACKAGE_NAME }} $ARCHIVE_NAME/
tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binaries-linux-${{ matrix.target }}
path: |
*.tar.gz
*.sha256
windows:
name: Build Windows ${{ matrix.target }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64
rust_target: x86_64-pc-windows-msvc
- target: aarch64
rust_target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --locked --out dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.target }}
path: dist
- name: Archive binary
shell: bash
run: |
TARGET=${{ matrix.rust_target }}
ARCHIVE_NAME=${{ env.PACKAGE_NAME }}-$TARGET
ARCHIVE_FILE=$ARCHIVE_NAME.zip
mkdir -p $ARCHIVE_NAME
cp target/$TARGET/release/${{ env.PACKAGE_NAME }}.exe $ARCHIVE_NAME/
7z a $ARCHIVE_FILE $ARCHIVE_NAME
sha256sum $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binaries-windows-${{ matrix.target }}
path: |
*.zip
*.sha256
macos:
name: Build macOS ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: macos-15-intel
target: x86_64
- runner: macos-15
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --locked --out dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: dist
- name: Archive binary
run: |
ARCH=${{ matrix.target }}
if [ "$ARCH" = "x86_64" ]; then
TARGET=x86_64-apple-darwin
else
TARGET=aarch64-apple-darwin
fi
ARCHIVE_NAME=${{ env.PACKAGE_NAME }}-$TARGET
ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz
mkdir -p $ARCHIVE_NAME
cp target/$TARGET/release/${{ env.PACKAGE_NAME }} $ARCHIVE_NAME/
tar czvf $ARCHIVE_FILE $ARCHIVE_NAME
shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binaries-macos-${{ matrix.target }}
path: |
*.tar.gz
*.sha256
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [sdist, linux, windows, macos]
steps:
- uses: actions/checkout@v4
- name: Download all binaries
uses: actions/download-artifact@v4
with:
pattern: binaries-*
path: binaries
merge-multiple: true
- name: Extract version
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: binaries/*
body: |
## Installation
**Python Package (PyPI):**
```bash
pip install ccgo==${{ steps.version.outputs.VERSION }}
# or
pip install --upgrade ccgo
```
**Homebrew (macOS/Linux):**
```bash
brew tap zhlinh/ccgo
brew install ccgo
```
**Rust Binary (crates.io):**
```bash
cargo install ccgo
```
**Pre-built Binaries:**
Download platform-specific binaries from the assets below.
## Quick Start
```bash
# Create a new C++ cross-platform project
ccgo new my-project
# Build for different platforms
cd my-project/<project_name>
ccgo build android
ccgo build ios
ccgo build macos
ccgo build linux
ccgo build windows
# Cross-platform builds using Docker
ccgo build linux --docker
ccgo build windows --docker
ccgo build macos --docker
ccgo build ios --docker
```
See [CHANGELOG.md](CHANGELOG.md) for details.
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [sdist, linux, windows, macos]
environment:
name: release
permissions:
id-token: write
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-crates:
name: Publish to crates.io
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [sdist, linux, windows, macos]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify build
run: cargo build --release --locked
- name: Run tests
run: cargo test --locked
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked
publish-homebrew:
name: Update Homebrew tap
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc')
needs: [github-release]
steps:
- name: Download binary artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
path: binaries
merge-multiple: true
- name: Extract SHA256 checksums
id: sha
run: |
extract_sha() {
local file="binaries/$1.sha256"
if [ ! -f "$file" ]; then
echo "Error: missing checksum file $file" >&2
exit 1
fi
awk '{print $1}' "$file"
}
{
echo "darwin_arm64=$(extract_sha ccgo-aarch64-apple-darwin.tar.gz)"
echo "darwin_x86_64=$(extract_sha ccgo-x86_64-apple-darwin.tar.gz)"
echo "linux_arm64=$(extract_sha ccgo-aarch64-unknown-linux-gnu.tar.gz)"
echo "linux_x86_64=$(extract_sha ccgo-x86_64-unknown-linux-gnu.tar.gz)"
} >> "$GITHUB_OUTPUT"
- name: Clone Homebrew tap
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/zhlinh/homebrew-ccgo.git" tap
- name: Initialize Formula if not exists
run: |
mkdir -p tap/Formula
if [ ! -f "tap/Formula/ccgo.rb" ]; then
echo "Formula not found, creating a new one..."
cat << 'EOF' > tap/Formula/ccgo.rb
class Ccgo < Formula
desc "A high-performance C++ cross-platform build CLI"
homepage "https://github.com/zhlinh/ccgo"
version "0.0.0"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/zhlinh/ccgo/releases/download/v#{version}/ccgo-aarch64-apple-darwin.tar.gz"
sha256 "0000000000000000000000000000000000000000000000000000000000000000" # darwin-arm64
end
if Hardware::CPU.intel?
url "https://github.com/zhlinh/ccgo/releases/download/v#{version}/ccgo-x86_64-apple-darwin.tar.gz"
sha256 "0000000000000000000000000000000000000000000000000000000000000000" # darwin-x86_64
end
end
on_linux do
if Hardware::CPU.arm?
url "https://github.com/zhlinh/ccgo/releases/download/v#{version}/ccgo-aarch64-unknown-linux-gnu.tar.gz"
sha256 "0000000000000000000000000000000000000000000000000000000000000000" # linux-arm64
end
if Hardware::CPU.intel?
url "https://github.com/zhlinh/ccgo/releases/download/v#{version}/ccgo-x86_64-unknown-linux-gnu.tar.gz"
sha256 "0000000000000000000000000000000000000000000000000000000000000000" # linux-x86_64
end
end
def install
bin.install "ccgo"
end
end
EOF
else
echo "Formula already exists, skipping initialization."
fi
- name: Update Formula
env:
VERSION: ${{ github.ref_name }}
SHA_DARWIN_ARM64: ${{ steps.sha.outputs.darwin_arm64 }}
SHA_DARWIN_X86_64: ${{ steps.sha.outputs.darwin_x86_64 }}
SHA_LINUX_ARM64: ${{ steps.sha.outputs.linux_arm64 }}
SHA_LINUX_X86_64: ${{ steps.sha.outputs.linux_x86_64 }}
run: |
VERSION_NO_V=${VERSION#v}
FORMULA=tap/Formula/ccgo.rb
# Bump version
sed -i -E "s/^ version \"[^\"]+\"/ version \"${VERSION_NO_V}\"/" "$FORMULA"
# Patch each sha256 by its marker comment
sed -i -E "s|sha256 \"[0-9a-f]+\" # darwin-arm64|sha256 \"${SHA_DARWIN_ARM64}\" # darwin-arm64|" "$FORMULA"
sed -i -E "s|sha256 \"[0-9a-f]+\" # darwin-x86_64|sha256 \"${SHA_DARWIN_X86_64}\" # darwin-x86_64|" "$FORMULA"
sed -i -E "s|sha256 \"[0-9a-f]+\" # linux-arm64|sha256 \"${SHA_LINUX_ARM64}\" # linux-arm64|" "$FORMULA"
sed -i -E "s|sha256 \"[0-9a-f]+\" # linux-x86_64|sha256 \"${SHA_LINUX_X86_64}\" # linux-x86_64|" "$FORMULA"
echo "--- Updated Formula ---"
cat "$FORMULA"
- name: Commit and push
working-directory: tap
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git ls-files --error-unmatch Formula/ccgo.rb > /dev/null 2>&1 && git diff --quiet Formula/ccgo.rb; then
echo "No changes to Formula — skipping commit"
exit 0
fi
git add Formula/ccgo.rb
git commit -m "Update ccgo to ${GITHUB_REF_NAME#v}"
git push