From 0184d3fc058a3693e55974bb73a862e3d08cf5e5 Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Fri, 17 Jan 2025 11:39:19 -0500 Subject: [PATCH] add reuseable workflow for build-cli --- .github/workflows/build-cli.yml | 72 +++++++++++++++++++++++++++++++++ .github/workflows/canary.yml | 47 +-------------------- .github/workflows/release.yml | 47 +-------------------- 3 files changed, 74 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/build-cli.yml diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml new file mode 100644 index 0000000000..0f20b44c42 --- /dev/null +++ b/.github/workflows/build-cli.yml @@ -0,0 +1,72 @@ +# This is a **reuseable** workflow that bundles the Desktop App for macOS. +# It doesn't get triggered on its own. It gets used in multiple workflows: +# - release.yml +# - canary.yml +on: + workflow_call: + inputs: + # Let's allow overriding the OSes and architectures in JSON array form: + # e.g. '["ubuntu-latest","macos-latest"]' + # If no input is provided, these defaults apply. + operating-systems: + type: string + required: false + default: '["ubuntu-latest","macos-latest"]' + architectures: + type: string + required: false + default: '["x86_64","aarch64"]' + +name: "Reusable workflow to build CLI" + +jobs: + build-cli: + name: Build CLI + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ${{ fromJson(inputs.operating-systems) }} + architecture: ${{ fromJson(inputs.architectures) }} + + include: + # These are the standard two OSes & suffixes you originally had: + - os: ubuntu-latest + target-suffix: unknown-linux-gnu + # If you want: define additional custom fields here as needed + - os: macos-latest + target-suffix: apple-darwin + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.architecture }}-${{ matrix.target-suffix }} + + - name: Install cross + run: cargo install cross --git https://github.com/cross-rs/cross + + - name: Build CLI + env: + CROSS_NO_WARNINGS: 0 + run: | + export TARGET="${{ matrix.architecture }}-${{ matrix.target-suffix }}" + rustup target add "${TARGET}" + + # 'cross' is used to cross-compile for different architectures (see Cross.toml) + cross build --release --target ${TARGET} -p goose-cli + + # tar the goose binary as goose-.tar.bz2 + cd target/${TARGET}/release + tar -cjf goose-${TARGET}.tar.bz2 goose + echo "ARTIFACT=target/${TARGET}/release/goose-${TARGET}.tar.bz2" >> $GITHUB_ENV + + - name: Upload CLI artifact + uses: actions/upload-artifact@v4 + with: + name: goose-${{ matrix.architecture }}-${{ matrix.target-suffix }} + path: ${{ env.ARTIFACT }} diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 7bcd66fb1f..efd4cc036e 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -20,52 +20,7 @@ jobs: # 1) Build CLI for multiple OS/Arch # ------------------------------------ build-cli: - name: Build CLI - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest, macos-latest ] - architecture: [ x86_64, aarch64 ] # Intel/AMD64, ARM64 - include: - - os: ubuntu-latest - target-suffix: unknown-linux-gnu - - os: macos-latest - target-suffix: apple-darwin - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - target: ${{ matrix.architecture }}-${{ matrix.target-suffix }} - - - name: Install cross - run: cargo install cross --git https://github.com/cross-rs/cross - - - name: Build CLI - env: - CROSS_NO_WARNINGS: 0 - run: | - export TARGET="${{ matrix.architecture }}-${{ matrix.target-suffix }}" - rustup target add "${TARGET}" - - # 'cross' is used to cross-compile for different architectures (see Cross.toml) - # Only 'goose' binary is needed for CLI release, skipping 'goosed' here - cross build --release --target ${TARGET} -p goose-cli - - cd target/${TARGET}/release - tar -cjf goose-${TARGET}.tar.bz2 goose - echo "ARTIFACT=target/${TARGET}/release/goose-${TARGET}.tar.bz2" >> $GITHUB_ENV - - - name: Upload CLI artifact - uses: actions/upload-artifact@v4 - with: - name: goose-${{ matrix.architecture }}-${{ matrix.target-suffix }} - path: ${{ env.ARTIFACT }} + uses: ./.github/workflows/build-cli.yml # ------------------------------------ # 2) Upload Install CLI Script (we only need to do this once) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 485940aeea..a0bc94ba96 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,52 +16,7 @@ jobs: # 1) Build CLI for multiple OS/Arch # ------------------------------------ build-cli: - name: Build CLI - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest, macos-latest ] - architecture: [ x86_64, aarch64 ] # Intel/AMD64, ARM64 - include: - - os: ubuntu-latest - target-suffix: unknown-linux-gnu - - os: macos-latest - target-suffix: apple-darwin - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - target: ${{ matrix.architecture }}-${{ matrix.target-suffix }} - - - name: Install cross - run: cargo install cross --git https://github.com/cross-rs/cross - - - name: Build CLI - env: - CROSS_NO_WARNINGS: 0 - run: | - export TARGET="${{ matrix.architecture }}-${{ matrix.target-suffix }}" - rustup target add "${TARGET}" - - # 'cross' is used to cross-compile for different architectures (see Cross.toml) - # Only 'goose' binary is needed for CLI release, skipping 'goosed' here - cross build --release --target ${TARGET} -p goose-cli - - cd target/${TARGET}/release - tar -cjf goose-${TARGET}.tar.bz2 goose - echo "ARTIFACT=target/${TARGET}/release/goose-${TARGET}.tar.bz2" >> $GITHUB_ENV - - - name: Upload CLI artifact - uses: actions/upload-artifact@v4 - with: - name: goose-${{ matrix.architecture }}-${{ matrix.target-suffix }} - path: ${{ env.ARTIFACT }} + uses: ./.github/workflows/build-cli.yml # ------------------------------------ # 2) Upload Install CLI Script (we only need to do this once)