diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 257648fe..61869854 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,106 +10,103 @@ permissions: jobs: - build_binaries_and_publish: - name: Build Binaries + prebuild_preparation: + name: Get Binary Type + runs-on: ubuntu-latest + outputs: + bin_name: ${{ steps.get_binary_type.outputs.BIN_NAME }} + bin_suffix: ${{ steps.get_binary_type.outputs.BIN_SUFFIX }} + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Get Binary Type" + id: get_binary_type + run: | + cd ${{github.workspace}} + echo ${{ github.event.release.tag_name }} + value=$(echo "${{ github.event.release.tag_name }}" | cut -d'/' -f2) + echo "$value" + echo "BIN_SUFFIX=${value}" >> $GITHUB_OUTPUT + echo "BIN_NAME=ahnlich-${value}" >> $GITHUB_OUTPUT + + build_linux_binaries_and_publish: + needs: prebuild_preparation + name: Build Linux Binaries runs-on: ubuntu-latest - outputs: - bin_name: ${{ steps.get_binary_type.outputs.BIN_NAME }} - bin_suffix: ${{ steps.get_binary_type.outputs.BIN_SUFFIX }} steps: - name: "Checkout" uses: actions/checkout@v4 - - name: "Get Binary Type" - id: get_binary_type - run: | - cd ${{github.workspace}} - echo ${{ github.event.release.tag_name }} - value=$(echo "${{ github.event.release.tag_name }}" | cut -d'/' -f2) - echo "$value" - echo "BIN_SUFFIX=${value}" >> $GITHUB_OUTPUT - echo "BIN_NAME=ahnlich-${value}" >> $GITHUB_OUTPUT - - name: Get Cargo toolchain uses: actions-rs/toolchain@v1 with: toolchain: 1.81.0 - - - name: Setup Zig - uses: mlugg/setup-zig@v1 - with: - version: 0.13.0 - - name: Build Linux Release for ${{ steps.get_binary_type.outputs.BIN_NAME }} + - name: Build Linux Release for ${{ needs.prebuild_preparation.outputs.bin_name }} working-directory: ./ahnlich run: | - cargo build --release --bin ${{ steps.get_binary_type.outputs.BIN_NAME }} - tar -cvzf linux-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz -C target/release ${{ steps.get_binary_type.outputs.BIN_NAME }} - gh release upload ${{github.event.release.tag_name}} linux-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz + cargo build --release --bin ${{ needs.prebuild_preparation.outputs.bin_name }} + tar -cvzf linux-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz -C target/release ${{ needs.prebuild_preparation.outputs.bin_name }} + gh release upload ${{github.event.release.tag_name}} linux-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} shell: bash - - name: Setup Cargo ZigBuild - working-directory: ./ahnlich - run: | - cargo install --locked cargo-zigbuild --version 0.19.1 + build_macos_darwin_binaries_and_publish: + needs: prebuild_preparation + name: Build MacOs Darwin Binaries + runs-on: macos-latest + outputs: + bin_name: ${{ needs.prebuild_preparation.outputs.bin_name }} + bin_suffix: ${{ steps.get_binary_type.outputs.BIN_SUFFIX }} + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Build Aarch64 Darwin Release for ${{ steps.get_binary_type.outputs.BIN_NAME }} + - name: Build Aarch64 Darwin Release for ${{ needs.prebuild_preparation.outputs.bin_name }} working-directory: ./ahnlich run: | - rustup target add aarch64-apple-darwin - cargo zigbuild --release --target aarch64-apple-darwin --bin ${{ steps.get_binary_type.outputs.BIN_NAME }} - tar -cvzf aarch64-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz -C target/aarch64-apple-darwin/release ${{ steps.get_binary_type.outputs.BIN_NAME }} - gh release upload ${{github.event.release.tag_name}} aarch64-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz + cargo build --release --target aarch64-apple-darwin --bin ${{ needs.prebuild_preparation.outputs.bin_name }} + tar -cvzf aarch64-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz -C target/aarch64-apple-darwin/release ${{ needs.prebuild_preparation.outputs.bin_name }} + gh release upload ${{github.event.release.tag_name}} aarch64-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} shell: bash - - - name: Build x86_64 Apple Darwin Release for ${{ steps.get_binary_type.outputs.BIN_NAME }} - working-directory: ./ahnlich - run: | - rustup target add x86_64-apple-darwin - cargo zigbuild --release --target x86_64-apple-darwin --bin ${{ steps.get_binary_type.outputs.BIN_NAME }} - tar -cvzf x86_64-apple-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz -C target/x86_64-apple-darwin/release ${{ steps.get_binary_type.outputs.BIN_NAME }} - - gh release upload ${{github.event.release.tag_name}} x86_64-apple-darwin-${{ steps.get_binary_type.outputs.BIN_NAME }}.tar.gz - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - shell: bash - - name: Setup Cross - working-directory: ./ahnlich - run: | - cargo install cross --git https://github.com/cross-rs/cross + build_macos_x86_64_binaries_and_publish: + needs: prebuild_preparation + name: Build MacOs x86_64 Binaries + runs-on: macos-13 + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Build Windows x86_64-pc-windows-gnu for Ahnlich ${{ steps.get_binary_type.outputs.BIN_NAME }} - uses: houseabsolute/actions-rust-cross@v0 + - name: Get Cargo toolchain + uses: actions-rs/toolchain@v1 with: - working-directory: ./ahnlich - command: build - target: x86_64-pc-windows-gnu - args: "--locked --release --bin ${{ steps.get_binary_type.outputs.BIN_NAME }}" - strip: true + toolchain: 1.81.0 - - name: Package and upload x86_64-pc-windows-gnu for Ahnlich ${{ steps.get_binary_type.outputs.BIN_NAME }} + - name: Build x86_64 Apple Darwin Release for ${{ needs.prebuild_preparation.outputs.bin_name }} working-directory: ./ahnlich run: | - cd target/x86_64-pc-windows-gnu/release/ && zip ../../../win-x86_64-gnu-${{ steps.get_binary_type.outputs.BIN_NAME }}.zip ${{ steps.get_binary_type.outputs.BIN_NAME }}.exe && cd ../../../ - gh release upload ${{github.event.release.tag_name}} win-x86_64-gnu-${{ steps.get_binary_type.outputs.BIN_NAME }}.zip + cargo build --release --target x86_64-apple-darwin --bin ${{ needs.prebuild_preparation.outputs.bin_name }} + tar -cvzf x86_64-apple-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz -C target/x86_64-apple-darwin/release ${{ needs.prebuild_preparation.outputs.bin_name }} + + gh release upload ${{github.event.release.tag_name}} x86_64-apple-darwin-${{ needs.prebuild_preparation.outputs.bin_name }}.tar.gz env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} shell: bash - + push_to_registries: - needs: build_binaries_and_publish + needs: prebuild_preparation name: Push Docker image to multiple registries runs-on: ubuntu-latest - if: ${{needs.build_binaries_and_publish.outputs.bin_name != 'ahnlich-cli'}} + if: ${{needs.prebuild_preparation.outputs.bin_name != 'ahnlich-cli'}} permissions: packages: write contents: read @@ -127,7 +124,7 @@ jobs: - name: Set Port Based on Bin Name id: set_port run: | - if [ "${{ needs.build_binaries_and_publish.outputs.bin_name }}" == "ahnlich-db" ]; then + if [ "${{ needs.prebuild_preparation.outputs.bin_name }}" == "ahnlich-db" ]; then echo "DEFAULT_PORT=1369" >> $GITHUB_ENV echo "DESCRIPTION=Ahnlich DB" >> $GITHUB_ENV else @@ -140,7 +137,7 @@ jobs: working-directory: ./ahnlich run: | # Extract only the numerical version part from the tag - VERSION=$(make workspace-crate-version CRATE_NAME=${{ needs.build_binaries_and_publish.outputs.bin_suffix }} | tail -n 1) + VERSION=$(make workspace-crate-version CRATE_NAME=${{ needs.prebuild_preparation.outputs.bin_suffix }} | tail -n 1) echo $VERSION echo "BIN_VERSION=$VERSION" >> $GITHUB_ENV @@ -156,7 +153,7 @@ jobs: id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ghcr.io/${{ github.repository_owner }}/${{needs.build_binaries_and_publish.outputs.bin_name}} + images: ghcr.io/${{ github.repository_owner }}/${{needs.prebuild_preparation.outputs.bin_name}} tags: | type=schedule type=semver,pattern={{version}},value=v${{env.BIN_VERSION}} @@ -172,12 +169,12 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - AHNLICH_BIN=${{ needs.build_binaries_and_publish.outputs.bin_name}} + AHNLICH_BIN=${{ needs.prebuild_preparation.outputs.bin_name}} DEFAULT_PORT=${{env.DEFAULT_PORT}} - name: Generate artifact attestation uses: actions/attest-build-provenance@v1 with: - subject-name: ghcr.io/${{ github.repository_owner }}/${{needs.build_binaries_and_publish.outputs.bin_name}} + subject-name: ghcr.io/${{ github.repository_owner }}/${{needs.prebuild_preparation.outputs.bin_name}} subject-digest: ${{ steps.push.outputs.digest }} push-to-registry: true