diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..77466bd --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,44 @@ +name: Publish canbench crates to crates.io + +on: + workflow_dispatch: + inputs: + dryRun: + description: "Run cargo publish with --dry-run" + required: false + type: boolean + +jobs: + publish-canbench: + runs-on: ubuntu-latest + + permissions: + id-token: write # Required for OIDC token exchange + + steps: + - uses: actions/checkout@v5 + + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + + - run: echo "Preparing to cargo publish ${{ github.ref_name }}." + # Crates need to be published in this specific order + - run: cargo publish -p canbench-rs-macros ${{ inputs.dryRun == true && '--dry-run' || '' }} + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + + - run: cargo publish -p canbench-rs ${{ inputs.dryRun == true && '--dry-run' || '' }} + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + + - run: cargo publish -p canbench ${{ inputs.dryRun == true && '--dry-run' || '' }} + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + + - name: Post to a Slack channel + uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 + with: + channel-id: eng-dsm-alerts + slack-message: "${{ inputs.dryRun == true && 'DRY RUN: ' || '' }}New `canbench` crates (version `${{ github.ref_name }}`) has been published to crates.io" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }} diff --git a/development-guide.md b/development-guide.md index 252b08a..df3554e 100644 --- a/development-guide.md +++ b/development-guide.md @@ -20,11 +20,6 @@ Here's an example PR bumping the versions: https://github.com/dfinity/canbench/p ## Steps to Publish the Packages to crates.io -1. Generate an API token to use with crates.io: - Log in to crates.io with your GitHub account, go to **Account Settings**, and generate a new token under **API Tokens**. -2. Run `cargo login` in the terminal and enter your API key when prompted. -3. Check out the repo at the tag created for the release, e.g. `git checkout vX.X.X`. -4. Publish the crates in the following order: - - `cargo publish -p canbench-rs-macros` - - `cargo publish -p canbench-rs` - - `cargo publish -p canbench` +1. On the repository main page, navigate to the `Actions` tab. +2. Click on the workflow to publish to crates.io +3. Click on `run workflow` and select the version tag created above for the workflow to run on.