From a51146f1de2c49358aaad30816a870cecaf9d3eb Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Wed, 27 Sep 2023 10:26:22 +0530 Subject: [PATCH 1/5] Add connector release workflow template --- .../release-package-connector-template.yml | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/release-package-connector-template.yml diff --git a/.github/workflows/release-package-connector-template.yml b/.github/workflows/release-package-connector-template.yml new file mode 100644 index 00000000..ec2dd526 --- /dev/null +++ b/.github/workflows/release-package-connector-template.yml @@ -0,0 +1,91 @@ +name: Publish Release + +on: + workflow_call: + inputs: + package-name: + required: true + type: string + package-org: + required: true + type: string + additional-build-flags: + required: false + type: string + default: "" + additional-publish-flags: + required: false + type: string + default: "" + +jobs: + publish-release: + name: Release Package + runs-on: ubuntu-latest + if: github.repository_owner == 'ballerina-platform' + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17.0.7 + + - name: Build without Tests + env: + packageUser: ${{ github.actor }} + packagePAT: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name ${{ secrets.BALLERINA_BOT_USERNAME }} + git config --global user.email ${{ secrets.BALLERINA_BOT_EMAIL }} + ./gradlew build -x check -x test ${{ inputs.additional-build-flags }} + + - name: Create lib Directory if not Exists + run: mkdir -p ballerina/lib + + - name: Run Trivy Vulnerability Scanner + uses: aquasecurity/trivy-action@master + with: + scan-type: "rootfs" + scan-ref: "/github/workspace/ballerina/lib" + format: "table" + timeout: "10m0s" + exit-code: "1" + + - name: Get Release Version + run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV + + - name: Pre-Release Dependency Version Update + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + run: | + echo "Version: ${VERSION}" + git checkout -b release-${VERSION} + sed -i 's/ballerinaLangVersion=\(.*\)-SNAPSHOT/ballerinaLangVersion=\1/g' gradle.properties + sed -i 's/ballerinaLangVersion=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/ballerinaLangVersion=\1/g' gradle.properties + sed -i 's/stdlib\(.*\)=\(.*\)-SNAPSHOT/stdlib\1=\2/g' gradle.properties + sed -i 's/stdlib\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/stdlib\1=\2/g' gradle.properties + sed -i 's/observe\(.*\)=\(.*\)-SNAPSHOT/observe\1=\2/g' gradle.properties + sed -i 's/observe\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/observe\1=\2/g' gradle.properties + git add gradle.properties + git commit -m "Move dependencies to stable versions" || echo "No changes to commit" + + - name: Publish Package + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} + packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + publishUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + publishPAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + run: | + ./gradlew clean release -Prelease.useAutomaticVersion=true + ./gradlew -Pversion=${VERSION} publish -x test -PpublishToCentral=true ${{ inputs.additional-publish-flags }} + + - name: Release Sync PR + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + run: | + gh pr create --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" From f27400b2a9fcc1d6fa0529cd4e660b42a3c3200b Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Wed, 27 Sep 2023 10:28:35 +0530 Subject: [PATCH 2/5] Update connector release workflow name --- .github/workflows/release-package-connector-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-package-connector-template.yml b/.github/workflows/release-package-connector-template.yml index ec2dd526..fd541aa4 100644 --- a/.github/workflows/release-package-connector-template.yml +++ b/.github/workflows/release-package-connector-template.yml @@ -1,4 +1,4 @@ -name: Publish Release +name: Publish Release (Connector) on: workflow_call: From a5dc459a7ae12745f7f16d8c35a888cc7f9a36f3 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Wed, 27 Sep 2023 11:33:41 +0530 Subject: [PATCH 3/5] Address review suggestions --- .../release-package-connector-template.yml | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release-package-connector-template.yml b/.github/workflows/release-package-connector-template.yml index fd541aa4..f119df64 100644 --- a/.github/workflows/release-package-connector-template.yml +++ b/.github/workflows/release-package-connector-template.yml @@ -45,33 +45,9 @@ jobs: - name: Create lib Directory if not Exists run: mkdir -p ballerina/lib - - name: Run Trivy Vulnerability Scanner - uses: aquasecurity/trivy-action@master - with: - scan-type: "rootfs" - scan-ref: "/github/workspace/ballerina/lib" - format: "table" - timeout: "10m0s" - exit-code: "1" - - name: Get Release Version run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV - - name: Pre-Release Dependency Version Update - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - run: | - echo "Version: ${VERSION}" - git checkout -b release-${VERSION} - sed -i 's/ballerinaLangVersion=\(.*\)-SNAPSHOT/ballerinaLangVersion=\1/g' gradle.properties - sed -i 's/ballerinaLangVersion=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/ballerinaLangVersion=\1/g' gradle.properties - sed -i 's/stdlib\(.*\)=\(.*\)-SNAPSHOT/stdlib\1=\2/g' gradle.properties - sed -i 's/stdlib\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/stdlib\1=\2/g' gradle.properties - sed -i 's/observe\(.*\)=\(.*\)-SNAPSHOT/observe\1=\2/g' gradle.properties - sed -i 's/observe\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/observe\1=\2/g' gradle.properties - git add gradle.properties - git commit -m "Move dependencies to stable versions" || echo "No changes to commit" - - name: Publish Package env: GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} @@ -84,8 +60,9 @@ jobs: ./gradlew clean release -Prelease.useAutomaticVersion=true ./gradlew -Pversion=${VERSION} publish -x test -PpublishToCentral=true ${{ inputs.additional-publish-flags }} - - name: Release Sync PR + - name: GitHub Release and Release Sync PR env: GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} run: | + gh release create v$VERSION --title "module-${{ inputs.package-org }}-${{ inputs.package-name }}-v$VERSION" gh pr create --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" From 8b344ce2b5723e7e17c1ab468a00aba9e1376275 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Wed, 27 Sep 2023 12:02:47 +0530 Subject: [PATCH 4/5] Send a PR for the branch that triggered the workflow --- .github/workflows/release-package-connector-template.yml | 2 +- .github/workflows/release-package-template.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-package-connector-template.yml b/.github/workflows/release-package-connector-template.yml index f119df64..e7bec58b 100644 --- a/.github/workflows/release-package-connector-template.yml +++ b/.github/workflows/release-package-connector-template.yml @@ -65,4 +65,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} run: | gh release create v$VERSION --title "module-${{ inputs.package-org }}-${{ inputs.package-name }}-v$VERSION" - gh pr create --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" + gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" diff --git a/.github/workflows/release-package-template.yml b/.github/workflows/release-package-template.yml index a23de7bf..681bccdb 100644 --- a/.github/workflows/release-package-template.yml +++ b/.github/workflows/release-package-template.yml @@ -89,4 +89,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} run: | gh release create v$VERSION --title "module-${{ inputs.package-org }}-${{ inputs.package-name }}-v$VERSION" - gh pr create --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" + gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" From 5892603e6c0524939064f2a543788419c512a03a Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Wed, 27 Sep 2023 12:24:14 +0530 Subject: [PATCH 5/5] Update PR title and body to reflect github base branch --- .github/workflows/release-package-connector-template.yml | 2 +- .github/workflows/release-package-template.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-package-connector-template.yml b/.github/workflows/release-package-connector-template.yml index e7bec58b..2888074d 100644 --- a/.github/workflows/release-package-connector-template.yml +++ b/.github/workflows/release-package-connector-template.yml @@ -65,4 +65,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} run: | gh release create v$VERSION --title "module-${{ inputs.package-org }}-${{ inputs.package-name }}-v$VERSION" - gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" + gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync ${GITHUB_REF##*/} after $VERSION release" --body "Sync ${GITHUB_REF##*/} after $VERSION release" diff --git a/.github/workflows/release-package-template.yml b/.github/workflows/release-package-template.yml index 681bccdb..99f1cade 100644 --- a/.github/workflows/release-package-template.yml +++ b/.github/workflows/release-package-template.yml @@ -89,4 +89,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} run: | gh release create v$VERSION --title "module-${{ inputs.package-org }}-${{ inputs.package-name }}-v$VERSION" - gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" + gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync ${GITHUB_REF##*/} after $VERSION release" --body "Sync ${GITHUB_REF##*/} after $VERSION release"