|
| 1 | +name: Publish simplicityhl-lsp |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'simplicityhl-lsp-v*' |
| 7 | + workflow_dispatch: {} |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +jobs: |
| 12 | + lint: |
| 13 | + name: Lint (lsp) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Setup Rust (stable) |
| 20 | + uses: dtolnay/rust-toolchain@stable |
| 21 | + with: |
| 22 | + components: clippy, rustfmt |
| 23 | + |
| 24 | + - name: Rustfmt check |
| 25 | + working-directory: lsp |
| 26 | + run: cargo fmt --all -- --check |
| 27 | + |
| 28 | + - name: Clippy |
| 29 | + working-directory: lsp |
| 30 | + run: cargo clippy --all-targets --all-features -D warnings |
| 31 | + |
| 32 | + tests: |
| 33 | + name: Tests (lsp) |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Setup Rust (stable) |
| 40 | + uses: dtolnay/rust-toolchain@stable |
| 41 | + |
| 42 | + - name: Run tests |
| 43 | + working-directory: lsp |
| 44 | + run: cargo test --all-features -- --nocapture |
| 45 | + |
| 46 | + publish: |
| 47 | + name: Publish simplicityhl-lsp to crates.io |
| 48 | + needs: [lint, tests] |
| 49 | + runs-on: ubuntu-latest |
| 50 | + environment: release |
| 51 | + concurrency: |
| 52 | + group: publish-lsp-${{ github.ref }} |
| 53 | + cancel-in-progress: false |
| 54 | + permissions: |
| 55 | + id-token: write |
| 56 | + contents: read |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Setup Rust (stable) |
| 63 | + uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 64 | + with: |
| 65 | + toolchain: stable |
| 66 | + |
| 67 | + - name: Verify tag matches crate version |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + set -euo pipefail |
| 71 | + TAG="${GITHUB_REF##*/}" |
| 72 | + VERSION_TAG="${TAG#simplicityhl-lsp-v}" |
| 73 | + CRATE_VERSION=$(cargo metadata --manifest-path lsp/Cargo.toml --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="simplicityhl-lsp").version') |
| 74 | + echo "Tag version: $VERSION_TAG" |
| 75 | + echo "Crate version: $CRATE_VERSION" |
| 76 | + if [ "$VERSION_TAG" != "$CRATE_VERSION" ]; then |
| 77 | + echo "Tag version ($VERSION_TAG) does not match crate version ($CRATE_VERSION)" |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Check package |
| 82 | + working-directory: lsp |
| 83 | + run: cargo package |
| 84 | + |
| 85 | + - name: Authenticate with crates.io |
| 86 | + id: auth |
| 87 | + uses: rust-lang/crates-io-auth-action@v1 |
| 88 | + |
| 89 | + - name: Publish |
| 90 | + env: |
| 91 | + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |
| 92 | + working-directory: lsp |
| 93 | + run: cargo publish |
| 94 | + |
| 95 | + |
0 commit comments