Skip to content

Commit 3bcfd49

Browse files
authored
Merge pull request #3 from AElfProject/codex/wasm32-wasip2-alpha1
fix(ci): 🩹 automate tag releases and harden public smoke parsing
2 parents 8a67c81 + 8e73364 commit 3bcfd49

File tree

5 files changed

+326
-160
lines changed

5 files changed

+326
-160
lines changed

.github/workflows/publish.yml

Lines changed: 67 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: publish
22

33
on:
4+
push:
5+
tags:
6+
- "v*"
47
workflow_dispatch:
58
inputs:
69
dry_run:
@@ -23,172 +26,79 @@ permissions:
2326
contents: read
2427

2528
jobs:
26-
publish:
29+
release-preflight:
30+
if: github.event_name == 'push'
2731
runs-on: ubuntu-latest
2832
steps:
2933
- uses: actions/checkout@v4
3034
- uses: dtolnay/rust-toolchain@stable
35+
with:
36+
targets: wasm32-wasip2
3137
- uses: Swatinem/rust-cache@v2
32-
- name: publish crates
33-
env:
34-
DRY_RUN: ${{ inputs.dry_run }}
35-
SELECTED_PACKAGES: ${{ inputs.packages }}
36-
SKIP_PUBLISHED: ${{ inputs.skip_published }}
37-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
38+
- name: validate tag matches workspace version
3839
run: |
3940
set -euo pipefail
40-
41-
ordered_packages=(
42-
aelf-proto
43-
aelf-crypto
44-
aelf-client
45-
aelf-keystore
46-
aelf-contract
47-
aelf-sdk
48-
)
49-
50-
declare -A allowed_packages=()
51-
declare -A requested_packages=()
52-
53-
for pkg in "${ordered_packages[@]}"; do
54-
allowed_packages["$pkg"]=1
55-
done
56-
57-
if [[ -n "${SELECTED_PACKAGES//[[:space:]]/}" ]]; then
58-
IFS=',' read -r -a raw_packages <<< "$SELECTED_PACKAGES"
59-
for raw_pkg in "${raw_packages[@]}"; do
60-
pkg="${raw_pkg//[[:space:]]/}"
61-
if [[ -z "$pkg" ]]; then
62-
continue
63-
fi
64-
if [[ -z "${allowed_packages[$pkg]:-}" ]]; then
65-
echo "::error::Unsupported package '$pkg'. Allowed packages: ${ordered_packages[*]}"
66-
exit 1
67-
fi
68-
requested_packages["$pkg"]=1
69-
done
70-
71-
if [[ "${#requested_packages[@]}" -eq 0 ]]; then
72-
echo "::error::No valid packages were provided."
73-
exit 1
74-
fi
41+
tag_version="${GITHUB_REF_NAME#v}"
42+
pkgid="$(cargo pkgid -p aelf-sdk)"
43+
workspace_version="${pkgid##*@}"
44+
if [[ "$workspace_version" == "$pkgid" ]]; then
45+
workspace_version="${pkgid##*#}"
7546
fi
7647
77-
package_selected() {
78-
local pkg="$1"
79-
if [[ "${#requested_packages[@]}" -eq 0 ]]; then
80-
return 0
81-
fi
82-
[[ -n "${requested_packages[$pkg]:-}" ]]
83-
}
84-
85-
crate_version() {
86-
local pkgid
87-
local version
88-
89-
pkgid="$(cargo pkgid -p "$1")"
90-
version="${pkgid##*@}"
91-
if [[ "$version" == "$pkgid" ]]; then
92-
version="${pkgid##*#}"
93-
fi
94-
echo "$version"
95-
}
96-
97-
crate_registry_state() {
98-
local pkg="$1"
99-
local version="$2"
100-
local output
101-
local cmd_status
102-
103-
set +e
104-
output="$(cargo info "${pkg}@${version}" --registry crates-io 2>&1)"
105-
cmd_status=$?
106-
set -e
107-
108-
if [[ "$cmd_status" -eq 0 ]]; then
109-
echo "present"
110-
return 0
111-
fi
112-
113-
if grep -qi "could not find" <<< "$output"; then
114-
echo "missing"
115-
return 0
116-
fi
117-
118-
echo "::error::Failed to query crates.io index for ${pkg} ${version}: ${output}" >&2
119-
return 1
120-
}
121-
122-
ensure_crate_visible() {
123-
local pkg="$1"
124-
local version="$2"
125-
local max_attempts=30
126-
local sleep_seconds=10
127-
128-
for ((attempt = 1; attempt <= max_attempts; attempt++)); do
129-
state="$(crate_registry_state "$pkg" "$version")"
130-
case "$state" in
131-
present)
132-
echo "${pkg} ${version} is visible on crates.io."
133-
return 0
134-
;;
135-
missing)
136-
echo "Waiting for ${pkg} ${version} to become visible on crates.io (${attempt}/${max_attempts})..."
137-
sleep "$sleep_seconds"
138-
;;
139-
*)
140-
echo "::error::Unexpected crates.io registry state '${state}' while checking ${pkg} ${version}."
141-
return 1
142-
;;
143-
esac
144-
done
145-
146-
echo "::error::Timed out waiting for ${pkg} ${version} to become visible on crates.io."
147-
return 1
148-
}
149-
150-
if [[ "$DRY_RUN" != "true" && -z "${CARGO_REGISTRY_TOKEN:-}" ]]; then
151-
echo "::error::CARGO_REGISTRY_TOKEN is required when dry_run=false."
48+
if [[ "$tag_version" != "$workspace_version" ]]; then
49+
echo "::error::Tag version ${tag_version} does not match workspace version ${workspace_version}."
15250
exit 1
15351
fi
52+
- name: install cargo-audit
53+
run: cargo install cargo-audit --locked
54+
- name: fmt
55+
run: cargo fmt --all -- --check
56+
- name: msrv
57+
run: cargo +1.85.0 check --workspace --all-targets --all-features --locked
58+
- name: clippy
59+
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
60+
- name: audit
61+
run: cargo audit
62+
- name: examples
63+
run: cargo check --workspace --examples
64+
- name: wasm aelf-client
65+
run: cargo check -p aelf-client --target wasm32-wasip2 --no-default-features
66+
- name: wasm aelf-contract
67+
run: cargo check -p aelf-contract --target wasm32-wasip2 --no-default-features
68+
- name: wasm aelf-sdk
69+
run: cargo check -p aelf-sdk --target wasm32-wasip2 --no-default-features
70+
- name: test
71+
run: cargo test --workspace
72+
- name: public readonly smoke
73+
run: cargo test -p aelf-sdk --test public_readonly_smoke -- --ignored --test-threads=1 --nocapture
74+
75+
tag-publish:
76+
if: github.event_name == 'push'
77+
runs-on: ubuntu-latest
78+
needs: release-preflight
79+
steps:
80+
- uses: actions/checkout@v4
81+
- uses: dtolnay/rust-toolchain@stable
82+
- uses: Swatinem/rust-cache@v2
83+
- name: publish crates
84+
env:
85+
DRY_RUN: "false"
86+
SELECTED_PACKAGES: ""
87+
SKIP_PUBLISHED: "true"
88+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
89+
run: ./scripts/publish-crates.sh
15490

