ci: add release step
This commit is contained in:
1 parent
926bcbf978
commit
ee5d8371d0
2 files changed
+62
-7
No files matched your search
@@ -5,26 +5,76 @@ on:
|
|||||||
env:
|
env:
|
||||||
MACOS_SDK: "14.5"
|
MACOS_SDK: "14.5"
|
||||||
jobs:
|
jobs:
|
||||||
|
# next version = highest vX.Y.Z tag with the patch bumped; push a tag by hand for minor/major
|
||||||
|
version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.next.outputs.version }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- id: next
|
||||||
|
run: |
|
||||||
|
last=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n1)
|
||||||
|
if [ -z "$last" ]; then
|
||||||
|
next=0.1.0
|
||||||
|
else
|
||||||
|
last=${last#v}
|
||||||
|
next="${last%.*}.$(( ${last##*.} + 1 ))"
|
||||||
|
fi
|
||||||
|
echo "version=$next" >> "$GITHUB_OUTPUT"
|
||||||
build:
|
build:
|
||||||
|
needs: version
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
target: [x86_64-unknown-linux-gnu, aarch64-apple-darwin]
|
target: [x86_64-unknown-linux-musl, aarch64-apple-darwin]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.target }}
|
targets: ${{ matrix.target }}
|
||||||
- if: matrix.target == 'x86_64-unknown-linux-gnu'
|
# zig as cross C compiler/linker for both musl and macOS
|
||||||
run: cargo build --release --locked --target ${{ matrix.target }} -p hx-cli
|
- run: pip install ziglang cargo-zigbuild
|
||||||
# macOS: zig as cross C compiler/linker, Apple SDK for Security.framework etc.
|
# macOS: Apple SDK for Security.framework etc.
|
||||||
- if: matrix.target == 'aarch64-apple-darwin'
|
- if: matrix.target == 'aarch64-apple-darwin'
|
||||||
run: |
|
run: |
|
||||||
pip install ziglang cargo-zigbuild
|
|
||||||
curl -fsSL "https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK}/MacOSX${MACOS_SDK}.sdk.tar.xz" | tar -xJ -C "$HOME"
|
curl -fsSL "https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK}/MacOSX${MACOS_SDK}.sdk.tar.xz" | tar -xJ -C "$HOME"
|
||||||
SDKROOT="$HOME/MacOSX${MACOS_SDK}.sdk" cargo zigbuild --release --locked --target ${{ matrix.target }} -p hx-cli
|
echo "SDKROOT=$HOME/MacOSX${MACOS_SDK}.sdk" >> "$GITHUB_ENV"
|
||||||
|
- run: cargo zigbuild --release --locked --target ${{ matrix.target }} -p hx-cli
|
||||||
|
env:
|
||||||
|
HX_VERSION: ${{ needs.version.outputs.version }}
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: hx-${{ matrix.target }}
|
name: hx-${{ matrix.target }}
|
||||||
path: target/${{ matrix.target }}/release/hx
|
path: target/${{ matrix.target }}/release/hx
|
||||||
|
release:
|
||||||
|
needs: [build, version]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
# artifacts lose the executable bit, restore it before packaging
|
||||||
|
- working-directory: dist
|
||||||
|
run: |
|
||||||
|
for t in hx-*; do
|
||||||
|
chmod +x "$t/hx"
|
||||||
|
tar -czf "$t.tar.gz" -C "$t" hx
|
||||||
|
done
|
||||||
|
sha256sum *.tar.gz > SHA256SUMS
|
||||||
|
- env:
|
||||||
|
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
||||||
|
TAG: v${{ needs.version.outputs.version }}
|
||||||
|
SHA: ${{ gitea.sha }}
|
||||||
|
# Gitea creates the tag at target_commitish when it doesn't exist
|
||||||
|
run: |
|
||||||
|
id=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"target_commitish\":\"$SHA\"}" "$API/releases" | jq -r .id)
|
||||||
|
for f in dist/*.tar.gz dist/SHA256SUMS; do
|
||||||
|
curl -fsS -X POST -H "Authorization: token $TOKEN" \
|
||||||
|
-F "attachment=@$f" "$API/releases/$id/assets?name=$(basename "$f")"
|
||||||
|
done
|
||||||
@@ -15,7 +15,12 @@ mod rpc;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "hx", version, about = "Minimal coding agent")]
|
#[command(
|
||||||
|
name = "hx",
|
||||||
|
// CI sets HX_VERSION to the release version; local builds use Cargo's
|
||||||
|
version = option_env!("HX_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")),
|
||||||
|
about = "Minimal coding agent"
|
||||||
|
)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Option<Cmd>,
|
cmd: Option<Cmd>,
|
||||||
|
|||||||
Reference in new issue
Block a user