feat: add a github action to test #306
Workflow file for this run
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: CLI CI/CD | |
| on: | |
| push: | |
| branches: ['main'] | |
| paths: ['src/cli/**', '.github/workflows/**'] | |
| pull_request: | |
| branches: ['main'] | |
| paths: ['src/cli/**', '.github/workflows/**'] | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.target }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: linux-amd64 | |
| asset_name: chithi-cli-linux-amd64 | |
| - os: ubuntu-24.04-arm | |
| target: linux-arm64 | |
| asset_name: chithi-cli-linux-arm64 | |
| - os: windows-latest | |
| target: windows-amd64 | |
| asset_name: chithi-cli-windows-amd64.exe | |
| - os: windows-11-arm | |
| target: windows-arm64 | |
| asset_name: chithi-cli-windows-arm64.exe | |
| - os: macos-15-intel | |
| target: macos-amd64 | |
| asset_name: chithi-cli-macos-amd64 | |
| - os: macos-latest | |
| target: macos-arm64 | |
| asset_name: chithi-cli-macos-arm64 | |
| defaults: | |
| run: | |
| working-directory: ./src/cli | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup sccache | |
| uses: mozilla-actions/sccache-action@v0.0.9 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install dependencies | |
| run: uv sync --frozen | |
| - name: Build Binary | |
| run: uv run python build.py --output ${{ matrix.asset_name }} | |
| - name: Package macOS app | |
| if: startsWith(matrix.target, 'macos') | |
| run: | | |
| APP_NAME="${{ matrix.asset_name }}.app" | |
| zip -r "${{ matrix.asset_name }}.zip" "$APP_NAME" | |
| - name: Upload CI Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: cli-${{ matrix.target }} | |
| path: | | |
| src/cli/${{ matrix.asset_name }} | |
| src/cli/${{ matrix.asset_name }}.zip | |
| if-no-files-found: error | |
| - name: Test CLI | |
| shell: bash | |
| run: | | |
| if [[ "${{ matrix.target }}" == macos* ]]; then | |
| ./${{ matrix.asset_name }}.app/Contents/MacOS/${{ matrix.asset_name }} --help || { echo 'CLI failed'; exit 1; } | |
| else | |
| chmod +x ./${{ matrix.asset_name }} || true | |
| ./${{ matrix.asset_name }} --help || { echo 'CLI failed'; exit 1; } | |
| fi | |
| - name: Upload to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| src/cli/${{ matrix.asset_name }} | |
| src/cli/${{ matrix.asset_name }}.zip |