From 7f213e467ccee9cbb8fd66ac72ff9a4f2d07834e Mon Sep 17 00:00:00 2001 From: Samuel Burnham <45365069+samuelburnham@users.noreply.github.com> Date: Mon, 24 Jun 2024 02:19:32 -0400 Subject: [PATCH] ci: Update `bump-version-PR.yml` (#38) --- .github/workflows/bump-version-PR.yml | 45 ++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/bump-version-PR.yml b/.github/workflows/bump-version-PR.yml index d0ea36da..e3f11e58 100644 --- a/.github/workflows/bump-version-PR.yml +++ b/.github/workflows/bump-version-PR.yml @@ -19,10 +19,6 @@ on: jobs: release: runs-on: ubuntu-latest - env: - # Crates from which the version will be bumped - CRATES: './aptos/aptos-programs,./aptos/core,./aptos/light-client,./aptos/programs/inclusion,./aptos/programs/epoch-change,./aptos/proof-server' - steps: - name: Git config run: | @@ -35,6 +31,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install `tq-rs` + run: cargo install tq-rs + # The `release/1.0` branch is always truncated, so that patch version merges still are valid Semver # However, when we make the initial `release/1.0` version bump, we include the full `1.0.0` in `Cargo.toml` # and the release for clarity @@ -46,12 +48,12 @@ jobs: VERSION=${{ inputs.version }} BASE_BRANCH="release/$BASE_VERSION_SHORT" PR_BRANCH="${{ inputs.type }}/${{ inputs.version }}" - git checkout ${{ env.PR_BRANCH }} + git checkout $PR_BRANCH else VERSION=$BASE_VERSION BASE_BRANCH="main" PR_BRANCH="release/$BASE_VERSION_SHORT" - git checkout -b ${{ env.PR_BRANCH }} + git checkout -b $PR_BRANCH fi echo "BASE_BRANCH=$BASE_BRANCH" | tee -a $GITHUB_ENV @@ -76,19 +78,34 @@ jobs: - name: Update version in Cargo.toml run: | echo "Updating version in Cargo.toml..." - IFS=',' read -ra CRATE_PATHS <<< "$CRATES" - for path in "${CRATE_PATHS[@]}"; do - cd $path + + members=$(tq workspace.members -f Cargo.toml | jq -r '. += ["programs/inclusion", "programs/epoch-change"] | .[]') + + bump_version() { + cd "$1" OLD_VERSION=$(grep -oP 'version = "\K[^"]+' Cargo.toml) if [[ "${{ env.VERSION }}" > "$OLD_VERSION" ]]; then - sed -i 's/version = "'$OLD_VERSION'"/version = "${{ env.VERSION }}"/' Cargo.toml + sed -i "s/version = \"$OLD_VERSION\"/version = \"${{ env.VERSION }}\"/" Cargo.toml else - echo "New version is not greater than the current version for $path. Aborting..." + echo "New version is not greater than the current version for $1. Aborting..." exit 1 fi - cd $GITHUB_WORKSPACE - done - + cd ${{ github.workspace }}/aptos + } + + while IFS= read -r path; do + if [[ "$path" == *"/*" ]]; then + for dir in "${path%/*}"/*; do + if [ -d "$dir" ] && [ -f "$dir/Cargo.toml" ]; then + bump_version "$dir" + fi + done + else + bump_version "$path" + fi + done <<< "$members" + working-directory: ${{ github.workspace }}/aptos + - name: Commit changes run: | git add .