From 4bbcfa8569cd57818cc3df4bc79d609ad1b719fa Mon Sep 17 00:00:00 2001 From: ori-d Date: Thu, 27 Jan 2022 11:55:07 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=EF=BB=BFci:=20change=20the=20main=20workfl?= =?UTF-8?q?ow=20to=20a=20reusable=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This workflow will triggered by dedicated workflows for snapshot versions and for release versions. Signed-off-by: ori-d --- .github/workflows/build.yml | 45 +++++++++---------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) 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 }} From d41a1efbb1f72b70bf0e43d10759623b0c3575e4 Mon Sep 17 00:00:00 2001 From: ori-d Date: Mon, 31 Jan 2022 18:02:15 +0200 Subject: [PATCH 2/3] ci: add dedicated workflow to run build for any push This workflow run the reusable workflow. Signed-off-by: ori-d --- .github/workflows/build_snapshot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/workflows/build_snapshot.yml 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 From 7423b114acd2503ecad2e7b54aa55a92f52f52f6 Mon Sep 17 00:00:00 2001 From: ori-d Date: Mon, 31 Jan 2022 18:03:17 +0200 Subject: [PATCH 3/3] ci: add dedicated workflow to run build for any release creation. This workflow run the reusable workflow. In addition, it's uploading uberJAR and it's md5 hash to the release artifacts. Signed-off-by: ori-d --- .github/workflows/build_release.yml | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/build_release.yml 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