From 1e365bc7c3567b23f5cc0cf5956985a8cfc5ed86 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 11 Sep 2023 16:26:33 +0530 Subject: [PATCH 1/5] Migrate workflows to reuse workflows from ballerina-standard-library repo --- .../workflows/build-timestamped-master.yml | 47 ++---------- .github/workflows/central-publish.yml | 72 ++---------------- .github/workflows/publish-release.yml | 76 +++---------------- .github/workflows/pull-request.yml | 56 +++----------- 4 files changed, 33 insertions(+), 218 deletions(-) diff --git a/.github/workflows/build-timestamped-master.yml b/.github/workflows/build-timestamped-master.yml index 52bc406c..9fc193d9 100644 --- a/.github/workflows/build-timestamped-master.yml +++ b/.github/workflows/build-timestamped-master.yml @@ -11,45 +11,8 @@ on: workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest - if: github.repository_owner == 'ballerina-platform' - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17.0.7 - - name: Change to Timestamped Version - run: | - startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00') - latestCommit=$(git log -n 1 --pretty=format:"%h") - VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev) - updatedVersion=$VERSION-$startTime-$latestCommit - echo $updatedVersion - sed -i "s/version=\(.*\)/version=$updatedVersion/g" gradle.properties - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - env: - packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} - packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} - publishUser: ${{ secrets.BALLERINA_BOT_USERNAME }} - publishPAT: ${{ secrets.BALLERINA_BOT_TOKEN }} - run: | - ./gradlew publish --scan --no-daemon - - name: Archive Error Log - uses: actions/upload-artifact@v2 - if: failure() - with: - name: Ballerina Internal Log - path: tcp-ballerina/ballerina-internal.log - if-no-files-found: ignore - - name: Generate CodeCov Report - uses: codecov/codecov-action@v2 - - name: Upload Artifact - uses: actions/upload-artifact@v2 - with: - name: ballerina-runtime - path: target/ballerina-runtime/ + call_workflow: + name: Run Build Workflow + if: ${{ github.repository_owner == 'ballerina-platform' }} + uses: ballerina-platform/ballerina-standard-library/.github/workflows/build-timestamp-master-template.yml@main + secrets: inherit diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 16cf23ef..f3dfd3b4 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -5,73 +5,17 @@ on: inputs: environment: type: choice - description: Select environment + description: Select Environment required: true options: - - CENTRAL - DEV CENTRAL - STAGE CENTRAL jobs: - publish-release: - 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 with Gradle - env: - packageUser: ${{ github.actor }} - packagePAT: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build -x check -x test - - 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: Ballerina Central Push - if: ${{ github.event.inputs.environment == 'CENTRAL' }} - env: - BALLERINA_DEV_CENTRAL: false - BALLERINA_STAGE_CENTRAL: false - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} - packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} - packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - run: | - ./gradlew clean build -PpublishToCentral=true - - name: Ballerina Central Dev Push - if: ${{ github.event.inputs.environment == 'DEV CENTRAL' }} - env: - BALLERINA_DEV_CENTRAL: true - BALLERINA_STAGE_CENTRAL: false - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} - packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} - packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - run: | - sed -i 's/version=\(.*\)-SNAPSHOT/version=\1/g' gradle.properties - ./gradlew clean build -PpublishToCentral=true - - name: Ballerina Central Stage Push - if: ${{ github.event.inputs.environment == 'STAGE CENTRAL' }} - env: - BALLERINA_DEV_CENTRAL: false - BALLERINA_STAGE_CENTRAL: true - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }} - packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} - packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - run: | - sed -i 's/version=\(.*\)-SNAPSHOT/version=\1/g' gradle.properties - ./gradlew clean build -PpublishToCentral=true + call_workflow: + name: Run Central Publish Workflow + if: ${{ github.repository_owner == 'ballerina-platform' }} + uses: ballerina-platform/ballerina-standard-library/.github/workflows/central-publish-template.yml@main + with: + environment: ${{ github.event.inputs.environment }} + secrets: inherit diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index fe87e35d..990d9fc6 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,70 +1,16 @@ -name: Publish release +name: Publish Release on: - workflow_dispatch: - repository_dispatch: - types: [ stdlib-release-pipeline ] + workflow_dispatch: + repository_dispatch: + types: [ stdlib-release-pipeline ] jobs: - publish-release: - runs-on: ubuntu-latest - if: github.repository_owner == 'ballerina-platform' - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17.0.7 - - name: Build with Gradle - 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 - - name: Create lib directory if not exists - run: mkdir -p ballerina/lib - - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master + call_workflow: + name: Run Release Workflow + if: ${{ github.repository_owner == 'ballerina-platform' }} + uses: ballerina-platform/ballerina-standard-library/.github/workflows/release-package-template.yml@main with: - scan-type: 'rootfs' - scan-ref: '/github/workspace/ballerina/lib' - format: 'table' - timeout: '10m0s' - exit-code: '1' - - name: Set version env variable - 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 version" || echo "No changes to commit" - - name: Publish artifact - env: - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} - packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} - packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} - GITHUB_TOKEN: ${{ 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 - - name: GitHub Release and Release Sync PR - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - run: | - gh release create v$VERSION --title "module-ballerina-tcp-v$VERSION" - gh pr create --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release" + package-name: tcp + package-org: ballerina + secrets: inherit diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 56904ad4..55464ce2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,51 +1,13 @@ -name: PR build +name: Pull Request + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true on: pull_request jobs: - ubuntu-build: - name: Build on Ubuntu - runs-on: ubuntu-latest - - 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 with Gradle - env: - packageUser: ${{ github.actor }} - packagePAT: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build --scan - - name: Archive Code Coverage JSON - uses: actions/upload-artifact@v2 - with: - name: Code Coverage JSON - path: tcp-ballerina/target/report/test_results.json - if-no-files-found: ignore - - name: Generate CodeCov Report - if: github.event_name == 'pull_request' - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} - - windows-build: - name: Build on Windows - runs-on: windows-latest - - 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 with Gradle - env: - packageUser: ${{ github.actor }} - packagePAT: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew.bat build --scan + call_workflow: + name: Run PR Build Workflow + if: ${{ github.repository_owner == 'ballerina-platform' }} + uses: ballerina-platform/ballerina-standard-library/.github/workflows/pull-request-build-template.yml@main From a892e52c9979e4f77a7be6ec2021a572713cb22f Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Thu, 14 Sep 2023 15:16:06 +0530 Subject: [PATCH 2/5] [Automated] Update the native jar versions --- ballerina/Dependencies.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index aec8bb2c..acc9272a 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,7 +5,7 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.8.0-20230726-145300-b2bdf796" +distribution-version = "2201.8.0-20230830-220400-8a7556d8" [[package]] org = "ballerina" From 16e6bb8c800f70ad7565a1e1865d25baf6c339f1 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Tue, 19 Sep 2023 10:56:05 +0530 Subject: [PATCH 3/5] Fix secret in release and publish workflows --- .github/workflows/central-publish.yml | 2 +- .github/workflows/publish-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index f3dfd3b4..c0bd478b 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -16,6 +16,6 @@ jobs: name: Run Central Publish Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} uses: ballerina-platform/ballerina-standard-library/.github/workflows/central-publish-template.yml@main + secrets: inherit with: environment: ${{ github.event.inputs.environment }} - secrets: inherit diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 990d9fc6..e91276b9 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -10,7 +10,7 @@ jobs: name: Run Release Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} uses: ballerina-platform/ballerina-standard-library/.github/workflows/release-package-template.yml@main + secrets: inherit with: package-name: tcp package-org: ballerina - secrets: inherit From 227d4ad03a5129c136adc5877e8e430dbfa0dbf3 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Tue, 19 Sep 2023 11:12:36 +0530 Subject: [PATCH 4/5] Update trivy workflow --- .github/workflows/trivy-scan.yml | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index e968e77a..f3b9cbae 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -3,31 +3,11 @@ name: Trivy on: workflow_dispatch: schedule: - - cron: '30 20 * * *' + - cron: "30 20 * * *" jobs: - ubuntu-build: - name: Build on Ubuntu - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17.0.7 - - name: Build with Gradle - env: - packageUser: ${{ github.actor }} - packagePAT: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build -x check -x test - - 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' + call_workflow: + name: Run Trivy Scan Workflow + if: ${{ github.repository_owner == 'ballerina-platform' }} + uses: ballerina-platform/ballerina-standard-library/.github/workflows/trivy-scan-template.yml@main + secrets: inherit From 2f82378b4b9098bad8ed606fd1c8d97954c45332 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Thu, 21 Sep 2023 14:52:53 +0530 Subject: [PATCH 5/5] Revert pull request workflow name --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 55464ce2..5cdb8f7f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,4 +1,4 @@ -name: Pull Request +name: PR Build concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}