155-
if [[ "$DRY_RUN" == "true" && "${#requested_packages[@]}" -eq 0 ]]; then
156-
echo "Running workspace dry-run for the full publish set."
157-
cargo publish --workspace --dry-run --locked
158-
exit 0
159-
fi
160-
161-
for pkg in "${ordered_packages[@]}"; do
162-
if ! package_selected "$pkg"; then
163-
continue
164-
fi
165-
166-
version="$(crate_version "$pkg")"
167-
echo "Processing ${pkg} ${version}"
168-
169-
if [[ "$DRY_RUN" == "true" ]]; then
170-
cargo publish -p "$pkg" --dry-run --locked
171-
continue
172-
fi
173-
174-
state="$(crate_registry_state "$pkg" "$version")"
175-
case "$state" in
176-
present)
177-
if [[ "$SKIP_PUBLISHED" == "true" ]]; then
178-
echo "Skipping ${pkg} ${version}; version already exists on crates.io."
179-
continue
180-
fi
181-
echo "::error::${pkg} ${version} already exists on crates.io."
182-
exit 1
183-
;;
184-
missing)
185-
;;
186-
*)
187-
echo "::error::Unexpected crates.io registry state '${state}' while checking ${pkg} ${version}."
188-
exit 1
189-
;;
190-
esac
191-
192-
cargo publish -p "$pkg" --locked --token "$CARGO_REGISTRY_TOKEN"
193-
ensure_crate_visible "$pkg" "$version"
194-
done
91+
manual-publish:
92+
if: github.event_name == 'workflow_dispatch'
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: dtolnay/rust-toolchain@stable
97+
- uses: Swatinem/rust-cache@v2
98+
- name: publish crates
99+
env:
100+
DRY_RUN: ${{ inputs.dry_run }}
101+
SELECTED_PACKAGES: ${{ inputs.packages }}
102+
SKIP_PUBLISHED: ${{ inputs.skip_published }}
103+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
104+
run: ./scripts/publish-crates.sh

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht
2828
- The facade crate now exposes the transport abstraction needed by native-wasm skill runtimes
2929
- `send_transaction` no longer treats arbitrary non-empty text payloads as success
3030
- typed contract wrappers now lazily reuse the first descriptor per handle, while direct `contract_at(...)` calls still fetch a fresh descriptor for each new handle
31+
- `ChainStatusDto` now accepts both public-node branch map shapes, preventing readonly smoke failures behind mixed main-chain gateway backends
3132

3233
## [0.1.0-alpha.0] - 2026-03-10
3334

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ cargo test -p aelf-sdk --test public_readonly_smoke -- --ignored --test-threads=
5555
- Keep the documented MSRV at Rust `1.85` and preserve the hard `cargo +1.85.0 check --workspace --all-targets --all-features --locked` CI gate.
5656
- Preserve the `wasm32-wasip2` compile gates for `aelf-client`, `aelf-contract`, and `aelf-sdk` when changing transport or feature-flag behavior.
5757

58+
## Release Flow
59+
60+
- Push a tag such as `v0.1.0-alpha.1` to trigger the automated release flow.
61+
- The tag workflow runs release preflight checks first, then publishes the workspace crates in dependency order.
62+
- If a publish run partially succeeds, rerun the `publish` workflow manually with `packages="aelf-contract,aelf-sdk"`-style inputs and keep `skip_published=true`.
63+
5864
## Commit Style
5965

6066
Use Conventional Commit / `git-cz` style messages in English and keep the matching emoji prefix used by the repository workflow.

0 commit comments

Comments
 (0)