From eb09e12921c29a4d3ea41ab07de679bdd542c0a1 Mon Sep 17 00:00:00 2001 From: Sahan Hemachandra <45299562+sahanHe@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:58:23 +0530 Subject: [PATCH] Revert changes to publish-release and build-timestamped-master workflows --- .../workflows/build-timestamped-master.yml | 63 ++++++++++++--- .github/workflows/publish-release.yml | 80 ++++++++++++++++--- 2 files changed, 124 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-timestamped-master.yml b/.github/workflows/build-timestamped-master.yml index 00662e0..2798d13 100644 --- a/.github/workflows/build-timestamped-master.yml +++ b/.github/workflows/build-timestamped-master.yml @@ -1,19 +1,64 @@ name: Build on: + workflow_dispatch: push: branches: - main - 2201.[0-9]+.x paths-ignore: - - "*.md" - - "docs/**" - - workflow_dispatch: + - 'load-tests/**' + - '*.md' + - 'docs/**' jobs: - 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 + build: + runs-on: ubuntu-latest + if: github.repository_owner == 'ballerina-platform' + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 17.0.7 + - name: Change to Timestamped Version + run: | + initialVersion=$((grep -w 'version' | cut -d= -f2) < gradle.properties ) + echo "Initial_Version=$initialVersion" >> $GITHUB_ENV + 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: Build with Gradle + env: + packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + publishUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + publishPAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + run: | + ./gradlew clean build publishAllPublicationsToGitHubPackagesRepository --scan --no-daemon + - 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/ + - name: Revert to SNAPSHOT Version + run: | + echo "version=${{ env.Initial_Version }}" + sed -i "s/version=\(.*\)/version=${{ env.Initial_Version }}/g" gradle.properties + - name: Publish to Nexus + env: + packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + nexusUser: ${{ secrets.NEXUS_USERNAME }} + nexusPassword: ${{ secrets.NEXUS_PASSWORD }} + run: | + ./gradlew clean publishMavenJavaPublicationToWSO2NexusRepository -x test --scan --no-daemon \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 2ca2b0e..76ec44b 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,16 +1,76 @@ -name: Publish Release +name: Publish release on: workflow_dispatch: repository_dispatch: - types: [stdlib-release-pipeline] + types: [ stdlib-release-pipeline ] jobs: - 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 - secrets: inherit - with: - package-name: persist.sql - package-org: ballerinax + publish-release: + runs-on: ubuntu-latest + if: github.repository_owner == 'ballerina-platform' + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + 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 + 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: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Publish artifact + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + publishUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + publishPAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + nexusUser: ${{ secrets.NEXUS_USERNAME }} + nexusPassword: ${{ secrets.NEXUS_PASSWORD }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + REFRESH_TOKEN: ${{ secrets.REFRESH_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-ballerinax-persist.sql-v$VERSION" + gh pr create --title "[Automated] Sync main after $VERSION release" --body "Sync main after $VERSION release" \ No newline at end of file