Skip to content

ci: Use GitHub App as bot-like account for release-please #94

ci: Use GitHub App as bot-like account for release-please

ci: Use GitHub App as bot-like account for release-please #94

Workflow file for this run

name: Main
on:
push:
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
create-github-app-token:
name: Create GitHub App token
runs-on: ubuntu-latest
outputs:
token: ${{ steps.app-token.outputs.token }}
steps:
# https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
build-test:
name: Build and test (${{ matrix.os }})
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
- name: Build
run: >
cargo build
--locked
--verbose
- name: Run tests (without coverage)
run: >
cargo test
--verbose
build-test-coverage:
name: Build and test with coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
- name: Install cargo-tarpaulin (for coverage)
# As recommened by `cargo-binstall` team:
# https://github.com/cargo-bins/cargo-binstall/tree/d5549ce99ebc82b1ceee93a41375137b7dbd1a1f#faq
uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin
- name: Install (minimal) nightly toolchain
run: rustup toolchain install --profile minimal nightly
- name: Run tests (with coverage)
# `--all-targets` does not include `--doc`
run: >
cargo tarpaulin
--out xml
--engine llvm
--all-targets
--doc
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
release-please:
name: Execute release chores
needs:
- create-github-app-token
runs-on: ubuntu-latest
outputs:
created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
# Token needs: `contents: write`, `pull-requests: write`
token: ${{ needs.create-github-app-token.outputs.token }}
release-type: rust
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs:
- release-please
- build-test
if: needs.release-please.outputs.created
environment: crates.io
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
- name: Publish
# https://doc.rust-lang.org/cargo/reference/config.html?highlight=CARGO_REGISTRY_TOKEN#credentials
run: >
cargo publish
--verbose
--locked
--no-verify
--token ${{ secrets.CARGO_REGISTRY_TOKEN }}