|
| 1 | +name: Build MacOS |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + ref: |
| 7 | + description: 'Tag to build' |
| 8 | + required: true |
| 9 | + project_name: |
| 10 | + description: 'The vanagon project to build' |
| 11 | + required: false |
| 12 | + default: 'agent-runtime-main' |
| 13 | + platform_list: |
| 14 | + description: 'A comma-separated list of platforms to build for. Do not include spaces. If not provided, will use the default list of macOS platforms.' |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + default: 'osx-15-arm64,osx-15-x86_64' |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read # minimal required permissions to clone repo |
| 21 | + |
| 22 | +env: |
| 23 | + ENDPOINT_URL: ${{ secrets.S3_ENDPOINT_URL }} |
| 24 | + BUCKET_NAME: ${{ secrets.S3_ARTIFACTS_BUCKET_NAME }} |
| 25 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 26 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 27 | + # https://github.com/boto/boto3/issues/4398#issuecomment-2619946229 |
| 28 | + AWS_REQUEST_CHECKSUM_CALCULATION: "WHEN_REQUIRED" |
| 29 | + AWS_RESPONSE_CHECKSUM_VALIDATION: "WHEN_REQUIRED" |
| 30 | + VANAGON_LOCATION: 'https://github.com/openvoxproject/vanagon#macos_test' |
| 31 | + |
| 32 | +jobs: |
| 33 | + set-matrix: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + outputs: |
| 36 | + macos_matrix: ${{ steps.set-matrix.outputs.macos_matrix }} |
| 37 | + steps: |
| 38 | + - id: set-matrix |
| 39 | + run: | |
| 40 | + default_list=( |
| 41 | + 'osx-15-arm64' |
| 42 | + 'osx-15-x86_64' |
| 43 | + ) |
| 44 | + if [[ -n "${{ inputs.platform_list }}" ]]; then |
| 45 | + IFS=',' read -r -a platforms <<< "${{ inputs.platform_list }}" |
| 46 | + else |
| 47 | + platforms=("${default_list[@]}") |
| 48 | + fi |
| 49 | + echo "macos_matrix=$(jq --monochrome-output --compact-output --null-input '$ARGS.positional' --args -- ${platforms[@]})" >> "${GITHUB_OUTPUT}" |
| 50 | +
|
| 51 | + build_macos: |
| 52 | + needs: set-matrix |
| 53 | + runs-on: macos-latest |
| 54 | + timeout-minutes: 7200 |
| 55 | + if: needs.set-matrix.outputs.macos_matrix != '[]' |
| 56 | + strategy: |
| 57 | + fail-fast: false |
| 58 | + matrix: |
| 59 | + platform: ${{ fromJson(needs.set-matrix.outputs.macos_matrix) }} |
| 60 | + steps: |
| 61 | + - name: Checkout code at tag |
| 62 | + uses: actions/checkout@v5 |
| 63 | + with: |
| 64 | + ref: ${{ inputs.ref }} |
| 65 | + |
| 66 | + - name: Set architecture variables |
| 67 | + id: arch |
| 68 | + run: | |
| 69 | + if [[ "${{ matrix.platform }}" == *"x86_64"* ]]; then |
| 70 | + echo "arch=x86_64" >> $GITHUB_OUTPUT |
| 71 | + echo "needs_brew_reinstall=true" >> $GITHUB_OUTPUT |
| 72 | + else |
| 73 | + echo "arch=arm64" >> $GITHUB_OUTPUT |
| 74 | + echo "needs_brew_reinstall=false" >> $GITHUB_OUTPUT |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Setup brew and Ruby (x86_64 only) |
| 78 | + if: steps.arch.outputs.needs_brew_reinstall == 'true' |
| 79 | + # We must fully uninstall the existing brew install as we need |
| 80 | + # the x86_64 version, and then we must install Ruby ourselves |
| 81 | + run: | |
| 82 | + brew list --cask | xargs -r brew uninstall --cask --force |
| 83 | + brew list --formula | xargs -r brew uninstall --force --ignore-dependencies |
| 84 | + brew autoremove |
| 85 | + sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" -- --force |
| 86 | + sudo rm -rf /opt/homebrew |
| 87 | + arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 88 | + arch -x86_64 /bin/bash -c 'brew install ruby@3.2' |
| 89 | + echo >> $HOME/.bash_profile |
| 90 | + echo 'eval "$(/usr/local/bin/brew shellenv)"' >> $HOME/.bash_profile |
| 91 | + echo 'GEM_PATH=/usr/local/lib/ruby/gems/3.2.0/bin' >> $HOME/.bash_profile |
| 92 | + echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@3.2/bin:$PATH"' >> $HOME/.bash_profile |
| 93 | +
|
| 94 | + - name: Install Ruby (arm64 only) |
| 95 | + if: steps.arch.outputs.needs_brew_reinstall == 'false' |
| 96 | + uses: ruby/setup-ruby@v1 |
| 97 | + with: |
| 98 | + ruby-version: '3.2' |
| 99 | + |
| 100 | + - name: test |
| 101 | + run: | |
| 102 | + echo ".bash_profile" |
| 103 | + cat ~/.bash_profile |
| 104 | + echo ".bashrc" |
| 105 | + cat ~/.bashrc |
| 106 | + arch -x86_64 /bin/bash -c 'which ruby; ruby --version; which gem; gem --version; which bundle; bundle --version; which brew; brew --version;echo $PATH' |
| 107 | + - name: Bundle install |
| 108 | + run: | |
| 109 | + arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'bundle install --retry=3 && bundle update' |
| 110 | +
|
| 111 | + - name: Run build script |
| 112 | + run: | |
| 113 | + rm -rf output |
| 114 | + arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'bundle exec rake vox:build["${{ inputs.project_name }}","${{ matrix.platform }}"]' |
| 115 | +
|
| 116 | + - name: Install awscli |
| 117 | + run: | |
| 118 | + arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'brew install awscli' |
| 119 | +
|
| 120 | + - name: Upload output to S3 |
| 121 | + run: arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'bundle exec rake vox:upload["${{ inputs.ref }}","${{ matrix.platform }}"]' |
0 commit comments