Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Publish to crates.io

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
release: ${{ steps.detect.outputs.release }}
version: ${{ steps.detect.outputs.version }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Install Bake launcher
run: cargo install socketry-cargo-bake --locked
- name: Detect a versioned release change
id: detect
env:
BAKE_BEFORE: ${{ github.event.pull_request.base.sha || github.event.before }}
BAKE_SHA: ${{ github.sha }}
run: cargo bake --locked cargo:release:detect --base "$BAKE_BEFORE" --sha "$BAKE_SHA"
- name: Validate release candidate
if: steps.detect.outputs.release == 'true'
run: cargo bake --locked cargo:release
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run Clippy
run: cargo clippy --workspace --all-targets --locked -- -D warnings
- name: Run tests
run: cargo test --workspace --locked

publish:
needs: check
if: github.event_name == 'push' && needs.check.outputs.release == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
environment: crates-io
concurrency: release-${{ github.ref }}
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Install Bake launcher
run: cargo install socketry-cargo-bake --locked
- name: Find workspace packages that need publishing
id: packages
env:
BAKE_VERSION: ${{ needs.check.outputs.version }}
run: cargo bake --locked cargo:publish:pending --version "$BAKE_VERSION"
- uses: rust-lang/crates-io-auth-action@v1
id: auth
if: steps.packages.outputs.has_packages == 'true'
- name: Publish workspace and create GitHub Release
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
GH_TOKEN: ${{ github.token }}
BAKE_VERSION: ${{ needs.check.outputs.version }}
BAKE_SHA: ${{ github.sha }}
run: cargo bake --locked cargo:release:publish --version "$BAKE_VERSION" --sha "$BAKE_SHA"
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
- uses: actions-rust-lang/setup-rust-toolchain@v2
with:
components: clippy, llvm-tools-preview, rustfmt
cache-shared-key: coverage-cargo-install-v1
- name: Install Bake launcher
run: cargo install socketry-cargo-bake --locked
- name: Install coverage tool
run: cargo install cargo-llvm-cov --locked
- run: cargo fmt --all -- --check
- run: cargo clippy --workspace --all-targets --locked -- -D warnings
- name: Run tests and require complete region coverage
run: cargo bake --locked test:coverage --package bake-markdown --all-targets true --all-features true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
Loading
Loading