Skip to content

fix: release action

fix: release action #3

Workflow file for this run

name: Publish Rust Release
on:
pull_request:
types: [closed, opened, synchronize, ready_for_review]
branches:
- main
jobs:
publish-release:
# Run on merged release PRs OR any open PR for testing (temporarily hardcoded commits)
if: |
(github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')) ||
(github.event.action != 'closed')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
ref: "693f2de24eff345c2f34371a3f7377bfe7ec81ed"
- 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: "34686ce1eea0771d7f0991116f6d5fd4285775e1"
HEAD_SHA: "693f2de24eff345c2f34371a3f7377bfe7ec81ed"
run: |
echo "========================================="
echo "Phase 1: Validation (dry-run)"
echo "========================================="
# Hardcoded commits for testing
./scripts/validate-packages.sh "$BASE_SHA" "$HEAD_SHA"
- name: Publish packages to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
BASE_SHA: "34686ce1eea0771d7f0991116f6d5fd4285775e1"
HEAD_SHA: "693f2de24eff345c2f34371a3f7377bfe7ec81ed"
run: |
echo ""
echo "========================================="
echo "Phase 2: Publishing (atomic)"
echo "========================================="
# Hardcoded commits for testing
./scripts/validate-packages.sh --execute "$BASE_SHA" "$HEAD_SHA"
- name: Create GitHub releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_SHA: "34686ce1eea0771d7f0991116f6d5fd4285775e1"
HEAD_SHA: "693f2de24eff345c2f34371a3f7377bfe7ec81ed"
run: |
echo ""
echo "========================================="
echo "Phase 3: Creating GitHub releases"
echo "========================================="
# Detect packages that were published - hardcoded commits for testing
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"