| name: publish-libs | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - "lib/**" | |
| jobs: | |
| publish-libs: | |
| if: ${{ github.repository == 'rust-lang/rust-analyzer' || github.event_name == 'workflow_dispatch' }} | |
| name: publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| environment: publish-libs | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Rust toolchain | |
| run: rustup update --no-self-update stable | |
| - name: Install cargo-workspaces | |
| run: cargo install --locked cargo-workspaces --version "0.3.6" | |
| - uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 | |
| id: auth | |
| - name: Publish Crates | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | |
| shell: bash | |
| run: | | |
| git config --global user.email "runner@gha.local" | |
| git config --global user.name "GitHub Action" | |
| # Only publish the crates under lib/ | |
| sed -i 's|^members = .*$|members = ["lib/*"]|' Cargo.toml | |
| cargo workspaces publish --yes --exact --from-git --no-git-commit --allow-dirty |