Fix additional clippy warnings #64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - issue-* | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| inputs: | |
| release_target: | |
| description: 'Release target' | |
| required: true | |
| type: choice | |
| options: | |
| - js | |
| - rust | |
| - both | |
| release_mode: | |
| description: 'Manual release mode' | |
| required: true | |
| type: choice | |
| default: 'instant' | |
| options: | |
| - instant | |
| - changelog-pr | |
| bump_type: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| description: | |
| description: 'Release description (optional)' | |
| required: false | |
| type: string | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUSTFLAGS: -Dwarnings | |
| CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }} | |
| jobs: | |
| # === DETECT CHANGES === | |
| detect-changes: | |
| name: Detect Changes | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_dispatch' | |
| outputs: | |
| rs-changed: ${{ steps.changes.outputs.rs-changed }} | |
| toml-changed: ${{ steps.changes.outputs.toml-changed }} | |
| mjs-changed: ${{ steps.changes.outputs.mjs-changed }} | |
| js-changed: ${{ steps.changes.outputs.js-changed }} | |
| package-changed: ${{ steps.changes.outputs.package-changed }} | |
| docs-changed: ${{ steps.changes.outputs.docs-changed }} | |
| workflow-changed: ${{ steps.changes.outputs.workflow-changed }} | |
| any-rust-code-changed: ${{ steps.changes.outputs.any-rust-code-changed }} | |
| any-js-code-changed: ${{ steps.changes.outputs.any-js-code-changed }} | |
| any-code-changed: ${{ steps.changes.outputs.any-code-changed }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Detect changes | |
| id: changes | |
| env: | |
| GITHUB_EVENT_NAME: ${{ github.event_name }} | |
| GITHUB_BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: node scripts/shared/detect-code-changes.mjs | |
| # ==================== JAVASCRIPT JOBS ==================== | |
| # === JS CHANGESET CHECK === | |
| js-changeset-check: | |
| name: JS Changeset Check | |
| runs-on: ubuntu-latest | |
| needs: [detect-changes] | |
| if: github.event_name == 'pull_request' && needs.detect-changes.outputs.any-js-code-changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Install dependencies | |
| working-directory: js | |
| run: npm install | |
| - name: Check for changesets | |
| working-directory: js | |
| env: | |
| GITHUB_BASE_REF: ${{ github.base_ref }} | |
| GITHUB_BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| if [[ "${{ github.head_ref }}" == "changeset-release/"* ]]; then | |
| echo "Skipping changeset check for automated release PR" | |
| exit 0 | |
| fi | |
| # Count changeset files | |
| CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" 2>/dev/null | wc -l) | |
| if [ "$CHANGESET_COUNT" -eq 0 ]; then | |
| echo "::warning::No changeset found. Please add a changeset in js/.changeset/" | |
| fi | |
| echo "Found $CHANGESET_COUNT changeset file(s)" | |
| # === JS LINT === | |
| js-lint: | |
| name: JS Lint | |
| runs-on: ubuntu-latest | |
| needs: [detect-changes] | |
| if: | | |
| github.event_name == 'push' || | |
| github.event_name == 'workflow_dispatch' || | |
| needs.detect-changes.outputs.mjs-changed == 'true' || | |
| needs.detect-changes.outputs.js-changed == 'true' || | |
| needs.detect-changes.outputs.package-changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Install dependencies | |
| working-directory: js | |
| run: npm install | |
| - name: Run ESLint | |
| working-directory: js | |
| run: npm run lint | |
| - name: Check formatting | |
| working-directory: js | |
| run: npm run format:check | |
| - name: Check code duplication | |
| working-directory: js | |
| run: npm run check:duplication | |
| # === JS TEST === | |
| js-test: | |
| name: JS Test (${{ matrix.runtime }} on ${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: [detect-changes, js-changeset-check] | |
| if: always() && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || needs.js-changeset-check.result == 'success' || needs.js-changeset-check.result == 'skipped') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runtime: [node, bun, deno] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| if: matrix.runtime == 'node' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Install dependencies (Node.js) | |
| if: matrix.runtime == 'node' | |
| working-directory: js | |
| run: npm install | |
| - name: Run tests (Node.js) | |
| if: matrix.runtime == 'node' | |
| working-directory: js | |
| run: npm test | |
| - name: Setup Bun | |
| if: matrix.runtime == 'bun' | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies (Bun) | |
| if: matrix.runtime == 'bun' | |
| working-directory: js | |
| run: bun install | |
| - name: Run tests (Bun) | |
| if: matrix.runtime == 'bun' | |
| working-directory: js | |
| run: bun test | |
| - name: Setup Deno | |
| if: matrix.runtime == 'deno' | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Run tests (Deno) | |
| if: matrix.runtime == 'deno' | |
| working-directory: js | |
| run: deno test --allow-read --allow-run --allow-env --allow-net test/**/*.test.mjs | |
| # ==================== RUST JOBS ==================== | |
| # === RUST CHANGELOG CHECK === | |
| rust-changelog-check: | |
| name: Rust Changelog Check | |
| runs-on: ubuntu-latest | |
| needs: [detect-changes] | |
| if: github.event_name == 'pull_request' && needs.detect-changes.outputs.any-rust-code-changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for changelog fragments | |
| working-directory: rust | |
| run: | | |
| FRAGMENTS=$(find changelog.d -name "*.md" ! -name "README.md" 2>/dev/null | wc -l) | |
| CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) | |
| SOURCE_CHANGED=$(echo "$CHANGED_FILES" | grep -E "^rust/(src/|tests/|Cargo\.toml)" | wc -l) | |
| if [ "$SOURCE_CHANGED" -gt 0 ] && [ "$FRAGMENTS" -eq 0 ]; then | |
| echo "::warning::No changelog fragment found. Please add a changelog entry in rust/changelog.d/" | |
| fi | |
| echo "Found $FRAGMENTS changelog fragment(s)" | |
| # === RUST LINT === | |
| rust-lint: | |
| name: Rust Lint | |
| runs-on: ubuntu-latest | |
| needs: [detect-changes] | |
| if: | | |
| github.event_name == 'push' || | |
| github.event_name == 'workflow_dispatch' || | |
| needs.detect-changes.outputs.rs-changed == 'true' || | |
| needs.detect-changes.outputs.toml-changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Check formatting | |
| working-directory: rust | |
| run: cargo fmt --all -- --check | |
| - name: Run Clippy | |
| working-directory: rust | |
| run: cargo clippy --all-targets --all-features | |
| - name: Check file size limit | |
| working-directory: rust | |
| run: node ../scripts/rust/check-file-size.mjs | |
| # === RUST TEST === | |
| rust-test: | |
| name: Rust Test (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: [detect-changes, rust-changelog-check] | |
| if: always() && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || needs.rust-changelog-check.result == 'success' || needs.rust-changelog-check.result == 'skipped') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Run tests | |
| working-directory: rust | |
| run: cargo test --all-features --verbose | |
| - name: Run doc tests | |
| working-directory: rust | |
| run: cargo test --doc --verbose | |
| # === RUST BUILD === | |
| rust-build: | |
| name: Rust Build | |
| runs-on: ubuntu-latest | |
| needs: [rust-lint, rust-test] | |
| if: always() && needs.rust-lint.result == 'success' && needs.rust-test.result == 'success' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust/target | |
| key: ${{ runner.os }}-cargo-build-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-build- | |
| - name: Build release | |
| working-directory: rust | |
| run: cargo build --release --verbose | |
| - name: Check package | |
| working-directory: rust | |
| run: cargo package --list | |
| # ==================== RELEASE JOBS ==================== | |
| # === JS AUTO RELEASE === | |
| js-release: | |
| name: JS Release | |
| needs: [js-lint, js-test] | |
| if: always() && github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.js-lint.result == 'success' && needs.js-test.result == 'success' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| working-directory: js | |
| run: npm install | |
| - name: Check for changesets | |
| id: check_changesets | |
| working-directory: js | |
| run: | | |
| CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" 2>/dev/null | wc -l) | |
| echo "Found $CHANGESET_COUNT changeset file(s)" | |
| echo "has_changesets=$([[ $CHANGESET_COUNT -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT | |
| - name: Version packages and commit | |
| if: steps.check_changesets.outputs.has_changesets == 'true' | |
| id: version | |
| working-directory: js | |
| run: node ../scripts/js/version-and-commit.mjs --mode changeset | |
| - name: Publish to npm | |
| if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true' | |
| id: publish | |
| working-directory: js | |
| run: node ../scripts/js/publish-to-npm.mjs --should-pull | |
| - name: Create GitHub Release | |
| if: steps.publish.outputs.published == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| working-directory: js | |
| run: node ../scripts/js/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" | |
| # === RUST AUTO RELEASE === | |
| rust-release: | |
| name: Rust Release | |
| needs: [rust-lint, rust-test, rust-build] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Determine bump type from changelog fragments | |
| id: bump_type | |
| working-directory: rust | |
| run: node ../scripts/rust/get-bump-type.mjs | |
| - name: Check if version already released or no fragments | |
| id: check | |
| working-directory: rust | |
| run: | | |
| if [ "${{ steps.bump_type.outputs.has_fragments }}" != "true" ]; then | |
| CURRENT_VERSION=$(grep -Po '(?<=^version = ")[^"]*' Cargo.toml) | |
| if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then | |
| echo "No changelog fragments and v$CURRENT_VERSION already released" | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "No changelog fragments but v$CURRENT_VERSION not yet released" | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| echo "skip_bump=true" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "Found changelog fragments, proceeding with release" | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| echo "skip_bump=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Collect changelog and bump version | |
| id: version | |
| if: steps.check.outputs.should_release == 'true' && steps.check.outputs.skip_bump != 'true' | |
| working-directory: rust | |
| run: node ../scripts/rust/version-and-commit.mjs --bump-type "${{ steps.bump_type.outputs.bump_type }}" | |
| - name: Get current version | |
| id: current_version | |
| if: steps.check.outputs.should_release == 'true' | |
| working-directory: rust | |
| run: | | |
| CURRENT_VERSION=$(grep -Po '(?<=^version = ")[^"]*' Cargo.toml) | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Build release | |
| if: steps.check.outputs.should_release == 'true' | |
| working-directory: rust | |
| run: cargo build --release | |
| - name: Publish to Crates.io | |
| if: steps.check.outputs.should_release == 'true' | |
| id: publish-crate | |
| working-directory: rust | |
| run: | | |
| PACKAGE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/name = "\(.*\)"/\1/') | |
| PACKAGE_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') | |
| echo "Package: $PACKAGE_NAME@$PACKAGE_VERSION" | |
| echo "=== Attempting to publish to crates.io ===" | |
| # Try to publish and capture the result | |
| set +e # Don't exit on error | |
| cargo publish --token ${{ secrets.CARGO_TOKEN }} --allow-dirty 2>&1 | tee publish_output.txt | |
| PUBLISH_EXIT_CODE=$? | |
| set -e # Re-enable exit on error | |
| if [ $PUBLISH_EXIT_CODE -eq 0 ]; then | |
| echo "Successfully published $PACKAGE_NAME@$PACKAGE_VERSION to crates.io" | |
| echo "publish_result=success" >> $GITHUB_OUTPUT | |
| elif grep -q "already uploaded" publish_output.txt || grep -q "already exists" publish_output.txt; then | |
| echo "Version $PACKAGE_VERSION already exists on crates.io - this is OK" | |
| echo "publish_result=already_exists" >> $GITHUB_OUTPUT | |
| else | |
| echo "Failed to publish for unknown reason" | |
| cat publish_output.txt | |
| echo "publish_result=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| - name: Report crates.io publish status | |
| if: steps.check.outputs.should_release == 'true' | |
| run: | | |
| if [ "${{ steps.publish-crate.outputs.publish_result }}" = "success" ]; then | |
| echo "Package was successfully published to crates.io" | |
| elif [ "${{ steps.publish-crate.outputs.publish_result }}" = "already_exists" ]; then | |
| echo "Package version already exists on crates.io - no action needed" | |
| else | |
| echo "Publishing to crates.io failed - please check the logs" | |
| fi | |
| - name: Create GitHub Release | |
| if: steps.check.outputs.should_release == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| working-directory: rust | |
| run: | | |
| PACKAGE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/name = "\(.*\)"/\1/') | |
| node ../scripts/rust/create-github-release.mjs \ | |
| --release-version "${{ steps.current_version.outputs.version }}" \ | |
| --repository "${{ github.repository }}" \ | |
| --crates-io-url "https://crates.io/crates/$PACKAGE_NAME" | |
| # === MANUAL INSTANT RELEASE === | |
| manual-release: | |
| name: Manual Instant Release (${{ github.event.inputs.release_target }}) | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'instant' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup Rust | |
| if: github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both' | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # JS Manual Release | |
| - name: Install JS dependencies | |
| if: github.event.inputs.release_target == 'js' || github.event.inputs.release_target == 'both' | |
| working-directory: js | |
| run: npm install | |
| - name: JS Version and commit | |
| if: github.event.inputs.release_target == 'js' || github.event.inputs.release_target == 'both' | |
| id: js_version | |
| working-directory: js | |
| run: node ../scripts/js/version-and-commit.mjs --mode instant --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}" | |
| - name: JS Publish to npm | |
| if: (github.event.inputs.release_target == 'js' || github.event.inputs.release_target == 'both') && (steps.js_version.outputs.version_committed == 'true' || steps.js_version.outputs.already_released == 'true') | |
| id: js_publish | |
| working-directory: js | |
| run: node ../scripts/js/publish-to-npm.mjs | |
| - name: JS Create GitHub Release | |
| if: steps.js_publish.outputs.published == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| working-directory: js | |
| run: node ../scripts/js/create-github-release.mjs --release-version "${{ steps.js_publish.outputs.published_version }}" --repository "${{ github.repository }}" | |
| # Rust Manual Release | |
| - name: Rust Collect changelog fragments | |
| if: github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both' | |
| working-directory: rust | |
| run: | | |
| # Check if there are any fragments to collect | |
| FRAGMENTS=$(find changelog.d -name "*.md" ! -name "README.md" 2>/dev/null | wc -l) | |
| if [ "$FRAGMENTS" -gt 0 ]; then | |
| echo "Found $FRAGMENTS changelog fragment(s), collecting..." | |
| node ../scripts/rust/collect-changelog.mjs | |
| else | |
| echo "No changelog fragments found, skipping collection" | |
| fi | |
| - name: Rust Version and commit | |
| if: github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both' | |
| id: rust_version | |
| working-directory: rust | |
| run: node ../scripts/rust/version-and-commit.mjs --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}" | |
| - name: Rust Build release | |
| if: (github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both') && (steps.rust_version.outputs.version_committed == 'true' || steps.rust_version.outputs.already_released == 'true') | |
| working-directory: rust | |
| run: cargo build --release | |
| - name: Rust Publish to Crates.io | |
| if: (github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both') && (steps.rust_version.outputs.version_committed == 'true' || steps.rust_version.outputs.already_released == 'true') | |
| id: rust_publish_crate | |
| working-directory: rust | |
| run: | | |
| PACKAGE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/name = "\(.*\)"/\1/') | |
| PACKAGE_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') | |
| echo "Package: $PACKAGE_NAME@$PACKAGE_VERSION" | |
| echo "=== Attempting to publish to crates.io ===" | |
| # Try to publish and capture the result | |
| set +e # Don't exit on error | |
| cargo publish --token ${{ secrets.CARGO_TOKEN }} --allow-dirty 2>&1 | tee publish_output.txt | |
| PUBLISH_EXIT_CODE=$? | |
| set -e # Re-enable exit on error | |
| if [ $PUBLISH_EXIT_CODE -eq 0 ]; then | |
| echo "Successfully published $PACKAGE_NAME@$PACKAGE_VERSION to crates.io" | |
| echo "publish_result=success" >> $GITHUB_OUTPUT | |
| elif grep -q "already uploaded" publish_output.txt || grep -q "already exists" publish_output.txt; then | |
| echo "Version $PACKAGE_VERSION already exists on crates.io - this is OK" | |
| echo "publish_result=already_exists" >> $GITHUB_OUTPUT | |
| else | |
| echo "Failed to publish for unknown reason" | |
| cat publish_output.txt | |
| echo "publish_result=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| - name: Rust Report crates.io publish status | |
| if: (github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both') && (steps.rust_version.outputs.version_committed == 'true' || steps.rust_version.outputs.already_released == 'true') | |
| run: | | |
| if [ "${{ steps.rust_publish_crate.outputs.publish_result }}" = "success" ]; then | |
| echo "Package was successfully published to crates.io" | |
| elif [ "${{ steps.rust_publish_crate.outputs.publish_result }}" = "already_exists" ]; then | |
| echo "Package version already exists on crates.io - no action needed" | |
| else | |
| echo "Publishing to crates.io failed - please check the logs" | |
| fi | |
| - name: Rust Create GitHub Release | |
| if: (github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both') && (steps.rust_version.outputs.version_committed == 'true' || steps.rust_version.outputs.already_released == 'true') | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| working-directory: rust | |
| run: | | |
| PACKAGE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/name = "\(.*\)"/\1/') | |
| node ../scripts/rust/create-github-release.mjs \ | |
| --release-version "${{ steps.rust_version.outputs.new_version }}" \ | |
| --repository "${{ github.repository }}" \ | |
| --crates-io-url "https://crates.io/crates/$PACKAGE_NAME" | |
| # === MANUAL CHANGELOG PR === | |
| changelog-pr: | |
| name: Create Changelog PR (${{ github.event.inputs.release_target }}) | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'changelog-pr' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Create JS changelog fragment | |
| if: github.event.inputs.release_target == 'js' || github.event.inputs.release_target == 'both' | |
| working-directory: js | |
| run: | | |
| BUMP_TYPE="${{ github.event.inputs.bump_type }}" | |
| DESCRIPTION="${{ github.event.inputs.description }}" | |
| TIMESTAMP=$(date +%Y%m%d%H%M%S) | |
| FRAGMENT_FILE=".changeset/${TIMESTAMP}-manual-${BUMP_TYPE}.md" | |
| # Create changeset file | |
| mkdir -p .changeset | |
| cat > "$FRAGMENT_FILE" << EOF | |
| --- | |
| "agent-commander": $BUMP_TYPE | |
| --- | |
| EOF | |
| if [ -n "$DESCRIPTION" ]; then | |
| echo "${DESCRIPTION}" >> "$FRAGMENT_FILE" | |
| else | |
| echo "Manual ${BUMP_TYPE} release" >> "$FRAGMENT_FILE" | |
| fi | |
| echo "Created changeset fragment: $FRAGMENT_FILE" | |
| cat "$FRAGMENT_FILE" | |
| - name: Create Rust changelog fragment | |
| if: github.event.inputs.release_target == 'rust' || github.event.inputs.release_target == 'both' | |
| working-directory: rust | |
| run: | | |
| BUMP_TYPE="${{ github.event.inputs.bump_type }}" | |
| DESCRIPTION="${{ github.event.inputs.description }}" | |
| TIMESTAMP=$(date +%Y%m%d%H%M%S) | |
| FRAGMENT_FILE="changelog.d/${TIMESTAMP}-manual-${BUMP_TYPE}.md" | |
| # Determine changelog category based on bump type | |
| case "$BUMP_TYPE" in | |
| major) | |
| CATEGORY="### Breaking Changes" | |
| ;; | |
| minor) | |
| CATEGORY="### Added" | |
| ;; | |
| patch) | |
| CATEGORY="### Fixed" | |
| ;; | |
| esac | |
| # Create changelog fragment with frontmatter | |
| mkdir -p changelog.d | |
| cat > "$FRAGMENT_FILE" << EOF | |
| --- | |
| bump: $BUMP_TYPE | |
| --- | |
| $CATEGORY | |
| EOF | |
| if [ -n "$DESCRIPTION" ]; then | |
| echo "- ${DESCRIPTION}" >> "$FRAGMENT_FILE" | |
| else | |
| echo "- Manual ${BUMP_TYPE} release" >> "$FRAGMENT_FILE" | |
| fi | |
| echo "Created changelog fragment: $FRAGMENT_FILE" | |
| cat "$FRAGMENT_FILE" | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: 'chore: add changelog for manual ${{ github.event.inputs.bump_type }} release (${{ github.event.inputs.release_target }})' | |
| branch: changelog-manual-release-${{ github.run_id }} | |
| delete-branch: true | |
| title: 'chore: manual ${{ github.event.inputs.bump_type }} release (${{ github.event.inputs.release_target }})' | |
| body: | | |
| ## Manual Release Request | |
| This PR was created by a manual workflow trigger to prepare a **${{ github.event.inputs.bump_type }}** release. | |
| ### Release Details | |
| - **Target:** ${{ github.event.inputs.release_target }} | |
| - **Type:** ${{ github.event.inputs.bump_type }} | |
| - **Description:** ${{ github.event.inputs.description || 'Manual release' }} | |
| - **Triggered by:** @${{ github.actor }} | |
| ### Next Steps | |
| 1. Review the changelog fragment(s) in this PR | |
| 2. Merge this PR to main | |
| 3. The automated release workflow will: | |
| - For JS: Publish to npm and create a GitHub release | |
| - For Rust: Publish to crates.io and create a GitHub release |