Skip to content

Commit

Permalink
Merge branch 'main' into feature/TRA-327-isolated-margin-delta
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang authored Jun 3, 2024
2 parents 7581c71 + 2f74d28 commit e2804cc
Show file tree
Hide file tree
Showing 34 changed files with 1,200 additions and 317 deletions.
84 changes: 73 additions & 11 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bump version on PR
name: Bump version
on:
pull_request_target:
types: [opened, synchronize, reopened]
Expand All @@ -8,6 +8,7 @@ permissions:

jobs:
update_version:
#if: github.event.pull_request.merged == true
runs-on: macos-latest
steps:
- name: checkout
Expand All @@ -17,16 +18,78 @@ jobs:
fetch-depth: 0
token: ${{ secrets.BOT_PAT }}
ref: ${{ github.head_ref }}
- name: Run bump_version_gh_action.sh

- name: Bump version if needed
id: bump-version
run: |
set +e
./bump_version_gh_action.sh
echo "bump_version_ret=$?" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.BOT_PAT }}

set +e
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
# Defining a temporary directory for cloning
TMP_DIR=$(mktemp -d)
curl https://raw.githubusercontent.com/dydxprotocol/v4-abacus/main/build.gradle.kts > $TMP_DIR/build.gradle.kts
# search for the first line that starts with "version" in build.gradle.kts
# get the value in the quotes
VERSION=$(grep "^version = " build.gradle.kts | sed -n 's/version = "\(.*\)"/\1/p')

REPO_VERSION=$(grep "^version = " $TMP_DIR/build.gradle.kts | sed -n 's/version = "\(.*\)"/\1/p')

# call the version comparison function

vercomp $REPO_VERSION $VERSION
case $? in
0) SHOULD_BUMP=true ;;
1) SHOULD_BUMP=true ;;
2) SHOULD_BUMP=false ;;
esac

if [ $SHOULD_BUMP == false ]; then
echo "Repo version < PR version... No need to bump."
echo "bump_version_ret=-1" >> $GITHUB_OUTPUT
exit 0
fi

# increment the version number
NEW_VERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')

#if NEW_VERSION is not empty, replace the version in build.gradle.kts
if [ -n "$NEW_VERSION" ]; then
sed -i '' "s/version = \"$VERSION\"/version = \"$NEW_VERSION\"/" build.gradle.kts
echo "Version bumped to $NEW_VERSION"
fi
echo "bump_version_ret=0" >> $GITHUB_OUTPUT

- name: Import bot's GPG key for signing commits
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v6
Expand All @@ -42,7 +105,7 @@ jobs:
if [[ "${{ steps.bump-version.outputs.bump_version_ret }}" == "0" ]]; then
git config --global user.email ${{ steps.import-gpg.outputs.name }}
git config --global user.name ${{ steps.import-gpg.outputs.email }}
git commit -S -m "Bump version" build.gradle.kts
git push
fi
Expand All @@ -52,4 +115,3 @@ jobs:
GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }}

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.7.46"
version = "1.7.47"

repositories {
google()
Expand Down
68 changes: 0 additions & 68 deletions bump_version_gh_action.sh

This file was deleted.

Loading

0 comments on commit e2804cc

Please sign in to comment.