Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update bump-version-PR.yml #38

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions .github/workflows/bump-version-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 .
Expand Down
Loading