ci: fix permissions issues #111
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: Tag | ||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| RUST_BACKTRACE: 1 | ||
| RUSTDOCFLAGS: '--deny warnings' | ||
| MINIMUM_SUPPORTED_RUST_VERSION: 1.85.0 | ||
| RUST_CHANNEL: stable | ||
| permissions: | ||
| contents: write | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - CHANGELOG.md | ||
| jobs: | ||
| tag: | ||
| runs-on: ubuntu-latest | ||
| if: github.ref == 'refs/heads/main' | ||
| outputs: | ||
| created: ${{ steps.tag.outputs.created }} | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | ||
| with: | ||
| persist-credentials: false | ||
| - name: Get tags | ||
| run: git fetch --tags origin | ||
| - name: Install Rust | ||
| run: | | ||
| rustup update --no-self-update ${RUST_CHANNEL} | ||
| rustup component add --toolchain ${RUST_CHANNEL} cargo | ||
| rustup default ${RUST_CHANNEL} | ||
| env: | ||
| RUST_CHANNEL: ${{ env.RUST_CHANNEL }} | ||
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 | ||
| - name: Configure git | ||
| run: | | ||
| git config --global user.name "${ACTOR}" | ||
| git config --global user.email "${ACTOR_ID}+${ACTOR}@users.noreply.github.com" | ||
| git config --global push.autoSetupRemote true | ||
| env: | ||
| ACTOR: ${{ github.actor }} | ||
| ACTOR_ID: ${{ github.actor_id }} | ||
| - name: Get the version | ||
| id: current | ||
| run: echo "version=$(cargo pkgid --manifest-path crates/bin/Cargo.toml | cut -d '@' -f2)" >> "$GITHUB_OUTPUT" | ||
| - name: Create git tag | ||
| id: tag | ||
| run: | | ||
| if git tag -a "v${VERSION}" -m "${VERSION}"; then | ||
| echo "created=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "::notice title=Git tag:: The version ${VERSION} already exists. The \`publish\` workflow won't be executed." | ||
| echo "created=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| env: | ||
| VERSION: ${{ steps.current.outputs.version }} | ||
| publish: | ||
| needs: tag | ||
| if: ${{ needs.tag.outputs.created == 'true' }} | ||
| uses: ./.github/workflows/publish.yml | ||
| permissions: | ||
| contents: write | ||
| actions: write | ||
| packages: write | ||
| attestations: write | ||
| id-token: write | ||
| pull-requests: write | ||
| secrets: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||