Skip to content

Commit 754baff

Browse files
Switch to cargo-workspaces for release automation (#232)
* fix: use --no-bump flag for current version release The 'current' option was incorrectly trying to pass a version number directly to cargo release. Instead, we need to use 'cargo release release --no-bump' to publish the current version without bumping. * Switch to cargo-workspaces for release automation * Fix workflow syntax and improve test script - Use correct cargo-workspaces publish syntax - Simplify workflow to use single command for version + publish - Update test script with better instructions - Remove --from-git flag (doesn't exist in cargo-workspaces)
1 parent 06743a7 commit 754baff

File tree

8 files changed

+201
-264
lines changed

8 files changed

+201
-264
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Release with cargo-workspaces
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version bump type"
8+
type: choice
9+
options:
10+
- patch
11+
- minor
12+
- major
13+
required: true
14+
dry_run:
15+
description: "Dry run (do not publish)"
16+
type: boolean
17+
default: false
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Install Rust toolchain
32+
uses: dtolnay/rust-toolchain@stable
33+
34+
- name: Cache cargo registry and tools
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
~/.cargo/bin/
39+
~/.cargo/registry/index/
40+
~/.cargo/registry/cache/
41+
~/.cargo/git/db/
42+
key: ${{ runner.os }}-cargo-tools-${{ hashFiles('**/Cargo.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-cargo-tools-
45+
46+
- name: Install cargo-workspaces
47+
run: |
48+
if ! command -v cargo-workspaces &> /dev/null; then
49+
echo "Installing cargo-workspaces..."
50+
cargo install cargo-workspaces
51+
else
52+
echo "cargo-workspaces already installed"
53+
fi
54+
55+
- name: Configure git
56+
run: |
57+
git config user.name "github-actions[bot]"
58+
git config user.email "github-actions[bot]@users.noreply.github.com"
59+
60+
- name: Verify authentication (non-dry-run)
61+
if: ${{ !inputs.dry_run }}
62+
env:
63+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
64+
run: |
65+
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
66+
echo "::error::CARGO_REGISTRY_TOKEN is not set!"
67+
exit 1
68+
fi
69+
70+
echo "Testing crates.io authentication..."
71+
cargo login "$CARGO_REGISTRY_TOKEN"
72+
73+
# Test with dry-run on smallest package
74+
cd crates/redis-cloud
75+
if cargo publish --dry-run 2>&1; then
76+
echo "✓ Successfully authenticated to crates.io"
77+
else
78+
echo "::error::Failed to authenticate to crates.io"
79+
exit 1
80+
fi
81+
cd ../..
82+
83+
- name: Show current state
84+
run: |
85+
echo "Current versions:"
86+
for pkg in redis-cloud redis-enterprise redisctl; do
87+
version=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[] | select(.name == \"$pkg\") | .version")
88+
echo " $pkg: $version"
89+
done
90+
91+
echo ""
92+
echo "Workspace members:"
93+
cargo metadata --no-deps --format-version 1 | jq -r '.workspace_members[]'
94+
95+
- name: Dry run
96+
if: inputs.dry_run
97+
run: |
98+
echo "Dry run: Testing version bump and publish..."
99+
cargo workspaces publish --dry-run ${{ inputs.version }}
100+
echo "✓ Dry run completed successfully"
101+
102+
- name: Version bump and publish
103+
if: ${{ !inputs.dry_run }}
104+
env:
105+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
106+
run: |
107+
echo "Releasing ${{ inputs.version }} version..."
108+
109+
# This single command will:
110+
# 1. Bump versions according to the specified type
111+
# 2. Update cross-dependencies
112+
# 3. Commit the changes with git
113+
# 4. Create and push git tag
114+
# 5. Publish all crates to crates.io
115+
cargo workspaces publish \
116+
--yes \
117+
--no-verify \
118+
--allow-branch main \
119+
--force '*' \
120+
${{ inputs.version }}
121+
122+
# Get the new version that was created
123+
NEW_VERSION=$(git describe --tags --abbrev=0)
124+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
125+
126+
- name: Report success
127+
if: ${{ !inputs.dry_run && success() }}
128+
run: |
129+
echo "::notice::✅ Successfully released v$NEW_VERSION"
130+
echo ""
131+
echo "Next steps:"
132+
echo "1. The tag v$NEW_VERSION will trigger cargo-dist to build binaries"
133+
echo "2. The tag will trigger Docker workflow to build images"
134+
echo "3. Verify packages on crates.io:"
135+
echo " - https://crates.io/crates/redis-cloud"
136+
echo " - https://crates.io/crates/redis-enterprise"
137+
echo " - https://crates.io/crates/redisctl"
138+
139+
- name: Report failure
140+
if: failure()
141+
run: |
142+
echo "::error::❌ Release failed!"
143+
echo ""
144+
echo "Recovery steps:"
145+
echo "1. Check logs above for specific error"
146+
echo "2. If tag was created but publish failed:"
147+
echo " - Delete tag: git push --delete origin v[VERSION]"
148+
echo " - Delete local tag: git tag -d v[VERSION]"
149+
echo " - Yank from crates.io if partially published"
150+
echo "3. If commits were made: git reset --hard HEAD~1"

.github/workflows/manual-release.yml

Lines changed: 0 additions & 215 deletions
This file was deleted.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ homepage = "https://github.com/joshrotenberg/redisctl"
2222
documentation = "https://docs.rs/redisctl"
2323

2424
# Config for 'dist'
25-
[workspace.metadata.release]
26-
shared-version = true # Critical for synchronized releases
27-
2825
[workspace.metadata.dist]
2926
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
3027
cargo-dist-version = "0.29.0"

crates/redis-cloud/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "redis-cloud"
3-
version.workspace = true
3+
version = "0.3.2"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -12,8 +12,7 @@ keywords = ["redis", "cloud", "api", "rest", "client"]
1212
categories = ["api-bindings", "database"]
1313
readme = "../../README.md"
1414

15-
[package.metadata.release]
16-
# Use workspace configuration
15+
1716

1817
[dependencies]
1918
async-trait = { workspace = true }

0 commit comments

Comments
 (0)