diff --git a/.github/workflows/bump-version-name.yml b/.github/workflows/bump-version-name.yml new file mode 100644 index 00000000000..8d7d106db8b --- /dev/null +++ b/.github/workflows/bump-version-name.yml @@ -0,0 +1,29 @@ +name: Bump version name +on: + # push: + # branches: + # - develop + pull_request: + branches: + - develop + - main + - bitrise_yml_new + types: [opened] +jobs: + bump-version-name: + runs-on: ubuntu-latest + if: contains(github.head_ref, "release/") + steps: + - uses: actions/checkout@v2 + - name: Bump script + env: + HEAD_REF: ${{ github.head_ref }} + run: | + ./scripts/bump-version.sh "$HEAD_REF" + git diff + git config user.name github-actions + git config user.email github-actions@github.com + git add bitrise.yml + git add package.json + git commit -m "Bump version name" + git push origin HEAD:"$HEAD_REF" --force diff --git a/bitrise.yml b/bitrise.yml index fdfc51f2c95..633933386b2 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -239,7 +239,7 @@ app: PROJECT_LOCATION_IOS: ios - opts: is_expand: false - VERSION_NAME: "'2.1.1'" + VERSION_NAME: 2.2.0 - opts: is_expand: false ANDROID_APK_LINK: '' diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100755 index 00000000000..29ae5829e94 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +versionName="$(awk '/VERSION_NAME: /{print $2}' bitrise.yml)" + +MAJOR=$(awk -F. '{print $1}' <<< $versionName) +MINOR=$(awk -F. '{print $2}' <<< $versionName) +PATCH=$(awk -F. '{print $3}' <<< $versionName) +version=$MAJOR'.'$MINOR'.'$PATCH + +if [[ $1 == *"release/"* ]] ; then + if [[ $1 == *"-major"* ]] ; then + major=$(($MAJOR + 1)); + minor="0"; + patch="0"; + version=$major'.'$minor'.'$patch + elif [[ $1 == *"-minor"* ]] ; then + minor=$(($MINOR + 1)); + patch="0"; + version=$MAJOR'.'$minor'.'$patch + elif [[ $1 == *"-patch"* ]] ; then + patch=$(($PATCH + 1)); + version=$MAJOR'.'$MINOR'.'$patch + fi + + echo "Bumping versionName to" + echo $version + + sed -i -e 's/VERSION_NAME: [0-9]\{1,\}.[0-9]\{1,\}.[0-9]\{1,\}/VERSION_NAME: '$version'/' bitrise.yml + sed -i -e 's/"version": "[0-9]\{1,\}.[0-9]\{1,\}.[0-9]\{1,\}"/"version": "'$version'"/' package.json + + echo "Bumping versionName finished" +fi