Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Linux bins; Pack binaries #13

Merged
merged 13 commits into from
Nov 13, 2023
62 changes: 62 additions & 0 deletions .ci/pack-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

fail() {
printf "%s\n" "$1" >&2
exit 1
}

not_empty() {
test -z "$1" && fail "expected $2"
}


not_empty "$GITHUB_REF" GITHUB_REF
not_empty "$OS_NAME" OS_NAME


if [ "$OS_NAME" = "ubuntu" ]; then
OS_NAME=linux
exe=""
elif [ "$OS_NAME" == "linux-aarch64" ]; then
OS_NAME=linux_aarch64
exe=""
elif [ "$OS_NAME" == "macos" ]; then
OS_NAME=osx
elif [ "$OS_NAME" == "windows" ]; then
exe=".exe"
else
fail "unknown os name: $OS_NAME"
fi

TAG_NAME="${GITHUB_REF##*/}"

generate_asset() {
local asset_type=$1
local bins="$2"
local non_exe="$3"
local TARGET_DIR=releases/${asset_type}-${OS_NAME}-${TAG_NAME}
mkdir -p "$TARGET_DIR"
for component in $bins; do
strip -x target/release/${component}${exe}
done
for bin in $bins; do
cp "target/release/${bin}${exe}" "$TARGET_DIR/"
done
if test -n "$non_exe"; then
for bin in $non_exe; do
cp "target/release/${bin}" "$TARGET_DIR/"
done
fi
if [ "$OS_NAME" = "windows" ]; then
echo "::set-output name=${asset_type}Artifact::${asset_type}-${OS_NAME}-${TAG_NAME}.zip"
echo "::set-output name=${asset_type}Media::application/zip"
(cd "$TARGET_DIR" && 7z a "../${asset_type}-${OS_NAME}-${TAG_NAME}.zip" * )
else
echo "::set-output name=${asset_type}Artifact::${asset_type}-${OS_NAME}-${TAG_NAME}.tar.gz"
echo "::set-output name=${asset_type}Media::application/tar+gzip"
(cd releases && tar czf "${asset_type}-${OS_NAME}-${TAG_NAME}.tar.gz" "${asset_type}-${OS_NAME}-${TAG_NAME}")
du -h "releases/${asset_type}-${OS_NAME}-${TAG_NAME}.tar.gz"
fi
}

generate_asset "runtime" "ya-runtime-ai"
generate_asset "dummy-framework" "dummy" "ya-dummy-ai.json"
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Release

on:
push:
tags:
- v*
- pre-rel-*
env:
CARGO_TERM_COLOR: always

jobs:
release:
name: CI
runs-on: ${{ matrix.os }}-latest
if: startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: true
matrix:
os:
- ubuntu
- windows

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.71.0
components: clippy, rustfmt

- uses: Swatinem/rust-cache@v2

- run: cargo tree --locked

- name: Build
run: cargo build --workspace --release

- name: Move descriptor
run: cp conf/ya-dummy-ai.json target/release/ya-dummy-ai.json

- name: Pack
id: pack
shell: bash
env:
OS_NAME: ${{ matrix.os }}
GITHUB_REF: ${{ github.ref }}
run: |
bash .ci/pack-build.sh

- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
releases/runtime-*
releases/dummy-framework-*
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre-rel-v') }}
26 changes: 8 additions & 18 deletions .github/workflows/ci.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Tests

on:
push:
Expand All @@ -14,9 +14,14 @@ env:
jobs:
test:
name: CI
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: true
matrix:
os:
- ubuntu
- windows

runs-on: windows-latest

steps:
- uses: actions/checkout@v4

Expand All @@ -28,21 +33,6 @@ jobs:
- uses: Swatinem/rust-cache@v2

- run: cargo tree --locked

- run: cargo fmt --all -- --check

- run: cargo clippy --all-targets --all-features --workspace -- -D warnings

- run: cargo test --all-features --workspace

- name: Release Build
if: startsWith(github.ref, 'refs/tags/')
run: cargo build --workspace --release

- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: target/release/*.exe
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre-rel-v') }}
5 changes: 2 additions & 3 deletions conf/ya-runtime-ai.json → conf/ya-dummy-ai.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"version": "0.1.0",
"supervisor-path": "[..]\\ya-runtime-ai\\target\\debug\\ya-runtime-ai.exe",
"extra-args": ["--runtime", "dummy"],
"description": "dummy ai runtime",
"properties": {
}
"description": "Dummy ai runtime for testing purposes",
"properties": {}
}
]
Loading