From e5b119d4589497c3acd992e9814bd83be163a57a Mon Sep 17 00:00:00 2001 From: David Derler Date: Mon, 22 Dec 2025 14:32:56 +0100 Subject: [PATCH 01/10] . --- .github/workflows/publish.yml | 39 +++++++++++++++++++++++++++++++++++ Cargo.toml | 3 ++- RELEASE_GUIDE.md | 26 ++--------------------- 3 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..e146ad78 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +name: Publish stable-structures to crates.io + +on: + push: + tags: + - "v*" + +jobs: + publish-ic-stable-structures: + 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 + + - name: Set Cargo.toml versions + shell: bash + env: + RELEASE_TAG: ${{ github.ref }} + run: | + sed -i -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" Cargo.toml + + - run: cargo publish -p ic-stable-structures + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + + - name: Post to a Slack channel + uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 + with: + method: chat.postMessage + token: ${{ secrets.SLACK_API_TOKEN }} + payload: | + channel: eng-dsm-alerts + text: "New `stable-structures` crate (version `${{ github.ref_name }}`) has been published to crates.io" diff --git a/Cargo.toml b/Cargo.toml index 173b20e6..ceecc219 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,8 @@ license = "Apache-2.0" name = "ic-stable-structures" readme = "README.md" repository = "https://github.com/dfinity/stable-structures" -version = "0.7.2" +# Version is set by a Github workflow from the git tag +version = "0.0.0-git" [package.metadata.docs.rs] # Build docs for wasm32-unknown-unknown target diff --git a/RELEASE_GUIDE.md b/RELEASE_GUIDE.md index e9e187e7..4c3b1017 100644 --- a/RELEASE_GUIDE.md +++ b/RELEASE_GUIDE.md @@ -71,7 +71,7 @@ Adding a `reclaim()` method to free unused memory without changing layout, only 2. Ensure CI is green. 3. Preferable commit & PR name: `chore(release): vX.Y.Z` ([example PR](https://github.com/dfinity/stable-structures/pull/379)). -### Publish Release to GitHub +### Publish Release to GitHub and crates.io 1. Identify the commit to release. 2. Draft a new release: @@ -81,29 +81,7 @@ Adding a `reclaim()` method to free unused memory without changing layout, only - Set the release title to `vX.Y.Z`. - Choose the previous tag as the last release. - Add release notes (GitHub can auto-generate, adjust as needed). -3. Click **Publish release**. - -### Publish to crates.io - -1. Generate an API token: - - Log in to crates.io → **Account Settings** → **API Tokens** → generate a new token. -2. Authenticate: - ```bash - cargo login - ``` - Enter the token when prompted. -3. Check out the repo at the release tag: - ```bash - git checkout vX.Y.Z - ``` -4. Dry-run publish (mandatory): - ```bash - cargo publish -p ic-stable-structures --dry-run - ``` -5. Publish: - ```bash - cargo publish -p ic-stable-structures - ``` +3. Click **Publish release**, which will also trigger publication to crates.io ### Verify From bbdb0a062ba0fc13b22cda9cc457455e86d9ed29 Mon Sep 17 00:00:00 2001 From: David Derler Date: Tue, 23 Dec 2025 09:11:50 +0100 Subject: [PATCH 02/10] . --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e146ad78..d51d2963 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,7 +23,7 @@ jobs: env: RELEASE_TAG: ${{ github.ref }} run: | - sed -i -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" Cargo.toml + sed -i '' -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" Cargo.toml - run: cargo publish -p ic-stable-structures env: From 0f6ef6f2c6b79f0a6ee777903bffe153d5a6669d Mon Sep 17 00:00:00 2001 From: David Derler Date: Tue, 23 Dec 2025 10:22:19 +0100 Subject: [PATCH 03/10] Allow dirty working directory because of sed changes --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d51d2963..b3efb446 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,7 +25,7 @@ jobs: run: | sed -i '' -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" Cargo.toml - - run: cargo publish -p ic-stable-structures + - run: cargo publish -p ic-stable-structures --allow-dirty env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} From 153b072c235958becc80be975404e50f913448bb Mon Sep 17 00:00:00 2001 From: David Derler Date: Tue, 23 Dec 2025 11:16:32 +0100 Subject: [PATCH 04/10] . --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 28b19794..043a14ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -302,7 +302,7 @@ dependencies = [ [[package]] name = "ic-stable-structures" -version = "0.7.2" +version = "0.0.0-git" dependencies = [ "canbench-rs", "candid", From 5c12f98c6cd2bd11c968c7f1abe0c97ecf2b45d5 Mon Sep 17 00:00:00 2001 From: David Derler Date: Tue, 23 Dec 2025 11:36:37 +0100 Subject: [PATCH 05/10] . --- examples/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 0da477b5..e21af14e 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -285,7 +285,7 @@ dependencies = [ [[package]] name = "ic-stable-structures" -version = "0.7.2" +version = "0.0.0-git" dependencies = [ "ic_principal", ] From be3f7a6c5b049e6692ea9c1fc5f90c10de8933cb Mon Sep 17 00:00:00 2001 From: David Derler Date: Mon, 12 Jan 2026 13:17:39 +0100 Subject: [PATCH 06/10] Switch to manually triggering of workflow --- .github/workflows/publish.yml | 11 +---------- Cargo.lock | 2 +- Cargo.toml | 3 +-- RELEASE_GUIDE.md | 26 ++++++++++++++++++++++++-- examples/Cargo.lock | 2 +- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b3efb446..d83122e4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,7 @@ name: Publish stable-structures to crates.io on: - push: - tags: - - "v*" + workflow_dispatch: jobs: publish-ic-stable-structures: @@ -18,13 +16,6 @@ jobs: - uses: rust-lang/crates-io-auth-action@v1 id: auth - - name: Set Cargo.toml versions - shell: bash - env: - RELEASE_TAG: ${{ github.ref }} - run: | - sed -i '' -e "s/0\\.0\\.0-git/${RELEASE_TAG##*\/v}/" Cargo.toml - - run: cargo publish -p ic-stable-structures --allow-dirty env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} diff --git a/Cargo.lock b/Cargo.lock index 043a14ee..28b19794 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -302,7 +302,7 @@ dependencies = [ [[package]] name = "ic-stable-structures" -version = "0.0.0-git" +version = "0.7.2" dependencies = [ "canbench-rs", "candid", diff --git a/Cargo.toml b/Cargo.toml index ceecc219..173b20e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,7 @@ license = "Apache-2.0" name = "ic-stable-structures" readme = "README.md" repository = "https://github.com/dfinity/stable-structures" -# Version is set by a Github workflow from the git tag -version = "0.0.0-git" +version = "0.7.2" [package.metadata.docs.rs] # Build docs for wasm32-unknown-unknown target diff --git a/RELEASE_GUIDE.md b/RELEASE_GUIDE.md index 4c3b1017..e9e187e7 100644 --- a/RELEASE_GUIDE.md +++ b/RELEASE_GUIDE.md @@ -71,7 +71,7 @@ Adding a `reclaim()` method to free unused memory without changing layout, only 2. Ensure CI is green. 3. Preferable commit & PR name: `chore(release): vX.Y.Z` ([example PR](https://github.com/dfinity/stable-structures/pull/379)). -### Publish Release to GitHub and crates.io +### Publish Release to GitHub 1. Identify the commit to release. 2. Draft a new release: @@ -81,7 +81,29 @@ Adding a `reclaim()` method to free unused memory without changing layout, only - Set the release title to `vX.Y.Z`. - Choose the previous tag as the last release. - Add release notes (GitHub can auto-generate, adjust as needed). -3. Click **Publish release**, which will also trigger publication to crates.io +3. Click **Publish release**. + +### Publish to crates.io + +1. Generate an API token: + - Log in to crates.io → **Account Settings** → **API Tokens** → generate a new token. +2. Authenticate: + ```bash + cargo login + ``` + Enter the token when prompted. +3. Check out the repo at the release tag: + ```bash + git checkout vX.Y.Z + ``` +4. Dry-run publish (mandatory): + ```bash + cargo publish -p ic-stable-structures --dry-run + ``` +5. Publish: + ```bash + cargo publish -p ic-stable-structures + ``` ### Verify diff --git a/examples/Cargo.lock b/examples/Cargo.lock index e21af14e..0da477b5 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -285,7 +285,7 @@ dependencies = [ [[package]] name = "ic-stable-structures" -version = "0.0.0-git" +version = "0.7.2" dependencies = [ "ic_principal", ] From eb0c604fc819e19b0fe53617a3b00470c1e34f12 Mon Sep 17 00:00:00 2001 From: David Derler Date: Mon, 12 Jan 2026 13:21:11 +0100 Subject: [PATCH 07/10] Drop --allow-dirty flag --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d83122e4..503b57ef 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: - uses: rust-lang/crates-io-auth-action@v1 id: auth - - run: cargo publish -p ic-stable-structures --allow-dirty + - run: cargo publish -p ic-stable-structures env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} From 5ef9152eea708fff548cb286ce30f5db5e06957b Mon Sep 17 00:00:00 2001 From: David Derler Date: Mon, 12 Jan 2026 13:51:02 +0100 Subject: [PATCH 08/10] . --- RELEASE_GUIDE.md | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/RELEASE_GUIDE.md b/RELEASE_GUIDE.md index e9e187e7..7a9277e6 100644 --- a/RELEASE_GUIDE.md +++ b/RELEASE_GUIDE.md @@ -85,25 +85,9 @@ Adding a `reclaim()` method to free unused memory without changing layout, only ### Publish to crates.io -1. Generate an API token: - - Log in to crates.io → **Account Settings** → **API Tokens** → generate a new token. -2. Authenticate: - ```bash - cargo login - ``` - Enter the token when prompted. -3. Check out the repo at the release tag: - ```bash - git checkout vX.Y.Z - ``` -4. Dry-run publish (mandatory): - ```bash - cargo publish -p ic-stable-structures --dry-run - ``` -5. Publish: - ```bash - cargo publish -p ic-stable-structures - ``` +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. ### Verify From 9bda02cf1d7d505f4f7d0069ce7c9da85c84d412 Mon Sep 17 00:00:00 2001 From: David Derler Date: Mon, 12 Jan 2026 15:21:48 +0000 Subject: [PATCH 09/10] Add dry run option --- .github/workflows/publish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 503b57ef..9eafe5af 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,6 +2,11 @@ name: Publish stable-structures to crates.io on: workflow_dispatch: + inputs: + dryRun: + description: "If true, runs cargo publish with --dry-run" + required: false + type: boolean jobs: publish-ic-stable-structures: @@ -16,7 +21,7 @@ jobs: - uses: rust-lang/crates-io-auth-action@v1 id: auth - - run: cargo publish -p ic-stable-structures + - run: cargo publish -p ic-stable-structures ${{ inputs.dryRun == true && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} @@ -27,4 +32,4 @@ jobs: token: ${{ secrets.SLACK_API_TOKEN }} payload: | channel: eng-dsm-alerts - text: "New `stable-structures` crate (version `${{ github.ref_name }}`) has been published to crates.io" + text: "${{ inputs.dryRun == true && 'DRY RUN: ' || '' }}New `stable-structures` crate (version `${{ github.ref_name }}`) has been published to crates.io" From 492e7550ce8f65d9567d8527c5fccc3fb774e8d6 Mon Sep 17 00:00:00 2001 From: David Derler Date: Mon, 12 Jan 2026 15:56:13 +0000 Subject: [PATCH 10/10] Reviewer comments --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9eafe5af..938a2379 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,8 @@ jobs: - uses: rust-lang/crates-io-auth-action@v1 id: auth + - run: echo "Preparing to cargo publish ${{ github.ref_name }}." + - run: cargo publish -p ic-stable-structures ${{ inputs.dryRun == true && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}