diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55cc5a6c..8fefdd2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,10 @@ # This workflow builds the SDK using Java 11 name: Build +# This is a reusable workflow. on: - push: - branches: [master] - pull_request: - branches: [master] - release: - types: [published] + workflow_call: + jobs: # Build and test the SDK build-test-publish: @@ -86,35 +83,15 @@ jobs: with: name: reports path: build/reports - - name: Define uberJAR name - if: startsWith(github.ref, 'refs/tags/v') - run: | - export TP_SDK_VARIANT="RELEASE" - echo "TP_SDK_VARIANT=RELEASE" >> $GITHUB_ENV - export TP_SDK_JAR_NAME="testproject-java-sdk" - export TP_SDK_UBER_JAR_EXT="with-dependencies.jar" - echo "TP_SDK_JAR_NAME=testproject-java-sdk" >> $GITHUB_ENV - echo "TP_SDK_UBER_JAR_EXT=with-dependencies.jar" >> $GITHUB_ENV - echo "TP_SDK_JAR_EXT=.jar" >> $GITHUB_ENV - - name: Upload uberJAR to release - if: startsWith(github.ref, 'refs/tags/v') - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/libs/${{ env.TP_SDK_JAR_NAME }}-${{ env.TP_SDK_VERSION }}-${{ env.TP_SDK_VARIANT}}-${{ env.TP_SDK_UBER_JAR_EXT }} - asset_name: ${{ env.TP_SDK_JAR_NAME }}${{ env.TP_SDK_JAR_EXT }} - tag: ${{ github.ref }} - overwrite: true - - name: Create uberJAR hash file + - name: Define uberJAR file name if: startsWith(github.ref, 'refs/tags/v') run: | - md5sum build/libs/${{ env.TP_SDK_JAR_NAME }}-${{ env.TP_SDK_VERSION }}-${{ env.TP_SDK_VARIANT}}-${{ env.TP_SDK_UBER_JAR_EXT }} > build/libs/jar-hash.md - - name: Upload hash artifact + export TP_SDK_JAR_NAME="testproject-java-sdk.jar" + echo "TP_SDK_JAR_NAME=testproject-java-sdk.jar" >> $GITHUB_ENV + mkdir -p build/libs/upload && cp build/libs/*with-dependencies.jar build/libs/upload/"${TP_SDK_JAR_NAME}" + - name: Upload uberJAR workflow artifact if: startsWith(github.ref, 'refs/tags/v') - uses: svenstaro/upload-release-action@v2 + uses: actions/upload-artifact@v2 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/libs/jar-hash.md - asset_name: ${{ env.TP_SDK_JAR_NAME }}.md5 - tag: ${{ github.ref }} - overwrite: true + name: ${{ env.TP_SDK_JAR_NAME }} + path: build/libs/upload/${{ env.TP_SDK_JAR_NAME }} diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml new file mode 100644 index 00000000..c8a53fc1 --- /dev/null +++ b/.github/workflows/build_release.yml @@ -0,0 +1,44 @@ +# This workflow is triggering the reusable build workflow. +# It's also extend the logic to upload uberJAR, and it's hash as release artifacts. + +name: BuildRelease + +on: + release: + types: [created] + +jobs: + + build_and_test: + uses: ./.github/workflows/build.yml + upload_release_artifacts: + needs: build_and_test + runs-on: ubuntu-latest + steps: + - name: Define uberJAR file name + run: | + export TP_SDK_JAR_NAME="testproject-java-sdk.jar" + echo "TP_SDK_JAR_NAME=testproject-java-sdk.jar" >> $GITHUB_ENV + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.TP_SDK_JAR_NAME }} + - name: Upload uberJAR to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ env.TP_SDK_JAR_NAME }} + asset_name: ${{ env.TP_SDK_JAR_NAME }} + tag: ${{ github.ref }} + overwrite: true + - name: Create uberJAR hash file + run: | + md5sum "${TP_SDK_JAR_NAME}" > ./jar-hash.md + - name: Upload hash artifact + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./jar-hash.md + asset_name: ${{ env.TP_SDK_JAR_NAME }}.md5 + tag: ${{ github.ref }} + overwrite: true \ No newline at end of file diff --git a/.github/workflows/build_snapshot.yml b/.github/workflows/build_snapshot.yml new file mode 100644 index 00000000..f93626d4 --- /dev/null +++ b/.github/workflows/build_snapshot.yml @@ -0,0 +1,9 @@ +name: BuildSnapshot + +on: + push: + branches: [master] + +jobs: + call_workflow: + uses: ./.github/workflows/build.yml \ No newline at end of file