diff --git a/.github/workflows/bump_version.yaml b/.github/workflows/bump_version.yaml index d03aa5e..7972c32 100644 --- a/.github/workflows/bump_version.yaml +++ b/.github/workflows/bump_version.yaml @@ -2,7 +2,7 @@ name: 'Bomb Version' on: push: branches: - - 'test/*' + - 'test/*.*.*' workflow_dispatch: inputs: @@ -12,6 +12,7 @@ on: jobs: bump-version: +# if: ${{ github.event_name == 'push' && github.ref_name == 'master' || github.event.inputs.environment == 'PROD' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -20,11 +21,16 @@ jobs: - name: Upgrade version run: | # Init - VERSION_INPUT=${{ github.event.inputs.targetVersionName }} + if [[ ! -z "${{ github.event.inputs.targetVersionName }}" ]] then + VERSION_INPUT=${{ github.event.inputs.targetVersionName }} + else + VERSION_INPUT=${GITHUB_REF#refs/heads/test/v} + fi # Check validation with format "a.b.c-x" + rx='^([0-9]+\.){2,2}(\*|[0-9]+)(\-.*){0,1}$' if [[ ! $VERSION_INPUT =~ $rx ]]; then - exit "Invalidate version" + exit "Invalidate version" fi # Parse input @@ -33,19 +39,18 @@ jobs: newPatch="$(echo VERSION_INPUT | cut -d'.' -f3)" # newStaging="$(echo VERSION_INPUT | cut -d'-' -f2)" # check whether exist - echo "success" - -# #Write file -# sed -i '' -E "s/versionMajor = ([0-9]+)/$newMajor/" build.gradle + #Write file + sed -i '' -E "s/versionName \"[^\"]*\"/versionName \"$VERSION_INPUT\"/g" app/build.gradle +# sed -i '' -E "s/versionName ([0-9]+)/$newMajor/" app/build.gradle # sed -i '' -E "s/versionMinor = ([0-9]+)/$newMinor/" build.gradle # sed -i '' -E "s/versionPatch = ([0-9]+)/$newPatch/" build.gradle -# # sed -i '' -E "s/versionStaging = ([0-9]+)/$newStaging/" build.gradle # check whether exist + # sed -i '' -E "s/versionStaging = ([0-9]+)/$newStaging/" build.gradle # check whether exist # -# - name: Commit and push changes -# run: | -# git config user.email "github-actions@myfunnow.com" -# git config user.name "Github Actions" -# git commit -m "Change version name" -# git push origin HEAD + - name: Commit and push changes + run: | + git config user.email "github-actions@google.com" + git config user.name "Github Actions" + git commit -m "Change version name" + git push origin HEAD # Push to firebase and slack