Skip to content

Commit

Permalink
Merge pull request #14 from DimuthuMadushan/update-workflow
Browse files Browse the repository at this point in the history
Add GitHub Release Publish
  • Loading branch information
DimuthuMadushan authored Dec 21, 2023
2 parents d61ba00 + 1a22ec7 commit 01e2506
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 42 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/dev-stage-central-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish to the Ballerina DEV/STAGE Central

on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Select environment
required: true
options:
- DEV CENTRAL
- STAGE CENTRAL

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

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: |
sed -i 's/version=\(.*\)-SNAPSHOT/version=\1/g' gradle.properties
./gradlew clean build
env:
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}

- name: Build the final Copybook tools package using Ballerina
uses: ballerina-platform/ballerina-action/@2201.8.0
with:
args: pack ./copybook-tool
env:
JAVA_HOME: /usr/lib/jvm/default-jvm

- name: Ballerina Central Stage Push
if: ${{ inputs.environment == 'STAGE CENTRAL' }}
uses: ballerina-platform/ballerina-action/@2201.8.0
with:
args: push
env:
WORKING_DIR: ./copybook-tool
BALLERINA_DEV_CENTRAL: false
BALLERINA_STAGE_CENTRAL: true
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
JAVA_HOME: /usr/lib/jvm/default-jvm
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }}

- name: Ballerina Central Dev Push
if: ${{ inputs.environment == 'DEV CENTRAL' }}
uses: ballerina-platform/ballerina-action/@2201.8.0
with:
args: push
env:
WORKING_DIR: ./copybook-tool
BALLERINA_DEV_CENTRAL: true
BALLERINA_STAGE_CENTRAL: false
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
JAVA_HOME: /usr/lib/jvm/default-jvm
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }}
57 changes: 20 additions & 37 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
name: Central Publish
name: Publish release

on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Select environment
required: true
options:
- CENTRAL
- DEV CENTRAL
- STAGE CENTRAL

jobs:
build:
Expand All @@ -25,6 +16,20 @@ jobs:
distribution: 'temurin'
java-version: 17

- 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
git add gradle.properties
git commit -m "Move dependencies to stable versions" || echo "No changes to commit"
- name: Grant execute permission for gradlew
run: chmod +x gradlew

Expand All @@ -44,7 +49,6 @@ jobs:
JAVA_HOME: /usr/lib/jvm/default-jvm

- name: Ballerina Central Push
if: ${{ inputs.environment == 'CENTRAL' }}
uses: ballerina-platform/ballerina-action/@2201.8.0
with:
args: push
Expand All @@ -57,30 +61,9 @@ jobs:
JAVA_HOME: /usr/lib/jvm/default-jvm
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}

- name: Ballerina Central Stage Push
if: ${{ inputs.environment == 'STAGE CENTRAL' }}
uses: ballerina-platform/ballerina-action/@2201.8.0
with:
args: push
- name: GitHub Release and Release Sync PR
env:
WORKING_DIR: ./copybook-tool
BALLERINA_DEV_CENTRAL: false
BALLERINA_STAGE_CENTRAL: true
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
JAVA_HOME: /usr/lib/jvm/default-jvm
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }}

- name: Ballerina Central Dev Push
if: ${{ inputs.environment == 'DEV CENTRAL' }}
uses: ballerina-platform/ballerina-action/@2201.8.0
with:
args: push
env:
WORKING_DIR: ./copybook-tool
BALLERINA_DEV_CENTRAL: true
BALLERINA_STAGE_CENTRAL: false
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
JAVA_HOME: /usr/lib/jvm/default-jvm
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
gh release create v$VERSION --title "copybook-tools-v$VERSION"
gh pr create --base main --title "[Automated] Sync main after $VERSION release" --body "Sync main after $VERSION release"
4 changes: 2 additions & 2 deletions copybook-tool/BalTool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
id = "copybook"

[[dependency]]
path = "build/libs/copybook-cli-0.1.0-SNAPSHOT.jar"
path = "build/libs/copybook-cli-0.1.2-SNAPSHOT.jar"

[[dependency]]
path = "build/libs/antlr4-runtime-4.13.1.jar"

[[dependency]]
path = "build/libs/copybook-commons-0.1.1.jar"
path = "build/libs/copybook-commons-0.2.0.jar"
2 changes: 1 addition & 1 deletion copybook-tool/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "copybook"
version = "0.1.0"
version = "0.1.2"
authors = ["Ballerina"]
keywords = ["copybook", "copybook tool"]
license = ["Apache-2.0"]
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.parallel=true
org.gradle.caching=true

group=io.ballerina
version=0.1.1-SNAPSHOT
version=0.1.2-SNAPSHOT

spotbugsPluginVersion=5.0.14
releasePluginVersion=2.8.0
Expand All @@ -16,4 +16,4 @@ antlrVersion=4.13.1
jacocoVersion=0.8.10

# Ballerinax
copybookParserVersion=0.1.1
copybookParserVersion=0.2.0

0 comments on commit 01e2506

Please sign in to comment.