diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7932f72..8924e7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Determine the version + # Updates the build version to the tag if it's a release. + # Otherwise updates the build version to latest tag with the branch name as a suffix (i.e. 1.0.0-feature-upload). + run: | + LAST_VERSION=$(git describe --tags --always --first-parent) + VERSION_SUFFIX=$(echo ${{ github.head_ref }} | sed -e 's/^refs\///' -e 's/[^0-9a-zA-Z\-_]/-/g') + BUILD_VERSION=$([[ "${{ github.event_name }}" == "release" ]] && echo $LAST_VERSION || echo "$LAST_VERSION-$VERSION_SUFFIX") + sed -i'' -e "/^version=/s/=.*/=$BUILD_VERSION/" gradle.properties + echo $BUILD_VERSION + echo "::set-output name=BUILD_VERSION::$BUILD_VERSION" - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: