Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Publish release

on:
workflow_dispatch:

jobs:
publish-release:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 21.0.3

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Set Up Ballerina
uses: ballerina-platform/setup-ballerina@v1.1.1
with:
version: 2201.12.3

- name: Cache Ballerina dependencies
uses: actions/cache@v4
id: cache-ballerina
with:
path: /home/runner/.ballerina/repositories/
key: ${{ runner.os }}-ballerina-${{ hashFiles('**/gradle.properties') }}
restore-keys: |
${{ runner.os }}-ballerina-

- name: Set version env variable
run: echo VERSION=$((grep -w "version" | cut -d= -f2) < gradle.properties | cut -d- -f1) >> $GITHUB_ENV

- name: Pre release depenency version update
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
echo "Version: ${VERSION}"
git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }}
git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }}
git checkout -b release-${VERSION}

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

- name: Release and publish artifacts
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
./gradlew release -Prelease.useAutomaticVersion=true -x test
./gradlew -Pversion=${VERSION} publish -x test

- name: Create Github release from the release tag
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
curl --request POST 'https://api.github.com/repos/ballerina-platform/ballerina-language-server/releases' \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \
--header 'Content-Type: application/json' \
--data-raw '{
"tag_name": "v'"$VERSION"'",
"name": "ballerina-language-server-v'"$VERSION"'"
}'

- name: Post release PR
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub pull-request --base main -m "[Automated] Sync main after "$VERSION" release"
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,3 @@ compileJava {
classpath = files()
}
}

defineSyncTask("bre/lib")
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,3 @@ compileJava {
classpath = files()
}
}

defineSyncTask("lib/tools/lang-server/lib")
116 changes: 36 additions & 80 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,59 +96,6 @@ subprojects {
/* Ballerina Persist Tool */
ballerinaStdLibs "io.ballerina:persist-tools:${persistToolVersion}"
}

ext.defineSyncTask = { String pathParam ->
tasks.register('localSync') {
doLast {
def distVersion = ""
def distributionsDir = new File("${System.getProperty('user.home')}/.ballerina/ballerina-home/distributions/")
if (distributionsDir.exists()) {
def ballerinaDirectories = distributionsDir.listFiles().findAll {
it.isDirectory() && it.name.startsWith("ballerina-")
}

if (ballerinaDirectories) {
ballerinaDirectories.sort { a, b -> b.name <=> a.name }
def latestDir = ballerinaDirectories[0]
distVersion = latestDir.name.substring("ballerina-".length())
} else {
println "No Ballerina distributions found."
return
}
} else {
println "Distributions directory does not exist at: ${distributionsDir.absolutePath}"
return
}

def buildLibsDir = file('build/libs')
def destinationPath = "${System.getProperty('user.home')}/.ballerina/ballerina-home/distributions/ballerina-${distVersion}/${pathParam}"

if (buildLibsDir.exists() && buildLibsDir.listFiles()) {
def jarFiles = buildLibsDir.listFiles().findAll { it.name.endsWith('.jar') }
if (jarFiles) {
// Get module name from the built jar (removing version part)
def jarName = jarFiles[0].name
def moduleJarName = jarName.contains('-') ? jarName.substring(0, jarName.lastIndexOf('-')) : jarName.replace('.jar', '')

def jarsToRemove = fileTree(destinationPath).matching {
include "${moduleJarName}*.jar"
}
if (!jarsToRemove.isEmpty()) {
jarsToRemove.each { jar ->
println "Removing existing jar: ${jar}"
jar.delete()
}
}
}
}
copy {
from fileTree(dir: 'build/libs', include: '*.jar')
println "Updating ${destinationPath}"
into destinationPath
}
}
}
}
}

def moduleVersion = project.version
Expand Down Expand Up @@ -190,37 +137,11 @@ def pullBallerinaModule(String packageName, String version = null, String orgNam
}
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ballerina-platform/ballerina-language-server")
credentials {
username = System.getenv("packageUser")
password = System.getenv("packagePAT")
}
}
}
}

release {
failOnPublishNeeded = false

buildTasks = ['build']
versionPropertyFile = 'gradle.properties'
tagTemplate = 'v${version}'
git {
// To release from any branch
requireBranch = "release-${moduleVersion}"
pushToRemote = 'origin'
}
}


configurations {
externalJarDeps
}

// Defines the third party dependencies to be included in the final JAR
dependencies {
externalJarDeps "org.eclipse.lsp4j:org.eclipse.lsp4j:${eclipseLsp4jVersion}"
externalJarDeps "com.google.code.gson:gson:${gsonVersion}"
Expand All @@ -234,6 +155,7 @@ dependencies {
externalJarDeps "commons-io:commons-io:${commonsIoVersion}"
externalJarDeps "com.google.guava:guava:${guavaVersion}"
externalJarDeps "com.moandjiezana.toml:toml4j:${moandjiezanaToml4jVersion}"
externalJarDeps "com.github.zafarkhaja:java-semver:${javaSemverVersion}"
}

task pack(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
Expand Down Expand Up @@ -320,6 +242,40 @@ task buildCommons {
dependsOn(":model-generator-commons:build")
}

publishing {
publications {
shadow(MavenPublication) { publication ->
publication.artifact(tasks.pack) {
classifier = null
}
from components.java
}
}

repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ballerina-platform/ballerina-language-server")
credentials {
username = System.getenv("packageUser")
password = System.getenv("packagePAT")
}
}
}
}

release {
failOnPublishNeeded = false

buildTasks = ['build']
versionPropertyFile = 'gradle.properties'
tagTemplate = 'v${version}'
git {
// To release from any branch
requireBranch = "release-${moduleVersion}"
pushToRemote = 'origin'
}
}

build.dependsOn test
build.doNotTrackState("build needs to run every time")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ task copyStdlibs() {
}
}

defineSyncTask("bre/lib")

test {
dependsOn {
copyStdlibs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,3 @@ compileJava {
classpath = files()
}
}

defineSyncTask("lib/tools/lang-server/lib")
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ commonsIoVersion=2.15.1
guavaVersion=32.0.1-jre
moandjiezanaToml4jVersion=0.7.2
awaitilityVersion=3.1.6
javaSemverVersion=0.9.0

# Ballerinax Observer
observeVersion=1.5.0-20250311-132700-a89f57a
Expand Down
2 changes: 0 additions & 2 deletions model-generator-commons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,3 @@ compileJava {
classpath = files()
}
}

defineSyncTask("bre/lib")
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,3 @@ compileJava {
classpath = files()
}
}

defineSyncTask("bre/lib")
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,3 @@ compileJava {
classpath = files()
}
}

defineSyncTask("lib/tools/lang-server/lib")
Loading