Publish Rust Release #13
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: Publish Rust Release | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| base_sha: | |
| description: 'Base commit SHA' | |
| required: false | |
| default: 'a31725d0de490f83ffc3b51c16d46ab98bef6214' | |
| head_sha: | |
| description: 'Head commit SHA' | |
| required: false | |
| default: 'c448992824d6410e08d07e0af3e41e44b2ec746d' | |
| jobs: | |
| publish-release: | |
| # Temporarily hardcoded to fix failed release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Fetch PR commits | |
| run: | | |
| git fetch origin ${{ github.event.pull_request.base.sha }} | |
| git fetch origin ${{ github.event.pull_request.head.sha }} | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Validate packages before publishing | |
| env: | |
| BASE_SHA: a31725d0de490f83ffc3b51c16d46ab98bef6214 | |
| HEAD_SHA: c448992824d6410e08d07e0af3e41e44b2ec746d | |
| run: | | |
| echo "=========================================" | |
| echo "Phase 1: Validation (dry-run)" | |
| echo "=========================================" | |
| ./scripts/validate-packages.sh "$BASE_SHA" "$HEAD_SHA" | |
| - name: Publish packages to crates.io | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| BASE_SHA: a31725d0de490f83ffc3b51c16d46ab98bef6214 | |
| HEAD_SHA: c448992824d6410e08d07e0af3e41e44b2ec746d | |
| run: | | |
| echo "" | |
| echo "=========================================" | |
| echo "Phase 2: Publishing (atomic)" | |
| echo "=========================================" | |
| ./scripts/validate-packages.sh --execute "$BASE_SHA" "$HEAD_SHA" | |
| - name: Create GitHub releases | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BASE_SHA: a31725d0de490f83ffc3b51c16d46ab98bef6214 | |
| HEAD_SHA: c448992824d6410e08d07e0af3e41e44b2ec746d | |
| run: | | |
| echo "" | |
| echo "=========================================" | |
| echo "Phase 3: Creating GitHub releases" | |
| echo "=========================================" | |
| # Detect packages that were published | |
| PACKAGES_STRING=$(./scripts/detect-version-changes.sh "$BASE_SHA" "$HEAD_SHA") | |
| read -ra PACKAGES <<< "$PACKAGES_STRING" | |
| for pkg in "${PACKAGES[@]}"; do | |
| echo "----------------------------------------" | |
| # Get the version from Cargo.toml | |
| VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r ".packages[] | select(.name == \"$pkg\") | .version") | |
| TAG="${pkg}-v${VERSION}" | |
| echo "Creating GitHub release for $TAG.." | |
| if gh release create "$TAG" --generate-notes --title "$TAG"; then | |
| echo "✓ Created release for $TAG" | |
| else | |
| echo "Warning: Failed to create release for $TAG" | |
| fi | |
| done | |
| echo "" | |
| echo "✓ GitHub releases created" |