From 3b909ab3bc0fc327f2cbbebe46760677ef2796e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Selim=20=C5=9Eeker?= <44788355+selimseker@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:38:06 +0300 Subject: [PATCH] Build and publish binaries (#116) * add build exe workflow file * install openssl * fix typo * convert openssl step to bash * set openssl env-vars * use choco install for windows packages * add openssl envs to build step * add openssl paths to matrix for each os/arch * add openssl_dir * fix typo * add PKG_CONFIG_PATH * fix typo * use choco install for windows packages * build cargo withour actions-rs * install gcc-aarch64-linux-gnu * openssl_dir as /usr/local/ssl * actions-rs use-cross * use houseabsolute/actions-rust-cross * build for macos/linux * build for macos arm64 * build for macos amd64 * build for macos and linux * update latest release with assets * build windows-amd64 * build windows-arm64 * use nightly for windows-arm64 * build linux-arm64 with prebuilt openssl installation * use linker rust-lld * add exes to v0.2.0 * update ollama-workflows * fix typo * remove linker * build for macos and linux all archs * ollama update * tar.gz instead of zip * change asset names * publish exe instead of tar * publish binaries for macos and linux * windows build * fix typo * trigger workflow on release creation --- .github/workflows/build_prod_exe.yml | 93 ++++++++++++++++++++++++++++ Cross.toml | 5 ++ 2 files changed, 98 insertions(+) create mode 100644 .github/workflows/build_prod_exe.yml create mode 100644 Cross.toml diff --git a/.github/workflows/build_prod_exe.yml b/.github/workflows/build_prod_exe.yml new file mode 100644 index 0000000..f7170de --- /dev/null +++ b/.github/workflows/build_prod_exe.yml @@ -0,0 +1,93 @@ +name: Build and Publish Compute Releases + +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + + build: + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - { runner: macos-latest, osname: macOS, arch: amd64, target: x86_64-apple-darwin, command: build } + - { runner: macos-latest, osname: macOS, arch: arm64, target: aarch64-apple-darwin, command: build } + - { runner: ubuntu-latest, osname: linux, arch: amd64, target: x86_64-unknown-linux-gnu, command: build } + - { runner: ubuntu-latest, osname: linux, arch: arm64, target: aarch64-unknown-linux-gnu, command: build, build_args: --no-default-features } + - { runner: windows-latest, osname: windows, arch: amd64, target: x86_64-pc-windows-msvc, command: build, extension: ".exe" } + # - { runner: windows-latest, osname: windows, arch: arm64, target: aarch64-pc-windows-msvc, command: build, extension: ".exe", toolchain: nightly } + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get the release version from the tag + shell: bash + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build binary + uses: houseabsolute/actions-rust-cross@v0 + with: + command: ${{ matrix.command }} + target: ${{ matrix.target }} + args: "--locked --release ${{ matrix.build_args }}" + strip: true + + - name: Prepare Release File + run: | + # move the binary + mv target/${{ matrix.target }}/release/dkn-compute${{ matrix.extension }} ./dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}${{ matrix.extension }} + + + - name: Upload Launch Artifacts + uses: actions/upload-artifact@v4 + with: + name: dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }} + path: dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}${{ matrix.extension }} + + + release: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch all tags and history + + - name: Download Launch Artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: ./artifacts + + - name: Get the latest tag + id: get_latest_tag + run: | + # latest release tag + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "untagged") + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + + # latest release name + LATEST_RELEASE=$(curl -s \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.name // "no-release-found"') + echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_ENV + + echo "Latest Tag: $LATEST_TAG" + echo "Latest Release: $LATEST_RELEASE" + + - name: Create release with artifacts + uses: ncipollo/release-action@v1 + with: + name: ${{ env.LATEST_RELEASE }} + tag: ${{ env.LATEST_TAG }} + artifacts: "artifacts/*" + artifactContentType: application/octet-stream + allowUpdates: true + # draft: true diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..ed33168 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,5 @@ +[target.aarch64-unknown-linux-gnu] +pre-build = [ + "dpkg --add-architecture $CROSS_DEB_ARCH", + "apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH" +] \ No newline at end of file