Skip to content

Commit

Permalink
Revert changes to workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sahanHe committed Apr 10, 2024
1 parent 7c7489e commit 9ffcbc5
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 27 deletions.
68 changes: 57 additions & 11 deletions .github/workflows/build-timestamped-master.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,65 @@
name: Build

on:
workflow_dispatch:
push:
branches:
- master
- main
- 2201.[0-9]+.x
paths-ignore:
- "*.md"
- "docs/**"
- "load-tests/**"
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@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: |
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
83 changes: 74 additions & 9 deletions .github/workflows/central-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,83 @@ on:
inputs:
environment:
type: choice
description: Select Environment
description: Select environment
required: true
options:
- CENTRAL
- DEV CENTRAL
- STAGE CENTRAL

jobs:
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
secrets: inherit
with:
environment: ${{ github.event.inputs.environment }}

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: ./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 }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_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 }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_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 }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
run: |
sed -i 's/version=\(.*\)-SNAPSHOT/version=\1/g' gradle.properties
./gradlew clean build -PpublishToCentral=true
34 changes: 27 additions & 7 deletions .github/workflows/trivy-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,32 @@ name: Trivy
on:
workflow_dispatch:
schedule:
- cron: "30 20 * * *"
- cron: '30 20 * * *'

jobs:
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

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'

0 comments on commit 9ffcbc5

Please sign in to comment.