diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a47dcc7..c1ee3a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,12 +4,39 @@ on: push: branches: - main + paths-ignore: + - '*.md' + workflow_dispatch: jobs: - call_workflow: - name: Run Connector Build Workflow - if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-standard-library/.github/workflows/build-connector-template.yml@main - secrets: inherit - with: - repo-name: module-ballerinax-snowflake.driver + 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: | + 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 }} + run: | + ./gradlew publish --scan --no-daemon + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: ballerina-runtime + path: target/ballerina-runtime/ diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml deleted file mode 100644 index 3f04a29..0000000 --- a/.github/workflows/daily-build.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Daily build - -on: - schedule: - - cron: "30 2 * * *" - -jobs: - call_workflow: - name: Run Daily Build Workflow - if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-standard-library/.github/workflows/daily-build-connector-template.yml@main - secrets: inherit - with: - repo-name: module-ballerinax-snowflake.driver diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07d7a88..9c06f3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,6 @@ -name: Publish Release +# Test cases are disabled in this driver. It is recommended to test the driver with Staging Central and Dev Central +# before publishing to Ballerina Central. +name: Publish release on: workflow_dispatch: @@ -6,11 +8,62 @@ on: 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-connector-template.yml@main - secrets: inherit - with: - package-name: snowflake.driver - 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 + 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 }} + 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-snowflake.driver-v$VERSION" + gh pr create --title "[Automated] Sync main after $VERSION release" --body "Sync main after $VERSION release"