Update phase.rb #97
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: Homebrew Tap Validation | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "phase.rb" | |
| pull_request: | |
| paths: | |
| - "phase.rb" | |
| jobs: | |
| homebrew-tap-validation: | |
| name: Validate on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [macos-13, macos-14, macos-15] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Validate Architecture | |
| run: | | |
| arch=$(uname -m) | |
| echo "Running on architecture: $arch" | |
| if [[ "${{ matrix.os }}" == "macos-13" && "$arch" != "x86_64" ]]; then | |
| echo "Error: Expected x86_64 architecture for macOS 13" | |
| exit 1 | |
| elif [[ "${{ matrix.os }}" =~ "macos-1[45]" && "$arch" != "arm64" ]]; then | |
| echo "Error: Expected arm64 architecture for ${{ matrix.os }}" | |
| exit 1 | |
| fi | |
| - name: Install Homebrew | |
| run: | | |
| if ! command -v brew &>/dev/null; then | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| fi | |
| brew update | |
| - name: Install CLI from local formula (PRs only) | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| mkdir -p "$(brew --repo phasehq/cli)/Formula" | |
| cp ./phase.rb "$(brew --repo phasehq/cli)/Formula/phase.rb" | |
| brew install --build-from-source phasehq/cli/phase | |
| - name: Install CLI from tap (main branch only) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| brew install phasehq/cli/phase | |
| - name: Extract Expected Version | |
| id: extract-version | |
| run: | | |
| version_line=$(grep 'version' phase.rb) | |
| version=$(echo $version_line | awk -F '\"' '{print $2}') | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| - name: Test CLI Version | |
| run: | | |
| expected_version="${{ steps.extract-version.outputs.version }}" | |
| installed_version=$(phase --version) | |
| if [ "$installed_version" != "$expected_version" ]; then | |
| echo "Version mismatch: expected $expected_version, got $installed_version" | |
| exit 1 | |
| fi | |
| shell: bash |