diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-rust.yml similarity index 93% rename from .github/workflows/release-publish.yml rename to .github/workflows/release-rust.yml index ea49614248..10bbe29a55 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-rust.yml @@ -1,4 +1,4 @@ -name: Publish Release +name: Publish Rust Release on: pull_request: @@ -21,14 +21,16 @@ jobs: 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: Install cargo-release - run: cargo install cargo-release - - name: Configure git run: | git config user.name "github-actions[bot]" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index eec2218324..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,167 +0,0 @@ -name: Release - -on: - push: - branches: - - main - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Setup and build - uses: ./.github/actions/setup-and-build - - - name: Install cargo-workspaces - run: | - source ./scripts/devenv.sh - cargo install cargo-release cargo-workspaces - - - name: Extract project - id: extract-project - shell: bash - run: | - COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s' | sed 's/([^()]*)//g' | head -n 1) - PACKAGE="" - LANGUAGE="" - echo "Commit message: $COMMIT_MESSAGE" - - if [[ "$COMMIT_MESSAGE" == "chore: Bump version of all Rust projects" ]]; then - PACKAGE="all" - LANGUAGE="rust" - elif [[ "$COMMIT_MESSAGE" == *"Bump version of all TypeScript"* ]]; then - PACKAGE="all" - LANGUAGE="ts" - elif [[ "$COMMIT_MESSAGE" == "chore: Bump version of Rust project "* ]]; then - PACKAGE=$(echo "$COMMIT_MESSAGE" | sed -n 's/chore: Bump version of Rust project \(.*\)/\1/p') - LANGUAGE="rust" - elif [[ "$COMMIT_MESSAGE" == *"Bump version of TypeScript project"* ]]; then - PACKAGE=$(echo "$COMMIT_MESSAGE" | grep -o "version of TypeScript project [^ ]*" | cut -d " " -f5) - LANGUAGE="rust" - fi - - # Needed for Anchor. - PACKAGE_SNAKE_CASE=$(echo "$PACKAGE" | tr '-' '_') - - printf "package=%s\package-snake-case=%s\nlanguage=%s\n" "$PACKAGE" "$PACKAGE_SNAKE_CASE" "$LANGUAGE" >> "$GITHUB_OUTPUT" - - - name: Set Git user configuration - if: steps.extract-project.outputs.language != '' - run: | - git config user.name "GitHub Actions" - git config user.email "github-actions@github.com" - - - name: Tag all Rust projects - if: steps.extract-project.outputs.package == 'all' && steps.extract-project.outputs.language == 'rust' - run: | - for PACKAGE in $(cargo ws list); do - VERSION=$(cargo pkgid -p "$PACKAGE" | cut -d "@" -f2) - echo "Creating tag for Rust package: $PACKAGE v$VERSION" - git tag "${PACKAGE}-v${VERSION}" - git push origin "${PACKAGE}-v${VERSION}" - done - - - name: Tag all TypeScript projects - if: steps.extract-project.outputs.package == 'all' && steps.extract-project.outputs.language == 'ts' - run: | - for dir in $(pnpm m ls --depth -1 --porcelain | grep -v examples | grep -v tsconfig | tail -n+2); do - pushd "$dir" - PACKAGE=$(basename "$dir") - VERSION=$(pnpm list --depth 0 --json | jq -r '.[0].version') - echo "Creating tag for TypeScript package: $PACKAGE v$VERSION" - git tag "${PACKAGE}-v${VERSION}" - git push origin "${PACKAGE}-v${VERSION}" - popd - done - - - name: Tag Rust project - id: tag-rust - if: steps.extract-project.outputs.package != 'all' && steps.extract-project.outputs.language == 'rust' - env: - PACKAGE: ${{ steps.extract-project.outputs.version }} - run: | - VERSION=$(cargo pkgid -p "$PACKAGE" | cut -d "@" -f2) - echo "Creating tag for package: $PACKAGE v$VERSION" - git tag "${PACKAGE}-v${VERSION}" - git push origin "${PACKAGE}-v${VERSION}" - - - name: Tag TypeScript project - id: tag-ts - if: steps.extract-project.outputs.package != 'all' && steps.extract-project.outputs.language == 'ts' - env: - PACKAGE: ${{ steps.extract-project.outputs.version }} - run: | - VERSION=$(pnpm list --filter "$1" --depth 0 --json | jq -r '.[0].version') - echo "Creating tag for package: $PACKAGE v$VERSION" - git tag "${PACKAGE}-v${VERSION}" - git push origin "${PACKAGE}-v${VERSION}" - - - name: Log in to crates.io - if: steps.extract-project.outputs.language == 'rust' - run: | - cargo login "${{ secrets.CRATES_IO_TOKEN }}" - - - name: Release all Rust projects - if: steps.extract-project.outputs.package == 'all' && steps.extract-project.outputs.language == 'rust' - shell: bash - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - PACKAGE: ${{ steps.extract-project.outputs.package }} - run: | - source ./scripts/devenv.sh - - npx nx build @lightprotocol/programs - cp -r ./target/deploy/*.so . - - PACKAGES=("aligned-sized" "light-heap" "light-utils" "light-bounded-vec" "light-hasher" "light-macros" "light-hash-set" "light-merkle-tree-reference" "light-concurrent-merkle-tree" "light-indexed-merkle-tree" "light-prover-client" "light-verifier" "account-compression" "light-registry" "light-system-program" "light-compressed-token" "light-test-utils") - for PACKAGE in "${PACKAGES[@]}"; do - for attempt in {1..3}; do - echo "Attempt $attempt: Publishing $PACKAGE..." - cargo release publish --package "$PACKAGE" --execute --no-confirm && break || echo "Attempt $attempt failed, retrying in 60..." - sleep 60 - done - echo "Sleeping for 60 seconds to handle rate limits..." - sleep 60 - done - - - name: Release Rust project - if: steps.extract-project.outputs.package != 'all' && steps.extract-project.outputs.language == 'rust' - shell: bash - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - PACKAGE: ${{ steps.extract-project.outputs.package }} - PACKAGE_SNAKE_CASE: ${{ steps.extract-project.outputs.package-snake-case }} - run: | - source ./scripts/devenv.sh - - # Check whether we are building an on-chain program. - if [[ $(anchor keys list | grep "$PACKAGE_SNAKE_CASE") -eq 0 ]]; then - anchor build -p "$PACKAGE_SNAKE_CASE" - fi - cp -r ./target/deploy/*.so . - - cargo release publish \ - --package "$PACKAGE" - - - name: Release TypeScript - if: steps.extract-project.outputs.package != 'all' && steps.extract-project.outputs.language == 'ts' - shell: bash - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} - NPM_CONFIG_PROVENANCE: true - PACKAGE: ${{ steps.extract-project.outputs.package }} - run: | - SUBDIR=$(grep "$PACKAGE" pnpm-workspace.yaml | awk -F '"' '{gsub("/\\*\\*", "", $2); print $2}') - cd "$SUBDIR" - pnpm publish --access public --no-git-checks - - - name: GitHub release - uses: softprops/action-gh-release@v2 - if: steps.extract-project.outputs.language != '' - with: - token: ${{ secrets.PAT_TOKEN }} - files: | - *.so diff --git a/Cargo.toml b/Cargo.toml index fdc108471a..2dcd9aa4f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -233,18 +233,3 @@ solana-program-runtime = { git = "https://github.com/Lightprotocol/agave", rev = solana-bpf-loader-program = { git = "https://github.com/Lightprotocol/agave", rev = "be34dc76559e14921a2c8610f2fa2402bf0684bb" } # Patch solana-program-memory to use older version where is_nonoverlapping is public solana-program-memory = { git = "https://github.com/anza-xyz/solana-sdk", rev = "1c1d667f161666f12f5a43ebef8eda9470a8c6ee" } - -[workspace.metadata.release] -allow-branch = ["main", "release/*"] -tag-name = "{{crate_name}}-v{{version}}" -publish = true -push = true -shared-version = false -sign-commit = false -sign-tag = false -# Update workspace dependencies when releasing -dependent-version = "upgrade" -# Don't consolidate commits - create one commit per package -consolidate-commits = false -# Don't verify (skip tests/build checks) -verify = false diff --git a/scripts/create-release-pr.sh b/scripts/create-release-pr.sh index 38eae0648c..db074d0b74 100755 --- a/scripts/create-release-pr.sh +++ b/scripts/create-release-pr.sh @@ -105,7 +105,7 @@ echo "$VERSION_CHANGES" echo "" echo "=========================================" -echo "Running cargo release dry-run validation..." +echo "Running cargo publish dry-run validation..." echo "=========================================" echo "" diff --git a/scripts/validate-packages.sh b/scripts/validate-packages.sh index 861f63eb2f..cdec076f29 100755 --- a/scripts/validate-packages.sh +++ b/scripts/validate-packages.sh @@ -48,20 +48,19 @@ done echo "" if [ -n "$EXECUTE_FLAG" ]; then - echo "Running: cargo release publish $PACKAGE_ARGS --execute --no-confirm" + echo "Running: cargo publish $PACKAGE_ARGS --no-verify" else echo "Running: cargo publish $PACKAGE_ARGS --dry-run" fi echo "----------------------------------------" # Native cargo 1.90.0+ handles dependency ordering for interdependent workspace crates -# Without --execute: dry-run validation using native cargo publish -# With --execute: use cargo-release for actual publish to crates.io if [ -n "$EXECUTE_FLAG" ]; then - cargo release publish $PACKAGE_ARGS --execute --no-confirm + # Actual publish to crates.io using native cargo + # Skip verification to avoid build issues with interdependent packages + cargo publish $PACKAGE_ARGS --no-verify else - # Use native cargo publish --dry-run with all packages at once - # This allows interdependent workspace crates to validate together + # Dry-run validation using native cargo publish # Allow dirty state and skip verification due to cargo bug with unpublished dep hashes cargo publish $PACKAGE_ARGS --dry-run --allow-dirty --no-verify fi