diff --git a/.ci/pack-build.sh b/.ci/pack-build.sh new file mode 100644 index 0000000..91e7709 --- /dev/null +++ b/.ci/pack-build.sh @@ -0,0 +1,64 @@ + +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 + target=x86_64-unknown-linux-musl/ + exe="" +elif [ "$OS_NAME" == "linux-aarch64" ]; then + OS_NAME=linux_aarch64 + target=aarch64-unknown-linux-musl/ + 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/golem-${asset_type}-${OS_NAME}-${TAG_NAME} + mkdir -p "$TARGET_DIR" + for component in $bins $non_exe; do + strip -x target/${target}release/${component}${exe} + done + for bin in $bins; do + cp "target/${target}release/${bin}${exe}" "$TARGET_DIR/" + done + if test -n "$non_exe"; then + for bin in $non_exe; do + cp "target/${target}release/${bin}" "$TARGET_DIR/" + done + fi + if [ "$OS_NAME" = "windows" ]; then + echo "::set-output name=${asset_type}Artifact::golem-${asset_type}-${OS_NAME}-${TAG_NAME}.zip" + echo "::set-output name=${asset_type}Media::application/zip" + (cd "$TARGET_DIR" && 7z a "../golem-${asset_type}-${OS_NAME}-${TAG_NAME}.zip" * ) + else + echo "::set-output name=${asset_type}Artifact::golem-${asset_type}-${OS_NAME}-${TAG_NAME}.tar.gz" + echo "::set-output name=${asset_type}Media::application/tar+gzip" + (cd releases && tar czf "golem-${asset_type}-${OS_NAME}-${TAG_NAME}.tar.gz" "golem-${asset_type}-${OS_NAME}-${TAG_NAME}") + du -h "releases/golem-${asset_type}-${OS_NAME}-${TAG_NAME}.tar.gz" + fi +} + +generate_asset "runtime" "ya-runtime-ai" +generate_asset "framework" "dummy" "ya-dummy-ai.json" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f711fd3..38b0a91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,13 @@ env: jobs: test: name: CI - - runs-on: windows-latest + runs-on: ${{ matrix.os }}-latest + strategy: + fail-fast: true + matrix: + os: + - ubuntu + - windows steps: - uses: actions/checkout@v4 @@ -39,10 +44,24 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: cargo build --workspace --release + - name: Move descriptor + run: mv conf/ya-dummy-ai.json target/release/conf/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 if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - files: target/release/*.exe + files: | + releases/golem-runtime-${{ matrix.os }}-${{ github.ref }}.* + releases/golem-framework-${{ matrix.os }}-${{ github.ref }}.* prerelease: ${{ startsWith(github.ref, 'refs/tags/pre-rel-v') }} diff --git a/conf/ya-runtime-ai.json b/conf/ya-dummy-ai.json similarity index 69% rename from conf/ya-runtime-ai.json rename to conf/ya-dummy-ai.json index a94a26f..396ef89 100644 --- a/conf/ya-runtime-ai.json +++ b/conf/ya-dummy-ai.json @@ -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": {} } ]