From 8181cf2d4fcf25612ef9f301c6e37faf67cae523 Mon Sep 17 00:00:00 2001 From: LauraMoraB Date: Wed, 10 Aug 2022 17:00:53 +0200 Subject: [PATCH 1/2] feat: introduce release process as gh workflow --- .github/workflows/build.yml | 47 +++++++++++++---- .github/workflows/release.yml | 97 +++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 75f36a7fe..c8b926390 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,17 @@ - name: CI -on: [pull_request] +on: + pull_request: + workflow_call: + inputs: + version: + required: true + type: string + outputs: + modules: + description: "Stream reactor collection of modules" + value: ${{ jobs.initiate.outputs.matrix }} + jobs: initiate: timeout-minutes: 5 @@ -11,7 +21,7 @@ jobs: it_matrix: ${{ steps.read-mods.outputs.it-matrix }} fun_matrix: ${{ steps.read-mods.outputs.fun-matrix }} steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v2 with: @@ -28,6 +38,7 @@ jobs: run: sbt generateModulesList generateItModulesList generateFunModulesList env: JVM_OPTS: -Xmx3200m + - name: Read modules lists id: read-mods run: | @@ -45,7 +56,7 @@ jobs: timeout-minutes: 5 runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v2 with: @@ -68,7 +79,7 @@ jobs: matrix: module: ${{fromJSON(needs.initiate.outputs.matrix)}} steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v2 with: @@ -101,7 +112,7 @@ jobs: matrix: module: ${{fromJSON(needs.initiate.outputs.it_matrix)}} steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v2 with: @@ -129,6 +140,7 @@ jobs: build-and-cache-assembly: needs: - initiate + - scalafmt - test - integration-test timeout-minutes: 30 @@ -137,7 +149,10 @@ jobs: matrix: module: ${{fromJSON(needs.initiate.outputs.matrix)}} steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 + name: Checkout repository + with: + fetch-depth: 0 - name: Set up JDK 8 uses: actions/setup-java@v2 with: @@ -150,16 +165,29 @@ jobs: ~/.ivy2/cache ~/.sbt key: ${{ runner.os }}-sbt-${{ hashFiles('*.sbt') }}-${{ hashFiles('project/**') }} + - name: Cache assembly uses: actions/cache@v3 with: path: | ~/**/target/**/libs/*.jar key: ${{ runner.os }}-assembly-${{ matrix.module }}-${{ github.run_id }} + + - name: Get version + id: version + shell: bash + run: | + if [ "${{ inputs.version }}" != "" ]; then + echo "::set-output name=version::${{ inputs.version }}" + else + echo "::set-output name=version::$(git describe --tags --always)" + fi + - name: Build assembly - run: sbt "project ${{ matrix.module }};set assembly / test := {}" assembly env: JVM_OPTS: -Xmx3200m + VERSION: ${{ steps.version.outputs.version }} + run: sbt "project ${{ matrix.module }};set assembly / test := {}" assembly functional-test: needs: @@ -171,7 +199,7 @@ jobs: matrix: module: ${{fromJSON(needs.initiate.outputs.fun_matrix)}} steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Set up JDK 8 uses: actions/setup-java@v2 with: @@ -205,6 +233,7 @@ jobs: upload-assembly: needs: - initiate + - build-and-cache-assembly - functional-test timeout-minutes: 30 runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..fb645ad15 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +name: Publish New Release + +on: + push: + tags: + - "*" + workflow_dispatch: + +jobs: + validate-tag: + runs-on: ubuntu-latest + outputs: + draft_release: ${{ steps.get_tag.outputs.draft_release }} + tag: ${{ steps.get_tag.outputs.tag }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get tag, release mode + shell: bash + id: get_tag + run: | + if [[ ${GITHUB_REF##*/} =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; + then + draft_release=false + + elif [[ ${GITHUB_REF##*/} =~ ^[0-9]\.[0-9]\.[0-9]+(-(alpha|beta|rc)(\.[0-9]+)?)?(\+[A-Za-z0-9.]+)?$ ]]; + then + draft_release=true + else + echo "Existing, github ref needs to be a tag with format x.y.z or x.y.z+(alpha|beta|rc)" + exit 1 + fi + echo "::set-output name=draft_release::$draft_release" + echo "::set-output name=tag::${GITHUB_REF##*/}" + + build: + needs: + - validate-tag + uses: ./.github/workflows/build.yml + with: + version: ${{ needs.validate-tag.outputs.tag }} + secrets: inherit + + create-release: + runs-on: ubuntu-latest + needs: + - validate-tag + - build + strategy: + matrix: + module: ${{fromJSON(needs.build.outputs.modules)}} + env: + DRAFT_RELEASE: '${{ needs.validate-tag.outputs.draft_release }}' + TAG: ${{ needs.validate-tag.outputs.tag }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: Cache SBT + uses: actions/cache@v3 + with: + path: | + ~/.ivy2/cache + ~/.sbt + key: ${{ runner.os }}-sbt-${{ hashFiles('*.sbt') }}-${{ hashFiles('project/**') }} + + - name: Cache assembly + uses: actions/cache@v3 + with: + path: | + ~/**/target/**/libs/*.jar + key: ${{ runner.os }}-assembly-${{ matrix.module }}-${{ github.run_id }} + + - name: Package Connector + shell: bash + run: | + FOLDER=kafka-connect-${{ matrix.module }}-${{ env.TAG }} + mkdir -p $FOLDER + cp **/target/**/libs/*.jar LICENSE $FOLDER/ + zip -r "$FOLDER.zip" $FOLDER/ + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + file: kafka-connect-${{ matrix.module }}-${{ env.TAG }}.zip + asset_name: "kafka-connect-${{ matrix.module }}-${{ env.TAG }}.zip" + release_name: 'Stream Reactor ${{ env.TAG }}' + prerelease: ${{ env.DRAFT_RELEASE }} \ No newline at end of file From fb1720dca768ec8f6cecedb326b8f5a3fb12321d Mon Sep 17 00:00:00 2001 From: LauraMoraB Date: Wed, 10 Aug 2022 17:47:11 +0200 Subject: [PATCH 2/2] chore: comment it tests as dependency to following jobs --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8b926390..b2d949dc8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -142,7 +142,7 @@ jobs: - initiate - scalafmt - test - - integration-test + # - integration-test timeout-minutes: 30 runs-on: ubuntu-latest strategy: