diff --git a/.github/workflows/publish-crate.yml b/.github/workflows/publish-crate.yml new file mode 100644 index 0000000..b6bd6bf --- /dev/null +++ b/.github/workflows/publish-crate.yml @@ -0,0 +1,18 @@ +name: Publish to crates.io + +on: + workflow_call: + inputs: + plan: + required: true + type: string + +jobs: + publish-crate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@stable + - run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 151d108..405dfb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -324,15 +324,30 @@ jobs: done git push + custom-publish-crate: + needs: + - plan + - host + if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} + uses: ./.github/workflows/publish-crate.yml + with: + plan: ${{ needs.plan.outputs.val }} + secrets: inherit + # publish jobs get escalated permissions + permissions: + "id-token": "write" + "packages": "write" + announce: needs: - plan - host - publish-homebrew-formula + - custom-publish-crate # use "always() && ..." to allow us to wait for all publish jobs while # still allowing individual publish jobs to skip themselves (for prereleases). # "host" however must run to completion, no skipping allowed! - if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }} + if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.custom-publish-crate.result == 'skipped' || needs.custom-publish-crate.result == 'success') }} runs-on: "ubuntu-22.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index fd2f7e5..5b06697 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,10 +29,17 @@ predicates = "3" inherits = "release" lto = "thin" +# Config for 'dist' [workspace.metadata.dist] +# The preferred dist version to use in CI (Cargo.toml SemVer syntax) cargo-dist-version = "0.31.0" -ci = ["github"] +# CI backends to support +ci = "github" +# The installers to generate for each app installers = ["homebrew"] +# A GitHub repo to push Homebrew formulas to tap = "hamsurang/homebrew-deepwiki-cli" -publish-jobs = ["homebrew"] +# Publish jobs to run in CI +publish-jobs = ["homebrew", "./publish-crate"] +# Target platforms to build apps for (Rust target-triple syntax) targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]