diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3a25b72..b69ffc8a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,118 +9,97 @@ on: - 'client-v*' workflow_dispatch: # Allow manual creation of artifacts without a release +defaults: + run: + shell: bash + jobs: build: name: build release assets - runs-on: ${{ matrix.config.os }} + runs-on: ${{ matrix.config.runnerOs }} outputs: version_output: ${{ steps.version_output.outputs.version }} strategy: matrix: config: - # NOTE: We are building on an older version of ubuntu because of libc compatibility - # issues. Namely, if we build on a new version of libc, it isn't backwards compatible with - # old versions. But if we build on the old version, it is compatible with the newer - # versions running in ubuntu 22 and its ilk - { - os: 'ubuntu-20.04', - arch: 'amd64', - extension: '', - targetPath: 'target/release/', + runnerOs: 'ubuntu-latest', + target: 'x86_64-unknown-linux-musl', + uploadArtifactSuffix: 'linux-amd64', + buildOutputPath: 'target/release/wadm', } - { - os: 'ubuntu-20.04', - arch: 'aarch64', - extension: '', - targetPath: 'target/aarch64-unknown-linux-gnu/release/', + runnerOs: 'ubuntu-latest', + target: 'aarch64-unknown-linux-musl', + uploadArtifactSuffix: 'linux-aarch64', + buildOutputPath: 'target/aarch64-unknown-linux-musl/release/wadm', } - { - os: 'macos-13', - arch: 'amd64', - extension: '', - targetPath: 'target/release/', + runnerOs: 'macos-14-large', + target: 'x86_64-apple-darwin', + uploadArtifactSuffix: 'macos-amd64', + buildOutputPath: 'target/release/wadm', } - { - os: 'windows-latest', - arch: 'amd64', - extension: '.exe', - targetPath: 'target/release/', + runnerOs: 'macos-14', + target: 'aarch64-apple-darwin', + uploadArtifactSuffix: 'macos-aarch64', + buildOutputPath: 'target/release/wadm', } - { - os: 'macos-latest', - arch: 'aarch64', - extension: '', - targetPath: 'target/release/', + runnerOs: 'windows-latest', + target: 'x86_64-pc-windows-msvc', + uploadArtifactSuffix: 'windows-amd64', + buildOutputPath: 'target/release/wadm.exe', } steps: - uses: actions/checkout@v4 - name: set the release version (tag) - if: startsWith(github.ref, 'refs/tags/v') - shell: bash - run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV - name: set the release version (main) - if: github.ref == 'refs/heads/main' - shell: bash - run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV + if: ${{ github.ref == 'refs/heads/main' }} + run: | + echo "RELEASE_VERSION=canary" >> $GITHUB_ENV - name: Output Version id: version_output run: echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT - - name: lowercase the runner OS name - shell: bash - run: | - OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]') - echo "RUNNER_OS=$OS" >> $GITHUB_ENV + - name: Install Zig + uses: goto-bus-stop/setup-zig@v2 - name: Install latest Rust stable toolchain uses: dtolnay/rust-toolchain@stable - if: matrix.config.arch != 'aarch64' || startsWith(matrix.config.os, 'macos') with: toolchain: stable components: clippy, rustfmt + target: ${{ matrix.config.target }} - - name: setup for cross-compile builds - if: matrix.config.arch == 'aarch64' && matrix.config.os == 'ubuntu-20.04' - run: | - sudo apt-get update - sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - rustup toolchain install stable-aarch64-unknown-linux-gnu - rustup target add --toolchain stable-aarch64-unknown-linux-gnu aarch64-unknown-linux-gnu - echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV - - - name: Install latest Rust stable toolchain - uses: dtolnay/rust-toolchain@stable - if: matrix.config.arch == 'aarch64' && matrix.config.os == 'ubuntu-20.04' + - name: Install cargo zigbuild + uses: taiki-e/install-action@v2 with: - toolchain: stable - components: clippy, rustfmt - target: aarch64-unknown-linux-gnu - - - name: build release (amd64 linux, macos, windows) - if: matrix.config.arch != 'aarch64' || startsWith(matrix.config.os, 'macos') - run: 'cargo build --release --bin wadm' + tool: cargo-zigbuild - - name: build release (arm64 linux) - if: matrix.config.arch == 'aarch64' && matrix.config.os == 'ubuntu-20.04' - run: 'cargo build --release --bin wadm --target aarch64-unknown-linux-gnu' + - name: Build wadm + run: | + cargo zigbuild --release --bin wadm --target ${{ matrix.config.target }} - uses: actions/upload-artifact@v4 with: - name: wadm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }} + name: wadm-${{ env.RELEASE_VERSION }}-${{ matrix.config.uploadArtifactSuffix }} if-no-files-found: error path: | - ${{ matrix.config.targetPath }}wadm${{ matrix.config.extension }} + ${{ matrix.config.buildOutputPath }} publish: + if: ${{ startsWith(github.ref, 'refs/tags/v') }} name: publish release assets - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: build - if: startsWith(github.ref, 'refs/tags/v') env: RELEASE_VERSION: ${{ needs.build.outputs.version_output }} steps: @@ -151,9 +130,9 @@ jobs: wadm-${{ env.RELEASE_VERSION }}-windows-amd64.tar.gz crate: + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/types-v') || startsWith(github.ref, 'refs/tags/client-v') }} name: Publish crate runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/types-v') || startsWith(github.ref, 'refs/tags/client-v') needs: build steps: - uses: actions/checkout@v4 @@ -161,25 +140,28 @@ jobs: uses: dtolnay/rust-toolchain@stable with: toolchain: stable + - name: Cargo login - run: cargo login ${{ secrets.CRATES_TOKEN }} - shell: bash + run: | + cargo login ${{ secrets.CRATES_TOKEN }} - name: Cargo publish wadm-types - if: startsWith(github.ref, 'refs/tags/types-v') - run: cargo publish + if: ${{ startsWith(github.ref, 'refs/tags/types-v') }} working-directory: ./crates/wadm-types - shell: bash + run: | + cargo publish + - name: Cargo publish wadm lib - if: startsWith(github.ref, 'refs/tags/v') - run: cargo publish + if: ${{ startsWith(github.ref, 'refs/tags/v') }} working-directory: ./crates/wadm - shell: bash + run: | + cargo publish + - name: Cargo publish wadm-client - if: startsWith(github.ref, 'refs/tags/client-v') - run: cargo publish + if: ${{ startsWith(github.ref, 'refs/tags/client-v') }} working-directory: ./crates/wadm-client - shell: bash + run: | + cargo publish docker-image: name: Build and push docker images @@ -201,15 +183,11 @@ jobs: - uses: actions/download-artifact@v4 with: - name: wadm-${{ env.RELEASE_VERSION }}-linux-aarch64 - path: ./artifacts - - run: mv ./artifacts/wadm ./artifacts/wadm-${{ env.RELEASE_VERSION }}-linux-aarch64 && chmod +x ./artifacts/wadm-${{ env.RELEASE_VERSION }}-linux-aarch64 - - - uses: actions/download-artifact@v4 - with: - name: wadm-${{ env.RELEASE_VERSION }}-linux-amd64 path: ./artifacts - - run: mv ./artifacts/wadm ./artifacts/wadm-${{ env.RELEASE_VERSION }}-linux-amd64 && chmod +x ./artifacts/wadm-${{ env.RELEASE_VERSION }}-linux-amd64 + merge-multiple: true + - run: | + chmod +x ./artifacts/wadm-${{ env.RELEASE_VERSION }}-linux-aarch64 + chmod +x ./artifacts/wadm-${{ env.RELEASE_VERSION }}-linux-amd64 - name: Login to GitHub Container Registry uses: docker/login-action@v3 @@ -224,7 +202,7 @@ jobs: - name: Build and push (tag) uses: docker/build-push-action@v6 - if: startsWith(github.ref, 'refs/tags/v') + if: ${{ startsWith(github.ref, 'refs/tags/v') }} with: push: true platforms: linux/amd64,linux/arm64 @@ -236,7 +214,7 @@ jobs: - name: Build and push (main) uses: docker/build-push-action@v6 - if: github.ref == 'refs/heads/main' + if: ${{ github.ref == 'refs/heads/main' }} with: push: true platforms: linux/amd64,linux/arm64