name: CI
on:
push:
branches: [master, main]
pull_request:
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install grammars
run: cargo run -- lang add markdown rust typescript python go c objc cpp java ruby lua zig bash solidity elixir swift dart
- run: cargo test
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy -- -D warnings
auto-tag:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, clippy]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Tag if version bumped
run: |
VERSION="v$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')"
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists, skipping"
else
echo "Creating tag $VERSION"
git tag "$VERSION"
git push origin "$VERSION"
fi