Skip to content
Draft
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
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 --allow-dirty
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"
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 2 additions & 24 deletions RELEASE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.