Skip to content

Commit

Permalink
ci: Update bump-version-PR.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelburnham committed Jun 21, 2024
1 parent 9e8d708 commit 55fac5b
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 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 Down Expand Up @@ -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

0 comments on commit 55fac5b

Please sign in to comment.