Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/actions/rust-ci-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ runs:

- name: Cache cargo artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: "sof-shared-cache"

- name: Install cargo tools
uses: taiki-e/install-action@v2
Expand Down
58 changes: 37 additions & 21 deletions .github/workflows/release-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ jobs:
- name: Setup Rust CI toolchain and tools
uses: ./.github/actions/rust-ci-setup

- name: Verify tag matches crate version
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"
crate_version="$(cargo pkgid -p sof | sed -E 's/.*@(.+)$/\1/')"
if [[ -z "${crate_version}" ]]; then
echo "Could not resolve crate version for package sof"
exit 1
fi
if [[ "${tag_version}" != "${crate_version}" ]]; then
echo "Tag version (${tag_version}) does not match crate version (${crate_version})"
exit 1
fi

- name: Verify tagged commit is on main
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
shell: bash
Expand All @@ -56,11 +40,43 @@ jobs:
- name: Run full CI matrix before publish
run: cargo make ci

- name: Dry-run publish
run: cargo publish -p sof --locked --dry-run

- name: Publish to crates.io
- name: Verify and Publish crates
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish -p sof --locked
shell: bash
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"
published_count=0

# Define crates in dependency order
crates=("sof" "sof-tx")

for pkg in "${crates[@]}"; do
crate_version="$(cargo pkgid -p "$pkg" | sed -E 's/.*@(.+)$/\1/')"

if [[ "${crate_version}" == "${tag_version}" ]]; then
echo ">>> Target matches: $pkg v${crate_version}. Dry-running..."
cargo publish -p "$pkg" --locked --dry-run

echo ">>> Publishing $pkg v${crate_version} to crates.io..."
cargo publish -p "$pkg" --locked

published_count=$((published_count + 1))

# If we just published the core crate and there are more to go,
# sleep to allow crates.io indexing
if [[ "$pkg" == "sof" ]]; then
echo "Waiting for crates.io indexing..."
sleep 30
fi
else
echo ">>> Skipping $pkg: version (${crate_version}) does not match tag (${tag_version})"
fi
done

if [[ $published_count -eq 0 ]]; then
echo "Error: No crates found with version matching tag ${tag_version}"
exit 1
fi
6 changes: 4 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ description = "Build all projects"
workspace = false
command = "cargo"
args = ["build", "--all-features", "${@}"]
dependencies = ["clean"]
dependencies = []


[tasks.format]
description = "Format code using rustfmt"
Expand Down Expand Up @@ -41,7 +42,8 @@ description = "Build optimized release binaries"
workspace = false
command = "cargo"
args = ["build", "--release", "${@}"]
dependencies = ["clean"]
dependencies = []


[tasks.check]
description = "Quick compilation check without building"
Expand Down