Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Split workflow to dedicated workflows that are triggering a reusable workflow #172

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 11 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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 }}
44 changes: 44 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions .github/workflows/build_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: BuildSnapshot

on:
push:
branches: [master]

jobs:
call_workflow:
uses: ./.github/workflows/build.yml