From abc3fcfcd3dd8157cd5020343392c7d10cdca1f5 Mon Sep 17 00:00:00 2001 From: Cezary Olborski Date: Tue, 23 Sep 2025 17:22:49 +0800 Subject: [PATCH] chore: RM - refreshed (#15) * chore: Proper version distribution * chore: version based on tags --------- Co-authored-by: czareko --- .github/workflows/release-proposal.yml | 116 +++++++++++++++---------- Cargo.lock | 18 ++-- Cargo.toml | 1 + crates/engine-cpu/Cargo.toml | 4 +- crates/engine-gpu-cuda/Cargo.toml | 4 +- crates/engine-gpu-opencl/Cargo.toml | 4 +- crates/engine-montgomery/Cargo.toml | 4 +- crates/metrics/Cargo.toml | 4 +- crates/miner-cli/Cargo.toml | 4 +- crates/miner-service/Cargo.toml | 4 +- crates/miner-telemetry/Cargo.toml | 4 +- crates/pow-core/Cargo.toml | 4 +- 12 files changed, 97 insertions(+), 74 deletions(-) diff --git a/.github/workflows/release-proposal.yml b/.github/workflows/release-proposal.yml index f3cd33e..b5e425a 100644 --- a/.github/workflows/release-proposal.yml +++ b/.github/workflows/release-proposal.yml @@ -53,58 +53,73 @@ jobs: echo "commit_sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT echo "source_branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT - - name: Get current version from Cargo.toml - id: current_version + - name: Get latest tag + id: latest_tag run: | - current=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') - echo "current=$current" >> $GITHUB_OUTPUT - echo "Current version: $current" + # Get all version tags and sort them by version + latest_semver_tag=$(git tag -l "v[0-9]*.[0-9]*.[0-9]*" | sort -V | tail -n 1) + + # If no tags found, use default + if [ -z "$latest_semver_tag" ]; then + latest_semver_tag="v0.0.0" + fi + + echo "latest_tag_found=$latest_semver_tag" >> $GITHUB_OUTPUT + echo "Latest semantic version tag found: $latest_semver_tag" - name: Calculate new version id: versioner env: - CURRENT_VERSION: ${{ steps.current_version.outputs.current }} + LATEST_TAG: ${{ steps.latest_tag.outputs.latest_tag_found }} VERSION_TYPE: ${{ github.event.inputs.version_type }} CUSTOM_VERSION: ${{ github.event.inputs.custom_version }} run: | + # Remove 'v' prefix and any suffix for processing + current_version=${LATEST_TAG#v} + # Remove any suffix after the version number + current_version=$(echo "$current_version" | sed -E 's/-[^-]+$//') + if [[ "$VERSION_TYPE" == "custom" ]]; then if [[ -z "$CUSTOM_VERSION" ]]; then echo "Error: Custom version is selected but no custom_version string provided." exit 1 fi + if [[ ! "$CUSTOM_VERSION" =~ ^v ]]; then + echo "Error: Custom version string MUST start with 'v' (e.g., v1.2.3)." + exit 1 + fi new_version="$CUSTOM_VERSION" else - # Parse current version - IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" - major=${VERSION_PARTS[0]} - minor=${VERSION_PARTS[1]} - patch=${VERSION_PARTS[2]} - - # Calculate new version - case $VERSION_TYPE in - major) + # Split version and pre-release part + IFS='-' read -r version_core prerelease_part <<< "$current_version" + IFS='.' read -r major minor patch <<< "$version_core" + + # Increment based on type + if [[ "$VERSION_TYPE" == "major" ]]; then + if [[ "$major" == "0" ]]; then # Handle 0.x.y -> 0.(x+1).0 + major=$major + minor=$((minor + 1)) + patch=0 + else major=$((major + 1)) minor=0 patch=0 - ;; - minor) - minor=$((minor + 1)) - patch=0 - ;; - patch) - patch=$((patch + 1)) - ;; - esac - - new_version="$major.$minor.$patch" + fi + elif [[ "$VERSION_TYPE" == "minor" ]]; then + minor=$((minor + 1)) + patch=0 + elif [[ "$VERSION_TYPE" == "patch" ]]; then + patch=$((patch + 1)) + else + echo "Error: Invalid version_type: $VERSION_TYPE" + exit 1 + fi + new_version="v$major.$minor.$patch" fi - - new_tag="v$new_version" - - echo "new_version=$new_version" >> $GITHUB_OUTPUT - echo "new_tag=$new_tag" >> $GITHUB_OUTPUT + echo "New version: $new_version" - echo "New tag: $new_tag" + echo "new_version=$new_version" >> $GITHUB_OUTPUT + echo "new_tag=$new_version" >> $GITHUB_OUTPUT update-cargo-toml: name: 📝 Update version files @@ -122,9 +137,6 @@ jobs: - name: Setup rust uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Install cargo-edit - run: cargo install cargo-edit --locked - - name: Create version bump branch and PR env: NEW_VERSION: ${{ needs.calculate-next-version.outputs.new_version }} @@ -134,27 +146,42 @@ jobs: TARGET_BRANCH: ${{ github.event.inputs.target_branch }} run: | set -ex - branch_name="release/${NEW_TAG}" + new_cargo_version=${NEW_VERSION#v} + branch_name="release/${NEW_VERSION}" # Create new branch from source branch git checkout "$SOURCE_BRANCH" git checkout -b "$branch_name" - # Update version in Cargo.toml - echo "Updating Cargo.toml to version: $NEW_VERSION" - cargo set-version "$NEW_VERSION" + # Update version in workspace Cargo.toml (safer than cargo set-version) + echo "Updating workspace Cargo.toml to version: $new_cargo_version" + sed -i -E "s/^version\s*=\s*\"[0-9a-zA-Z.-]+\"/version = \"$new_cargo_version\"/" Cargo.toml + + # Regenerate Cargo.lock with precise updates for our packages only + cargo update -p miner-cli --precise "$new_cargo_version" + cargo update -p miner-service --precise "$new_cargo_version" + cargo update -p pow-core --precise "$new_cargo_version" + cargo update -p metrics --precise "$new_cargo_version" + cargo update -p miner-telemetry --precise "$new_cargo_version" + cargo update -p engine-cpu --precise "$new_cargo_version" + cargo update -p engine-gpu-cuda --precise "$new_cargo_version" + cargo update -p engine-gpu-opencl --precise "$new_cargo_version" + cargo update -p engine-montgomery --precise "$new_cargo_version" + + # Verify everything compiles correctly + cargo check --workspace # Commit changes git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" git add Cargo.toml Cargo.lock - git commit -m "bump version to $NEW_TAG" + git commit -m "bump version to $NEW_VERSION" git push origin "$branch_name" # Prepare PR title and body - PR_TITLE="Release $NEW_TAG" - PR_BODY="Automated version bump for release $NEW_TAG. + PR_TITLE="Release $NEW_VERSION" + PR_BODY="Automated version bump for release $NEW_VERSION. ## Overview - Version bump: ${{ github.event.inputs.version_type }} @@ -164,11 +191,6 @@ jobs: ## What changed - Updated version in Cargo.toml and Cargo.lock - ## Validation - - [ ] Version number is correct - - [ ] All tests pass - - [ ] Ready for release - Triggered by workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" # Prepare labels diff --git a/Cargo.lock b/Cargo.lock index 3ba46e9..b880ac8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -471,7 +471,7 @@ dependencies = [ [[package]] name = "engine-cpu" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "hex", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "engine-gpu-cuda" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "cust", @@ -502,7 +502,7 @@ dependencies = [ [[package]] name = "engine-gpu-opencl" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "log", @@ -514,7 +514,7 @@ dependencies = [ [[package]] name = "engine-montgomery" -version = "0.1.0" +version = "0.0.1" dependencies = [ "crypto-bigint", "engine-cpu", @@ -1131,7 +1131,7 @@ checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "metrics" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "log", @@ -1161,7 +1161,7 @@ dependencies = [ [[package]] name = "miner-cli" -version = "0.1.0" +version = "0.0.1" dependencies = [ "clap", "env_logger", @@ -1172,7 +1172,7 @@ dependencies = [ [[package]] name = "miner-service" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "crossbeam-channel", @@ -1197,7 +1197,7 @@ dependencies = [ [[package]] name = "miner-telemetry" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "futures 0.3.31", @@ -1478,7 +1478,7 @@ dependencies = [ [[package]] name = "pow-core" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "hex", diff --git a/Cargo.toml b/Cargo.toml index 3e48512..7a825fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ resolver = "2" edition = "2021" authors = ["Quantus Network"] description = "Quantus External Miner Workspace" +version = "0.0.1" [workspace.dependencies] anyhow = "1" diff --git a/crates/engine-cpu/Cargo.toml b/crates/engine-cpu/Cargo.toml index 85f2d0f..9a10570 100644 --- a/crates/engine-cpu/Cargo.toml +++ b/crates/engine-cpu/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "engine-cpu" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true publish = false description = "CPU mining engine implementation for the Quantus External Miner" diff --git a/crates/engine-gpu-cuda/Cargo.toml b/crates/engine-gpu-cuda/Cargo.toml index 48b2fc1..7b527dc 100644 --- a/crates/engine-gpu-cuda/Cargo.toml +++ b/crates/engine-gpu-cuda/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "engine-gpu-cuda" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true publish = false description = "CUDA-based GPU mining engine for the Quantus External Miner (placeholder crate)" diff --git a/crates/engine-gpu-opencl/Cargo.toml b/crates/engine-gpu-opencl/Cargo.toml index 77283c6..ab8f3eb 100644 --- a/crates/engine-gpu-opencl/Cargo.toml +++ b/crates/engine-gpu-opencl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "engine-gpu-opencl" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true publish = false description = "OpenCL-based GPU mining engine for the Quantus External Miner (placeholder crate)" diff --git a/crates/engine-montgomery/Cargo.toml b/crates/engine-montgomery/Cargo.toml index 02de853..fd9b662 100644 --- a/crates/engine-montgomery/Cargo.toml +++ b/crates/engine-montgomery/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "engine-montgomery" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true description = "Montgomery-optimized CPU mining engine for Quantus External Miner" [lib] diff --git a/crates/metrics/Cargo.toml b/crates/metrics/Cargo.toml index 4c11d09..98d0032 100644 --- a/crates/metrics/Cargo.toml +++ b/crates/metrics/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "metrics" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true publish = false description = "Metrics and Prometheus exporter utilities for the Quantus External Miner" diff --git a/crates/miner-cli/Cargo.toml b/crates/miner-cli/Cargo.toml index fe64f5e..c09b34b 100644 --- a/crates/miner-cli/Cargo.toml +++ b/crates/miner-cli/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "miner-cli" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true publish = false description = "CLI binary to run the Quantus External Miner service" diff --git a/crates/miner-service/Cargo.toml b/crates/miner-service/Cargo.toml index f51587c..3acec0e 100644 --- a/crates/miner-service/Cargo.toml +++ b/crates/miner-service/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "miner-service" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true publish = false description = "Service layer: HTTP API, job orchestration, and engine abstraction for the Quantus External Miner" diff --git a/crates/miner-telemetry/Cargo.toml b/crates/miner-telemetry/Cargo.toml index 354f248..64da47a 100644 --- a/crates/miner-telemetry/Cargo.toml +++ b/crates/miner-telemetry/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "miner-telemetry" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true publish = false description = "Telemetry client for Quantus External Miner (Polkadot SDK-compatible envelopes over WebSocket)" diff --git a/crates/pow-core/Cargo.toml b/crates/pow-core/Cargo.toml index 87ff138..79e5106 100644 --- a/crates/pow-core/Cargo.toml +++ b/crates/pow-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pow-core" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true description = "Local QPoW math core for the Quantus external miner (reference + optimized paths)" license = "MIT OR Apache-2.0" keywords = ["bigint", "crypto", "pow", "qpow", "quantus"]