fix: disable spinner animation when stdout is not a TTY #200
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: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| if: "!startsWith(github.ref, 'refs/tags/v')" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Install dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libxdo-dev | |
| - name: Check formatting | |
| run: cargo fmt --check | |
| - name: Clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| test: | |
| name: Test (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| if: "!startsWith(github.ref, 'refs/tags/v')" | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get update && sudo apt-get install -y libxdo-dev | |
| - name: Run tests | |
| run: cargo test --all-features --verbose | |
| - name: Run tests (release) | |
| run: cargo test --release --all-features | |
| security: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| if: "!startsWith(github.ref, 'refs/tags/v')" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit | |
| - name: Security audit | |
| run: cargo audit | |
| validate-tag: | |
| name: Validate Tag | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check tag is on main | |
| run: | | |
| TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }}) | |
| echo "Tag commit: $TAG_COMMIT" | |
| if git branch -r --contains "$TAG_COMMIT" | grep -q 'origin/main'; then | |
| echo "✓ Tag commit is on main branch" | |
| else | |
| echo "❌ Tag commit is NOT on main branch" | |
| echo "Tags must only be created from commits that are on main." | |
| exit 1 | |
| fi | |
| build: | |
| name: Build (${{ matrix.target }}) | |
| runs-on: ${{ matrix.os }} | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [validate-tag] | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| artifact: ask-linux-x86_64 | |
| cross: true | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-musl | |
| artifact: ask-linux-aarch64 | |
| cross: true | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact: ask-macos-x86_64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact: ask-macos-aarch64 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact: ask-windows-x86_64.exe | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' && !matrix.cross | |
| run: sudo apt-get update && sudo apt-get install -y libxdo-dev | |
| - name: Install cross | |
| if: matrix.cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build (native) | |
| if: "!matrix.cross" | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Build (cross) | |
| if: matrix.cross | |
| run: cross build --release --target ${{ matrix.target }} | |
| - name: Prepare artifact (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cp target/${{ matrix.target }}/release/ask ${{ matrix.artifact }} | |
| chmod +x ${{ matrix.artifact }} | |
| sha256sum ${{ matrix.artifact }} > ${{ matrix.artifact }}.sha256 | |
| - name: Prepare artifact (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| Copy-Item "target/${{ matrix.target }}/release/ask.exe" "${{ matrix.artifact }}" | |
| (Get-FileHash "${{ matrix.artifact }}" -Algorithm SHA256).Hash.ToLower() + " ${{ matrix.artifact }}" | Out-File -Encoding ASCII "${{ matrix.artifact }}.sha256" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: | | |
| ${{ matrix.artifact }} | |
| ${{ matrix.artifact }}.sha256 | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release files | |
| run: | | |
| mkdir -p release | |
| for dir in artifacts/*/; do | |
| cp "$dir"* release/ | |
| done | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: ${{ contains(github.ref, '-') }} |