Skip to content

Commit

Permalink
Merge branch 'dev' into feature/licensing
Browse files Browse the repository at this point in the history
  • Loading branch information
tchataigner authored Jun 24, 2024
2 parents 3523e19 + 7f213e4 commit e2988a6
Showing 1 changed file with 31 additions and 14 deletions.
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

0 comments on commit e2988a6

Please sign in to comment.