@@ -3,10 +3,20 @@ name: Release
33on :
44 push :
55 tags :
6- - ' v*.*.*'
7- - ' v*.*.*-*'
6+ - ' sdk-v*.*.*'
7+ - ' sdk-v*.*.*-*'
8+ - ' macros-v*.*.*'
9+ - ' macros-v*.*.*-*'
810 workflow_dispatch :
911 inputs :
12+ crate :
13+ description : ' Which crate to publish'
14+ required : true
15+ type : choice
16+ options :
17+ - aptos-sdk
18+ - aptos-sdk-macros
19+ - both
1020 dry_run :
1121 description : ' Dry run (do not actually publish)'
1222 required : false
1727 CARGO_TERM_COLOR : always
1828
1929jobs :
30+ # Determine which crates to publish based on the tag or manual input
31+ resolve :
32+ name : Resolve Crates
33+ runs-on : ubuntu-latest
34+ outputs :
35+ publish_macros : ${{ steps.resolve.outputs.publish_macros }}
36+ publish_sdk : ${{ steps.resolve.outputs.publish_sdk }}
37+ steps :
38+ - name : Resolve which crates to publish
39+ id : resolve
40+ run : |
41+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
42+ case "${{ inputs.crate }}" in
43+ aptos-sdk-macros)
44+ echo "publish_macros=true" >> "$GITHUB_OUTPUT"
45+ echo "publish_sdk=false" >> "$GITHUB_OUTPUT"
46+ ;;
47+ aptos-sdk)
48+ echo "publish_macros=false" >> "$GITHUB_OUTPUT"
49+ echo "publish_sdk=true" >> "$GITHUB_OUTPUT"
50+ ;;
51+ both)
52+ echo "publish_macros=true" >> "$GITHUB_OUTPUT"
53+ echo "publish_sdk=true" >> "$GITHUB_OUTPUT"
54+ ;;
55+ esac
56+ else
57+ TAG="${GITHUB_REF#refs/tags/}"
58+ if [[ "$TAG" == macros-v* ]]; then
59+ echo "publish_macros=true" >> "$GITHUB_OUTPUT"
60+ echo "publish_sdk=false" >> "$GITHUB_OUTPUT"
61+ elif [[ "$TAG" == sdk-v* ]]; then
62+ echo "publish_macros=false" >> "$GITHUB_OUTPUT"
63+ echo "publish_sdk=true" >> "$GITHUB_OUTPUT"
64+ fi
65+ fi
66+
2067 verify :
2168 name : Verify Release
2269 runs-on : ubuntu-latest
@@ -46,11 +93,11 @@ jobs:
4693 RUSTDOCFLAGS : -D warnings
4794 run : cargo doc --no-deps --all-features
4895
49- publish :
50- name : Publish to crates.io
96+ publish-macros :
97+ name : Publish aptos-sdk-macros
5198 runs-on : ubuntu-latest
52- needs : verify
53- if : startsWith(github.ref, 'refs/tags/v')
99+ needs : [resolve, verify]
100+ if : needs.resolve.outputs.publish_macros == 'true'
54101 steps :
55102 - uses : actions/checkout@v6
56103
@@ -62,12 +109,9 @@ jobs:
62109 - name : Cache cargo
63110 uses : Swatinem/rust-cache@v2
64111
65- - name : Verify crates can be packaged
66- run : |
67- cargo package -p aptos-sdk-macros --locked
68- cargo package -p aptos-sdk --locked
112+ - name : Verify crate can be packaged
113+ run : cargo package -p aptos-sdk-macros --locked
69114
70- # Publish macros crate first (aptos-sdk depends on it)
71115 - name : Publish aptos-sdk-macros (dry run)
72116 if : github.event_name == 'workflow_dispatch' && inputs.dry_run == true
73117 run : cargo publish -p aptos-sdk-macros --locked --dry-run
@@ -77,13 +121,36 @@ jobs:
77121 run : cargo publish -p aptos-sdk-macros --locked
78122 env :
79123 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
124+
125+ publish-sdk :
126+ name : Publish aptos-sdk
127+ runs-on : ubuntu-latest
128+ needs : [resolve, verify, publish-macros]
129+ # Run if SDK should be published, AND either macros wasn't needed or macros succeeded
130+ if : |
131+ always() &&
132+ needs.resolve.outputs.publish_sdk == 'true' &&
133+ needs.verify.result == 'success' &&
134+ (needs.publish-macros.result == 'success' || needs.publish-macros.result == 'skipped')
135+ steps :
136+ - uses : actions/checkout@v6
137+
138+ - name : Install Rust
139+ uses : dtolnay/rust-toolchain@master
140+ with :
141+ toolchain : " 1.90"
142+
143+ - name : Cache cargo
144+ uses : Swatinem/rust-cache@v2
80145
81- # Wait for crates.io to index the macros crate (120s for reliability during high load)
146+ # If macros was just published, wait for crates.io to index it
82147 - name : Wait for crates.io indexing
83- if : github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.dry_run != true)
148+ if : needs.publish-macros.result == 'success'
84149 run : sleep 120
85150
86- # Publish main SDK crate
151+ - name : Verify crate can be packaged
152+ run : cargo package -p aptos-sdk --locked
153+
87154 - name : Publish aptos-sdk (dry run)
88155 if : github.event_name == 'workflow_dispatch' && inputs.dry_run == true
89156 run : cargo publish -p aptos-sdk --locked --dry-run
@@ -97,8 +164,11 @@ jobs:
97164 release-notes :
98165 name : Create Release Notes
99166 runs-on : ubuntu-latest
100- needs : publish
101- if : startsWith(github.ref, 'refs/tags/v')
167+ needs : [resolve, publish-macros, publish-sdk]
168+ if : |
169+ always() &&
170+ github.event_name == 'push' &&
171+ (needs.publish-macros.result == 'success' || needs.publish-sdk.result == 'success')
102172 permissions :
103173 contents : write
104174 steps :
@@ -114,4 +184,3 @@ jobs:
114184 prerelease : ${{ contains(github.ref, '-') }}
115185 env :
116186 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117-
0 commit comments