diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 56e03d2..c739b94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,26 +8,160 @@ on: jobs: assets: name: Build and release assets - runs-on: "ubuntu-latest" + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - { + os: "ubuntu-20.04", + arch: "amd64", + wasiSDK: "linux", + extension: "", + buildArgs: "", + target: "", + targetDir: "target/release", + } + - { + os: "ubuntu-20.04", + arch: "aarch64", + wasiSDK: "linux", + extension: "", + buildArgs: "--target aarch64-unknown-linux-gnu", + target: "aarch64-unknown-linux-gnu", + targetDir: "target/aarch64-unknown-linux-gnu/release", + } + - { + os: "macos-latest", + arch: "amd64", + wasiSDK: "macos", + extension: "", + buildArgs: "", + target: "", + targetDir: "target/release", + } + - { + os: "macos-latest", + arch: "aarch64", + wasiSDK: "macos", + extension: "", + buildArgs: "--target aarch64-apple-darwin", + target: "aarch64-apple-darwin", + targetDir: "target/aarch64-apple-darwin/release/", + } + - { + os: "windows-latest", + arch: "amd64", + wasiSDK: "", + extension: ".exe", + buildArgs: "", + target: "", + targetDir: "target/release", + } steps: - uses: actions/checkout@v2 - name: set the release version (tag) run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + - name: lowercase the runner OS name + shell: bash + run: | + OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]') + echo "RUNNER_OS=$OS" >> $GITHUB_ENV - - name: Install Dependencies + - name: Install Rust Wasm target run: rustup target add wasm32-wasi + - name: Install Rust CPU target + if: matrix.config.target != '' + shell: bash + run: rustup target add ${{ matrix.config.target }} + + - name: setup for cross-compiled linux aarch64 build + if: matrix.config.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt update + sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + echo '[target.aarch64-unknown-linux-gnu]' >> ${HOME}/.cargo/config.toml + echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml + echo 'rustflags = ["-Ctarget-feature=+fp16"]' >> ${HOME}/.cargo/config.toml - name: Build WASM + if: matrix.os == 'ubuntu-20.04' && matrix.arch == 'amd64' run: make build + - name: Upload WASM as GitHub artifact + if: matrix.os == 'ubuntu-20.04' && matrix.arch == 'amd64' + uses: actions/upload-artifact@v3 + with: + name: bart # TODO: ??? bartholomew.wasm + path: target/wasm32-wasi/release/bartholomew.wasm - name: Build bart - run: make bart + run: cargo build --release --manifest-path=bart/Cargo.toml ${{ matrix.config.extraArgs }} - - name: generate checksums + - name: package release assets + if: runner.os != 'Windows' + shell: bash + run: | + mkdir _dist + cp ${{ matrix.config.targetDir }}/bart${{ matrix.config.extension }} _dist/ + cd _dist + tar czf \ + bart-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz \ + bart${{ matrix.config.extension }} + + - name: package release assets + if: runner.os == 'Windows' + shell: bash run: | - sha256sum target/wasm32-wasi/release/bartholomew.wasm > checksums-${{ env.RELEASE_VERSION }}.txt - sha256sum target/release/bart >> checksums-${{ env.RELEASE_VERSION }}.txt + mkdir _dist + cp ${{ matrix.config.targetDir }}/bart${{ matrix.config.extension }} _dist/ + cd _dist + 7z a -tzip \ + bart-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.zip \ + bart${{ matrix.config.extension }} + + - name: upload binary as GitHub artifact + if: runner.os != 'Windows' + uses: actions/upload-artifact@v3 + with: + name: bart + path: _dist/bart-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz + + # - name: upload binary to Github release + # if: startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows' + # uses: svenstaro/upload-release-action@v2 + # with: + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # file: _dist/bart-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz + # tag: ${{ github.ref }} + + - name: upload binary as GitHub artifact + if: runner.os == 'Windows' + uses: actions/upload-artifact@v3 + with: + name: bart + path: _dist/bart-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.zip + + # - name: generate checksums + # run: | + # sha256sum target/wasm32-wasi/release/bartholomew.wasm > checksums-${{ env.RELEASE_VERSION }}.txt + # sha256sum target/release/bart >> checksums-${{ env.RELEASE_VERSION }}.txt + + checksums: + name: generate release checksums + runs-on: ubuntu-latest + needs: assets + steps: + - name: set the release version (tag) + run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: download release assets + uses: actions/download-artifact@v3 + with: + name: bart + + - name: generate checksums + run: sha256sum * > checksums-${{ env.RELEASE_VERSION }}.txt - name: Create release uses: softprops/action-gh-release@v1 @@ -35,6 +169,19 @@ jobs: fail_on_unmatched_files: true generate_release_notes: true files: | - target/wasm32-wasi/release/bartholomew.wasm - target/release/bart + bartholomew.wasm + *.tar.gz + *.zip checksums-${{ env.RELEASE_VERSION }}.txt + + - uses: actions/upload-artifact@v3 + with: + name: bart + path: checksums-${{ env.RELEASE_VERSION }}.txt + + - name: upload checksums to Github release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: checksums-${{ env.RELEASE_VERSION }}.txt + tag: ${{ github.ref }}