feat: split macos into arm64 and amd64 binaries #283
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: | |
| - "*.*.*" | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Run Unit Tests | |
| run: | | |
| make build test | |
| lint: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Lint | |
| run: | | |
| go install github.com/golangci/golangci-lint/v2/cmd/[email protected] | |
| make lint || true | |
| security: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Security scan | |
| run: | | |
| go install golang.org/x/vuln/cmd/govulncheck@latest | |
| govulncheck -show verbose ./... || true | |
| build_on_macos: | |
| runs-on: macos-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| needs: [test, lint, security] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| - name: Set version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| sed -i '' 's/version = \"dev\"/version = \"${{ github.ref_name }}\"/' cli/root.go | |
| - name: Build | |
| run: | | |
| GOARCH=arm64 go build -ldflags="-s -w" -o mobilecli-darwin-arm64 | |
| GOARCH=amd64 go build -ldflags="-s -w" -o mobilecli-darwin-amd64 | |
| ./mobilecli-darwin-arm64 --version | |
| - name: Upload macos build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: | | |
| mobilecli-darwin-arm64 | |
| mobilecli-darwin-amd64 | |
| retention-days: 1 | |
| overwrite: true | |
| build_on_linux: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| needs: [test, lint, security] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Set version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| sed -i 's/version = \"dev\"/version = \"${{ github.ref_name }}\"/' cli/root.go | |
| - name: Build | |
| run: | | |
| CGO_ENABLED=0 GOARCH=arm64 go build -ldflags="-s -w" -o mobilecli-linux-arm64 | |
| CGO_ENABLED=0 GOARCH=amd64 go build -ldflags="-s -w" -o mobilecli-linux-amd64 | |
| ./mobilecli-linux-amd64 --version | |
| - name: Upload macos build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: | | |
| mobilecli-linux-arm64 | |
| mobilecli-linux-amd64 | |
| retention-days: 1 | |
| overwrite: true | |
| build_on_windows: | |
| runs-on: windows-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: read | |
| needs: [test, lint, security] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Set version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| sed -i 's/version = \"dev\"/version = \"${{ github.ref_name }}\"/' cli/root.go | |
| - name: Build | |
| run: | | |
| go build -ldflags="-s -w" -o mobilecli-windows-amd64.exe | |
| env: | |
| GOARCH: amd64 | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: | | |
| mobilecli-windows-amd64.exe | |
| ios_simulator_test: | |
| if: false | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 10 | |
| needs: [build_on_macos] | |
| strategy: | |
| matrix: | |
| include: | |
| - ios_version: '17' | |
| runner: macos-14 | |
| - ios_version: '18' | |
| runner: macos-latest | |
| - ios_version: '26' | |
| runner: macos-latest | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download macos build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: . | |
| - name: Make mobilecli executable | |
| run: | | |
| mv mobilecli-darwin-arm64 mobilecli | |
| chmod +x mobilecli | |
| - name: Switch to Xcode ${{ matrix.xcode_version }} | |
| if: matrix.xcode_version | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: ${{ matrix.xcode_version }} | |
| - name: Launch simulator first | |
| run: | | |
| xcrun simctl list runtimes | |
| xcodebuild -runFirstLaunch | |
| - name: Run tests for iOS ${{ matrix.ios_version }} | |
| run: | | |
| cd test | |
| npm install | |
| npm run test -- --grep "iOS ${{ matrix.ios_version }}" | |
| server_test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| needs: [build_on_linux] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download linux build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: . | |
| - name: Make mobilecli executable | |
| run: | | |
| mv mobilecli-linux-amd64 mobilecli | |
| chmod +x mobilecli | |
| - name: Run server tests | |
| run: | | |
| cd test | |
| npm install | |
| npm run test -- --grep "server" | |
| android_emulator_test: | |
| if: false | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| needs: [build_on_linux] | |
| strategy: | |
| matrix: | |
| api_level: ['31', '36'] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Enable KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Setup JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - name: Set up Android SDK | |
| uses: android-actions/setup-android@v3 | |
| with: | |
| cmdline-tools-version: 11479570 | |
| - name: Install Android SDK components | |
| run: | | |
| yes | sdkmanager --licenses | |
| sdkmanager "platform-tools" "platforms;android-${{ matrix.api_level }}" | |
| sdkmanager "system-images;android-${{ matrix.api_level }};google_apis;x86_64" | |
| sdkmanager "emulator" | |
| - name: List AVD directory | |
| run: | | |
| ls -la ~/.android/avd || echo "AVD directory does not exist" | |
| - name: Download linux build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: . | |
| - name: Make mobilecli executable | |
| run: | | |
| mv mobilecli-linux-amd64 mobilecli | |
| chmod +x mobilecli | |
| - name: npm install | |
| run: | | |
| cd test | |
| npm install | |
| - name: run tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api_level }} | |
| arch: x86_64 | |
| force-avd-creation: false | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: true | |
| target: google_apis | |
| working-directory: test | |
| script: npm run test -- --grep "Android API ${{ matrix.api_level }}" | |
| # - name: Run tests for Android API ${{ matrix.api_level }} | |
| # run: | | |
| # cd test | |
| # npm install | |
| # npm run test -- --grep "Android API ${{ matrix.api_level }}" | |
| publish: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: write | |
| needs: [build_on_windows, build_on_linux, build_on_macos, server_test] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download darwin build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: mobilecli-darwin | |
| - name: Download linux build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: mobilecli-linux | |
| - name: Download windows build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: mobilecli-windows | |
| - name: Zip builds | |
| if: github.ref_type == 'tag' | |
| run: | | |
| mkdir dist | |
| cd dist | |
| # macos-arm64 | |
| cp ../mobilecli-darwin/mobilecli-darwin-arm64 mobilecli | |
| zip -9 ../mobilecli-${{ github.ref_name }}-macos-arm64.zip mobilecli | |
| rm -f mobilecli | |
| # macos-amd64 | |
| cp ../mobilecli-darwin/mobilecli-darwin-amd64 mobilecli | |
| zip -9 ../mobilecli-${{ github.ref_name }}-macos-amd64.zip mobilecli | |
| rm -f mobilecli | |
| # linux-amd64 | |
| cp ../mobilecli-linux/mobilecli-linux-amd64 mobilecli | |
| zip -9 ../mobilecli-${{ github.ref_name }}-linux-amd64.zip mobilecli | |
| rm -f mobilecli | |
| # linux-arm64 | |
| cp ../mobilecli-linux/mobilecli-linux-arm64 mobilecli | |
| zip -9 ../mobilecli-${{ github.ref_name }}-linux-arm64.zip mobilecli | |
| rm -f mobilecli | |
| # windows-amd64 | |
| cp ../mobilecli-windows/mobilecli-windows-amd64.exe mobilecli.exe | |
| zip -9 ../mobilecli-${{ github.ref_name }}-windows-amd64.zip mobilecli.exe | |
| rm -f mobilecli.exe | |
| cd .. | |
| ls -l *.zip | |
| rm -rf dist | |
| - name: Upload to GitHub Release | |
| if: github.ref_type == 'tag' | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASES_TOKEN }} | |
| with: | |
| name: Version ${{ github.ref_name }} | |
| files: | | |
| mobilecli-*.zip | |
| - name: Publish | |
| if: github.ref_type == 'tag' | |
| env: | |
| NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| run: | | |
| # prepare binaries for distribution | |
| mv ./mobilecli-darwin/mobilecli-darwin-arm64 publish/npm/bin | |
| mv ./mobilecli-darwin/mobilecli-darwin-amd64 publish/npm/bin | |
| mv ./mobilecli-linux/mobilecli-linux-amd64 publish/npm/bin | |
| mv ./mobilecli-linux/mobilecli-linux-arm64 publish/npm/bin | |
| mv ./mobilecli-windows/mobilecli-windows-amd64.exe publish/npm/bin | |
| chmod +x publish/npm/bin/* | |
| # setup npmrc | |
| echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/.npmrc | |
| # copy README.md | |
| cp README.md publish/npm | |
| # publish to npm | |
| cd publish/npm | |
| npm version "${{ github.ref_name }}" --no-git-tag-version | |
| npm install | |
| npm publish --access public | |