From c5e0e30b0f689b879b3e258adffea42e8e57a733 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 26 Sep 2024 07:55:16 +0530 Subject: [PATCH 01/80] Add regexp find operations bbe --- examples/index.json | 7 +++ .../regexp_find_operations.bal | 55 +++++++++++++++++++ .../regexp_find_operations.md | 13 +++++ .../regexp_find_operations.metatags | 2 + .../regexp_find_operations.out | 23 ++++++++ 5 files changed, 100 insertions(+) create mode 100644 examples/regexp-find-operations/regexp_find_operations.bal create mode 100644 examples/regexp-find-operations/regexp_find_operations.md create mode 100644 examples/regexp-find-operations/regexp_find_operations.metatags create mode 100644 examples/regexp-find-operations/regexp_find_operations.out diff --git a/examples/index.json b/examples/index.json index f8b606bbbc..43003c19c2 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1201,6 +1201,13 @@ "verifyBuild": true, "verifyOutput": true, "isLearnByExample": true + }, + { + "name": "RegExp find operations", + "url": "regexp-find-operations", + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true } ] }, diff --git a/examples/regexp-find-operations/regexp_find_operations.bal b/examples/regexp-find-operations/regexp_find_operations.bal new file mode 100644 index 0000000000..0879269e08 --- /dev/null +++ b/examples/regexp-find-operations/regexp_find_operations.bal @@ -0,0 +1,55 @@ +import ballerina/io; +import ballerina/lang.regexp; + +function printGroupsWithinLog(regexp:Groups logGroup) { + // The first element in the `logGroup` is the entire matched string. + // The subsequent elements in `logGroup` represent the captured groups + // (timestamp, component, message). + string timestamp = (logGroup[1]).substring(); + string component = (logGroup[2]).substring(); + string logMessage = (logGroup[3]).substring(); + + io:println(string `Timestamp: ${timestamp}`); + io:println(string `Component: ${component}`); + io:println(string `Message: ${logMessage}`); +} + +public function main() { + string logContent = string ` + 2024-09-19 10:02:01 WARN [UserLogin] - Failed login attempt for user: johndoe + 2024-09-19 10:03:17 ERROR [Database] - Connection to database timed out + 2024-09-19 10:04:05 WARN [RequestHandler] - Response time exceeded threshold for /api/v1/users + 2024-09-19 10:05:45 INFO [Scheduler] - Scheduled task started: Data backup + 2024-09-19 10:06:10 ERROR [Scheduler] - Failed to start data backup: Permission denied + 2024-09-19 10:11:55 INFO [Security] - Security scan completed, no issues found + 2024-09-19 10:12:30 ERROR [RequestHandler] - 404 Not Found: /api/v1/products`; + + // Regex to match error logs with three groups: + // 1. Timestamp (e.g., 2024-09-19 10:03:17). + // 2. Component (e.g., Database, Scheduler). + // 3. Log message (e.g., Connection to database timed out). + string:RegExp errorLogPattern = re `(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ERROR \[(\w+)\] - (.*)`; + + // Retrieving the first error log from the `logContent`. + regexp:Span firstErrorLog = errorLogPattern.find(logContent); + io:println(string `First error log: ${firstErrorLog.substring()}`); + + // Retrieving all error logs from the `logContent`. + regexp:Span[] allErrorLogs = errorLogPattern.findAll(logContent); + io:println("All error logs:"); + foreach regexp:Span errorLog in allErrorLogs { + io:println(errorLog.substring()); + } + + // Retrieving groups (timestamp, component, message) from the first error log. + regexp:Groups firstErrorLogGroups = errorLogPattern.findGroups(logContent); + io:println("\nGroups within first error log:"); + printGroupsWithinLog(firstErrorLogGroups); + + // Retrieving groups from all error logs. + regexp:Groups[] allErrorLogGroups = errorLogPattern.findAllGroups(logContent); + io:println("\nGroups in all error logs"); + foreach regexp:Groups logGroup in allErrorLogGroups { + printGroupsWithinLog(logGroup); + } +} diff --git a/examples/regexp-find-operations/regexp_find_operations.md b/examples/regexp-find-operations/regexp_find_operations.md new file mode 100644 index 0000000000..00c62d1c5e --- /dev/null +++ b/examples/regexp-find-operations/regexp_find_operations.md @@ -0,0 +1,13 @@ +# RegExp find operations + +The `RegExp` type provides a set of language library functions to find patterns within strings. These functions enable efficient pattern matching, grouping, and extraction based on specific regular expressions. + + +::: code regexp_find_operations.bal ::: + +::: out regexp_find_operations.out ::: + +## Related links +- [RegExp type](/learn/by-example/regexp-type) +- [RegExp API Docs](https://lib.ballerina.io/ballerina/lang.regexp) +- [string API Docs](https://lib.ballerina.io/ballerina/lang.string) diff --git a/examples/regexp-find-operations/regexp_find_operations.metatags b/examples/regexp-find-operations/regexp_find_operations.metatags new file mode 100644 index 0000000000..a88701759c --- /dev/null +++ b/examples/regexp-find-operations/regexp_find_operations.metatags @@ -0,0 +1,2 @@ +description: This BBE demonstrates how to use the regexp langlib functions relevant to regex find operations. +keywords: ballerina, ballerina by example, bbe, regexp, RegExp, regex, regular expressions, ballerina regex functions, regexp langlib functions, find, findAll, findGroups, findAllGroups diff --git a/examples/regexp-find-operations/regexp_find_operations.out b/examples/regexp-find-operations/regexp_find_operations.out new file mode 100644 index 0000000000..5e9a9f4454 --- /dev/null +++ b/examples/regexp-find-operations/regexp_find_operations.out @@ -0,0 +1,23 @@ +$ bal run regexp_find_operations.bal +First error log: 2024-09-19 10:03:17 ERROR [Database] - Connection to database timed out +All error logs: +2024-09-19 10:03:17 ERROR [Database] - Connection to database timed out +2024-09-19 10:06:10 ERROR [Scheduler] - Failed to start data backup: Permission denied +2024-09-19 10:12:30 ERROR [RequestHandler] - 404 Not Found: /api/v1/products + +Groups within first error log: +Timestamp: 2024-09-19 10:03:17 +Component: Database +Message: Connection to database timed out + +Groups in all error logs +Timestamp: 2024-09-19 10:03:17 +Component: Database +Message: Connection to database timed out +Timestamp: 2024-09-19 10:06:10 +Component: Scheduler +Message: Failed to start data backup: Permission denied +Timestamp: 2024-09-19 10:12:30 +Component: RequestHandler +Message: 404 Not Found: /api/v1/products +➜ From f3c2c3263755cbad070cc0000bc38079866dfb41 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 26 Sep 2024 10:58:40 +0530 Subject: [PATCH 02/80] Update function order --- .../regexp_find_operations.bal | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/regexp-find-operations/regexp_find_operations.bal b/examples/regexp-find-operations/regexp_find_operations.bal index 0879269e08..15cfe0e3ce 100644 --- a/examples/regexp-find-operations/regexp_find_operations.bal +++ b/examples/regexp-find-operations/regexp_find_operations.bal @@ -1,19 +1,6 @@ import ballerina/io; import ballerina/lang.regexp; -function printGroupsWithinLog(regexp:Groups logGroup) { - // The first element in the `logGroup` is the entire matched string. - // The subsequent elements in `logGroup` represent the captured groups - // (timestamp, component, message). - string timestamp = (logGroup[1]).substring(); - string component = (logGroup[2]).substring(); - string logMessage = (logGroup[3]).substring(); - - io:println(string `Timestamp: ${timestamp}`); - io:println(string `Component: ${component}`); - io:println(string `Message: ${logMessage}`); -} - public function main() { string logContent = string ` 2024-09-19 10:02:01 WARN [UserLogin] - Failed login attempt for user: johndoe @@ -53,3 +40,16 @@ public function main() { printGroupsWithinLog(logGroup); } } + +function printGroupsWithinLog(regexp:Groups logGroup) { + // The first element in the `logGroup` is the entire matched string. + // The subsequent elements in `logGroup` represent the captured groups + // (timestamp, component, message). + string timestamp = (logGroup[1]).substring(); + string component = (logGroup[2]).substring(); + string logMessage = (logGroup[3]).substring(); + + io:println(string `Timestamp: ${timestamp}`); + io:println(string `Component: ${component}`); + io:println(string `Message: ${logMessage}`); +} From 1b556ff359e6fb73998dd6543ec609ae11f1d7bd Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Fri, 27 Sep 2024 09:56:33 +0530 Subject: [PATCH 03/80] Address review suggestions --- .../regexp_find_operations.bal | 20 +++++++++++++------ .../regexp_find_operations.md | 1 - 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/regexp-find-operations/regexp_find_operations.bal b/examples/regexp-find-operations/regexp_find_operations.bal index 15cfe0e3ce..2034f1ca71 100644 --- a/examples/regexp-find-operations/regexp_find_operations.bal +++ b/examples/regexp-find-operations/regexp_find_operations.bal @@ -15,27 +15,35 @@ public function main() { // 1. Timestamp (e.g., 2024-09-19 10:03:17). // 2. Component (e.g., Database, Scheduler). // 3. Log message (e.g., Connection to database timed out). - string:RegExp errorLogPattern = re `(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ERROR \[(\w+)\] - (.*)`; + string:RegExp errorLogPattern = re `(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ERROR \[(\w+)\]\s-\s(.*)`; // Retrieving the first error log from the `logContent`. - regexp:Span firstErrorLog = errorLogPattern.find(logContent); + regexp:Span? firstErrorLog = errorLogPattern.find(logContent); + if firstErrorLog == () { + io:println("Failed to find a error log"); + return; + } io:println(string `First error log: ${firstErrorLog.substring()}`); // Retrieving all error logs from the `logContent`. regexp:Span[] allErrorLogs = errorLogPattern.findAll(logContent); - io:println("All error logs:"); + io:println("\n", "All error logs:"); foreach regexp:Span errorLog in allErrorLogs { io:println(errorLog.substring()); } // Retrieving groups (timestamp, component, message) from the first error log. - regexp:Groups firstErrorLogGroups = errorLogPattern.findGroups(logContent); - io:println("\nGroups within first error log:"); + regexp:Groups? firstErrorLogGroups = errorLogPattern.findGroups(logContent); + if firstErrorLogGroups == () { + io:println("Failed to find groups in first error log"); + return; + } + io:println("\n", "Groups within first error log:"); printGroupsWithinLog(firstErrorLogGroups); // Retrieving groups from all error logs. regexp:Groups[] allErrorLogGroups = errorLogPattern.findAllGroups(logContent); - io:println("\nGroups in all error logs"); + io:println("\n", "Groups in all error logs"); foreach regexp:Groups logGroup in allErrorLogGroups { printGroupsWithinLog(logGroup); } diff --git a/examples/regexp-find-operations/regexp_find_operations.md b/examples/regexp-find-operations/regexp_find_operations.md index 00c62d1c5e..850ed3b18a 100644 --- a/examples/regexp-find-operations/regexp_find_operations.md +++ b/examples/regexp-find-operations/regexp_find_operations.md @@ -2,7 +2,6 @@ The `RegExp` type provides a set of language library functions to find patterns within strings. These functions enable efficient pattern matching, grouping, and extraction based on specific regular expressions. - ::: code regexp_find_operations.bal ::: ::: out regexp_find_operations.out ::: From d88fe10b786dc1ae58aa4a5808b9bb4db0e85b74 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Fri, 27 Sep 2024 09:58:01 +0530 Subject: [PATCH 04/80] Update out --- examples/regexp-find-operations/regexp_find_operations.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/regexp-find-operations/regexp_find_operations.out b/examples/regexp-find-operations/regexp_find_operations.out index 5e9a9f4454..23aac6565e 100644 --- a/examples/regexp-find-operations/regexp_find_operations.out +++ b/examples/regexp-find-operations/regexp_find_operations.out @@ -1,5 +1,6 @@ $ bal run regexp_find_operations.bal First error log: 2024-09-19 10:03:17 ERROR [Database] - Connection to database timed out + All error logs: 2024-09-19 10:03:17 ERROR [Database] - Connection to database timed out 2024-09-19 10:06:10 ERROR [Scheduler] - Failed to start data backup: Permission denied @@ -20,4 +21,3 @@ Message: Failed to start data backup: Permission denied Timestamp: 2024-09-19 10:12:30 Component: RequestHandler Message: 404 Not Found: /api/v1/products -➜ From ff64dffa674b0b1d8060461f8855ad27dc1f2335 Mon Sep 17 00:00:00 2001 From: hindujaB Date: Mon, 7 Oct 2024 14:32:00 +0530 Subject: [PATCH 05/80] Improve configurability BBE --- examples/configurable-variables/configurable_variables.bal | 7 +++++++ examples/configurable-variables/configurable_variables.md | 4 ++++ examples/configurable-variables/configurable_variables.out | 2 ++ examples/configuring-via-toml/configuring-via-toml.md | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/examples/configurable-variables/configurable_variables.bal b/examples/configurable-variables/configurable_variables.bal index 880933310d..b24c014db0 100644 --- a/examples/configurable-variables/configurable_variables.bal +++ b/examples/configurable-variables/configurable_variables.bal @@ -1,5 +1,12 @@ +import ballerina/io; + // The host of the database server. The default value is `localhost`. configurable string dbHost = "localhost"; // This specifies that the password must be supplied in a configuration file. configurable string password = ?; + +public function main() { + io:println("host: ", hostName); + io:println("password: ", password); +} diff --git a/examples/configurable-variables/configurable_variables.md b/examples/configurable-variables/configurable_variables.md index 2d43fd239a..1201ab355e 100644 --- a/examples/configurable-variables/configurable_variables.md +++ b/examples/configurable-variables/configurable_variables.md @@ -6,4 +6,8 @@ For more information, see [Configure a sample Ballerina service](/learn/configur ::: code configurable_variables.bal ::: +To run the example, copy the following content to a file named `Config.toml` in the current directory. + +::: code Config.toml ::: + ::: out configurable_variables.out ::: \ No newline at end of file diff --git a/examples/configurable-variables/configurable_variables.out b/examples/configurable-variables/configurable_variables.out index 3f29ebe387..048dd2bc4d 100644 --- a/examples/configurable-variables/configurable_variables.out +++ b/examples/configurable-variables/configurable_variables.out @@ -1 +1,3 @@ $ bal run configurable_variables.bal +host: localhost +password: password diff --git a/examples/configuring-via-toml/configuring-via-toml.md b/examples/configuring-via-toml/configuring-via-toml.md index 8d96d2ed29..1790f26275 100644 --- a/examples/configuring-via-toml/configuring-via-toml.md +++ b/examples/configuring-via-toml/configuring-via-toml.md @@ -10,4 +10,8 @@ For more information, see [Configure via TOML syntax](/learn/provide-values-to-c ::: code configuring_via_toml.bal ::: +To run the example, copy the following content to a file named `Config.toml` in the current directory. + +::: code Config.toml ::: + ::: out configuring_via_toml.out ::: From 5b2d87dd3f077969d7442b511f8c2507c0971222 Mon Sep 17 00:00:00 2001 From: hindujaB Date: Mon, 7 Oct 2024 14:45:08 +0530 Subject: [PATCH 06/80] Only include outputs in toml BBE --- examples/configurable-variables/configurable_variables.bal | 7 ------- examples/configurable-variables/configurable_variables.md | 6 +----- examples/configurable-variables/configurable_variables.out | 2 -- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/examples/configurable-variables/configurable_variables.bal b/examples/configurable-variables/configurable_variables.bal index b24c014db0..880933310d 100644 --- a/examples/configurable-variables/configurable_variables.bal +++ b/examples/configurable-variables/configurable_variables.bal @@ -1,12 +1,5 @@ -import ballerina/io; - // The host of the database server. The default value is `localhost`. configurable string dbHost = "localhost"; // This specifies that the password must be supplied in a configuration file. configurable string password = ?; - -public function main() { - io:println("host: ", hostName); - io:println("password: ", password); -} diff --git a/examples/configurable-variables/configurable_variables.md b/examples/configurable-variables/configurable_variables.md index 1201ab355e..4c76651c44 100644 --- a/examples/configurable-variables/configurable_variables.md +++ b/examples/configurable-variables/configurable_variables.md @@ -6,8 +6,4 @@ For more information, see [Configure a sample Ballerina service](/learn/configur ::: code configurable_variables.bal ::: -To run the example, copy the following content to a file named `Config.toml` in the current directory. - -::: code Config.toml ::: - -::: out configurable_variables.out ::: \ No newline at end of file +::: out configurable_variables.out ::: diff --git a/examples/configurable-variables/configurable_variables.out b/examples/configurable-variables/configurable_variables.out index 048dd2bc4d..3f29ebe387 100644 --- a/examples/configurable-variables/configurable_variables.out +++ b/examples/configurable-variables/configurable_variables.out @@ -1,3 +1 @@ $ bal run configurable_variables.bal -host: localhost -password: password From 2c994134ff809e6acccdaebc998052446658d369 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Thu, 10 Oct 2024 16:51:00 +0530 Subject: [PATCH 07/80] Update SQL version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9ad2180de2..53365f7614 100644 --- a/gradle.properties +++ b/gradle.properties @@ -71,7 +71,7 @@ stdlibWebsubhubVersion=1.12.0 # Stdlib Level 07 stdlibGraphqlVersion=1.14.0 -stdlibSqlVersion=1.14.0 +stdlibSqlVersion=1.14.1 # Persist Tool persistToolVersion=1.4.0 From a9143c723d1b89f2e3df5e4b7c946d465130b7a3 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Thu, 10 Oct 2024 21:23:35 +0530 Subject: [PATCH 08/80] Create linux-arm zip and installer --- .github/workflows/daily-build.yml | 48 +++++++- ballerina/build.gradle | 106 +++++++++++++++++- gradle.properties | 2 +- .../build-ballerina-linux-deb-x64.sh | 24 +++- 4 files changed, 174 insertions(+), 6 deletions(-) diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index 4ec41b9db9..1fdb034ca6 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -80,6 +80,16 @@ jobs: with: name: Linux Installer rpm path: installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-*-linux-x64.rpm + - name: Archive Linux Installer ZIP + uses: actions/upload-artifact@v4 + with: + name: Linux Installer ZIP + path: ballerina/build/distributions/ballerina-*-linux.zip + - name: Archive Linux-ARM Installer ZIP + uses: actions/upload-artifact@v4 + with: + name: Linux-ARM Installer ZIP + path: ballerina/build/distributions/ballerina-*-linux-arm.zip - name: Archive MacOS Installer ZIP uses: actions/upload-artifact@v4 with: @@ -308,6 +318,42 @@ jobs: env: TEST_MODE_ACTIVE: true + ubuntu-arm-installer-build: + + needs: ubuntu-build + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17.0.7' + - name: Download Linux-ARM Installer Zip + uses: actions/download-artifact@v4 + with: + name: Linux-ARM Installer ZIP + - name: Create linux-arm deb + working-directory: installers/linux-deb + run: | + ./build-ballerina-linux-deb-x64.sh -v ${{ needs.ubuntu-build.outputs.project-version }} -p ./../../ -a arm + echo "Created linux-arm-deb successfully" + - name: Generate Hashes + run: | + openssl dgst -sha256 -out ballerina-${{ needs.ubuntu-build.outputs.project-version }}-linux-arm-x64.deb.sha256 installers/linux-deb/target/ballerina-*-linux-arm-x64.deb + - name: Archive Linux deb + uses: actions/upload-artifact@v4 + with: + name: Linux-ARM Installer deb + path: installers/linux-deb/target/ballerina-*-linux-arm-x64.deb + - name: Archive Linux deb Hashes + uses: actions/upload-artifact@v4 + with: + name: Linux deb Hashes + path: ballerina-${{ needs.ubuntu-build.outputs.project-version }}-linux-arm-x64.deb.sha256 + macos-installer-build: needs: ubuntu-build @@ -321,7 +367,7 @@ jobs: with: distribution: 'temurin' java-version: '17.0.7' - - name: Download MacOS Intaller Zip + - name: Download MacOS Installer Zip uses: actions/download-artifact@v4 with: name: MacOS Installer ZIP diff --git a/ballerina/build.gradle b/ballerina/build.gradle index 33faa07371..1f2dcb712f 100644 --- a/ballerina/build.gradle +++ b/ballerina/build.gradle @@ -33,6 +33,7 @@ configurations { jBallerinaDistribution ballerinaDistribution ballerinaLinuxDistribution + ballerinaLinuxArmDistribution ballerinaMacDistribution ballerinaMacArmDistribution ballerinaWindowsDistribution @@ -47,6 +48,7 @@ dependencies { def jBallerinaDistributionZip = file("$project.buildDir/distributions/ballerina-${shortVersion}.zip") def ballerinaDistributionZip = file("$project.buildDir/distributions/ballerina-${ballerinaLangVersion}.zip") def ballerinaLinuxDistributionZip = file("$project.buildDir/distributions/ballerina-linux-${ballerinaLangVersion}.zip") +def ballerinaLinuxArmDistributionZip = file("$project.buildDir/distributions/ballerina-linux-arm-${ballerinaLangVersion}.zip") def ballerinaMacDistributionZip = file("$project.buildDir/distributions/ballerina-macos-${ballerinaLangVersion}.zip") def ballerinaMacArmDistributionZip = file("$project.buildDir/distributions/ballerina-macos-arm-${ballerinaLangVersion}.zip") def ballerinaWindowsDistributionZip = file("$project.buildDir/distributions/ballerina-windows-${ballerinaLangVersion}.zip") @@ -56,6 +58,8 @@ task unpackBallerinaJre(type: Download) { def jreBaseURL = "https://github.com/ballerina-platform/ballerina-custom-jre/releases/download/${ballerinaJreVersion}" src([ "${jreBaseURL}/ballerina-jre-linux-64-${ballerinaJreVersion}.zip", + "${jreBaseURL}/ballerina-jre-linux-arm-64-${ballerinaJreVersion}.zip", +// "https://github.com/NipunaMadhushan/ballerina-examples/releases/download/test-1.0.0/ballerina-jre-linux-arm-64-${ballerinaJreVersion}.zip", "${jreBaseURL}/ballerina-jre-macos-64-${ballerinaJreVersion}.zip", "${jreBaseURL}/ballerina-jre-macos-arm-64-${ballerinaJreVersion}.zip", "${jreBaseURL}/ballerina-jre-win-64-${ballerinaJreVersion}.zip" @@ -167,6 +171,12 @@ task extractJreForLinux(type: Copy) { into("${buildDir}/target/extracted-jre-linux") } +task extractJreForLinuxArm(type: Copy) { + group = "extract_jre" + from zipTree { "${jreLocation}/ballerina-jre-linux-arm-64-${ballerinaJreVersion}.zip" } + into("${buildDir}/target/extracted-jre-linux-arm") +} + task extractJreForMac(type: Copy) { group = "extract_jre" from zipTree { "${jreLocation}/ballerina-jre-macos-64-${ballerinaJreVersion}.zip" } @@ -536,6 +546,95 @@ task packageDistLinux(type: Zip) { outputs.file ballerinaLinuxDistributionZip } +task packageDistLinuxArm(type: Zip) { + group = "package_distribution" + description = 'Ballerina Linux-ARM Distribution Assembly' + ext { + baseName = "${distributionName}-${version}" + parentDir = "${baseName}-${codeName}-linux-arm" + } + archiveFileName = "${parentDir}.zip" + entryCompression = ZipEntryCompression.DEFLATED + + into("${parentDir}/dependencies") { + from "build/target/extracted-jre-linux-arm" + fileMode = 0755 + } + into("${parentDir}/distributions/ballerina-${shortVersion}/examples/") { + from "${project.rootDir}/examples/" + fileMode = 0755 + } + // Code2Cloud Extension Examples + into("${parentDir}/distributions/ballerina-${shortVersion}/examples") { + from "build/target/extracted-distributions/c2c-examples-zip" + exclude "index.js" + } + + /* Tools artifacts */ + into("${parentDir}/distributions/ballerina-${shortVersion}") { + from "build/target/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}" + exclude "distributions/ballerina-version" + exclude "distributions/installer-version" + exclude "/bin/bal.bat" + exclude "/bin/version.txt" + exclude "/LICENSE" + } + into("${parentDir}") { + from "../resources/tools" + exclude "distributions/ballerina-version" + exclude "distributions/installer-version" + exclude "**/scripts/**" + } + + /* Files */ + into("${parentDir}/distributions/ballerina-${shortVersion}") { + from "LICENSE" + } + into("${parentDir}/distributions/ballerina-${shortVersion}/bin") { + from "lib/version.txt" + fileMode = 0644 + filter(ReplaceTokens, tokens: [version: version]) + } + into("${parentDir}/distributions") { + from "../resources/tools/distributions/ballerina-version" + fileMode = 0644 + filter(ReplaceTokens, tokens: [version: shortVersion]) + } + into("${parentDir}/distributions") { + from "../resources/tools/distributions/installer-version" + fileMode = 0644 + filter(ReplaceTokens, tokens: [uuid: installerVersion]) + } + into("${parentDir}/bin") { + from "build/target/ballerina-command-${ballerinaCommandVersion}/bin/bal" + fileMode = 775 + filter(ReplaceTokens, tokens: [ballerinaCommandVersion: ballerinaCommandVersion]) + } + into("${parentDir}/lib") { + from "build/target/ballerina-command-${ballerinaCommandVersion}/lib/ballerina-command-${ballerinaCommandVersion}.jar" + fileMode = 0775 + } + into("${parentDir}/scripts") { + from "build/target/ballerina-command-${ballerinaCommandVersion}/scripts/bal_completion.bash" + fileMode = 775 + } + into("${parentDir}/scripts") { + from "build/target/ballerina-command-${ballerinaCommandVersion}/scripts/_bal" + fileMode = 775 + } + + /* Dependencies */ + into("${parentDir}/distributions/ballerina-${shortVersion}/bre/lib") { + from configurations.exten + } + + doLast { + println 'Ballerina Linux-ARM Distribution Packaged' + } + + outputs.file ballerinaLinuxArmDistributionZip +} + task packageDistMac(type: Zip) { group = "package_distribution" description = 'Ballerina MacOS Distribution Assembly' @@ -791,6 +890,7 @@ artifacts { jBallerinaDistribution file: jBallerinaDistributionZip, builtBy: packageDist ballerinaDistribution file: ballerinaDistributionZip, builtBy: packageDistZip ballerinaLinuxDistribution file: ballerinaLinuxDistributionZip, builtBy: packageDistLinux + ballerinaLinuxArmDistribution file: ballerinaLinuxArmDistributionZip, builtBy: packageDistLinuxArm ballerinaMacDistribution file: ballerinaMacDistributionZip, builtBy: packageDistMac ballerinaMacArmDistribution file: ballerinaMacArmDistributionZip, builtBy: packageDistMacArm ballerinaWindowsDistribution file: ballerinaWindowsDistributionZip, builtBy: packageDistWindows @@ -1521,7 +1621,8 @@ generateCache.dependsOn copyDevToolsDocUi /* Extract JRE */ extractJreForLinux.dependsOn unpackBalCommand extractJreForMac.dependsOn extractJreForLinux -extractJreForMacArm.dependsOn extractJreForMac +extractJreForLinuxArm.dependsOn extractJreForMac +extractJreForMacArm.dependsOn extractJreForLinuxArm extractJreForWindows.dependsOn extractJreForMacArm copyOtherRepos.dependsOn extractJreForWindows @@ -1540,7 +1641,8 @@ packageDist.dependsOn generateCache packageDistZip.dependsOn packageDist packageDistLinux.dependsOn packageDistZip packageDistLinux.dependsOn unzipDistForTests -packageDistMac.dependsOn packageDistLinux +packageDistLinuxArm.dependsOn packageDistLinux +packageDistMac.dependsOn packageDistLinuxArm packageDistMacArm.dependsOn packageDistMac packageDistWindows.dependsOn packageDistMacArm unzipDistForTests.dependsOn packageDistZip diff --git a/gradle.properties b/gradle.properties index 9ad2180de2..6b68b60468 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ version=2201.11.0-SNAPSHOT codeName=swan-lake ballerinaLangVersion=2201.10.0 -ballerinaJreVersion=2.0.0 +ballerinaJreVersion=2.0.1 dependencyJREVersion=jdk-17.0.7+7-jre specVersion=2024R1 slf4jVersion=1.7.30 diff --git a/installers/linux-deb/build-ballerina-linux-deb-x64.sh b/installers/linux-deb/build-ballerina-linux-deb-x64.sh index 03a9fbeddc..10428fb66b 100755 --- a/installers/linux-deb/build-ballerina-linux-deb-x64.sh +++ b/installers/linux-deb/build-ballerina-linux-deb-x64.sh @@ -8,6 +8,10 @@ function printUsage() { echo " version of the ballerina distribution" echo " -p (--path)" echo " path of the ballerina distributions" + echo " -a (--arch)" + echo " architecture of the ballerina distribution" + echo " If not specified : x86" + echo " arm : aarch64/arm64" echo " -d (--dist)" echo " ballerina distribution type either of the followings" echo " If not specified both distributions will be built" @@ -34,6 +38,11 @@ case ${key} in shift # past argument shift # past value ;; + -a|--arch) + ARCH="$2" + shift # past argument + shift # past value + ;; -d|--dist) DISTRIBUTION="$2" shift # past argument @@ -62,8 +71,19 @@ if [ -z "$DISTRIBUTION" ]; then BUILD_ALL_DISTRIBUTIONS=true fi +if [ -z "$ARCH" ]; then + BALLERINA_PLATFORM=ballerina-${BALLERINA_VERSION}-linux +else + if [ "$ARCH" = "arm" ]; then + BALLERINA_PLATFORM=ballerina-${BALLERINA_VERSION}-linux-arm + else + echo "Please enter a valid architecture for the ballerina pack" + printUsage + exit 1 + fi +fi + BALLERINA_DISTRIBUTION_LOCATION=${DIST_PATH} -BALLERINA_PLATFORM=ballerina-${BALLERINA_VERSION}-linux BALLERINA_INSTALL_DIRECTORY=ballerina-${BALLERINA_VERSION} echo "Build started at" $(date +"%Y-%m-%d %H:%M:%S") @@ -108,7 +128,7 @@ function createBallerinaPlatform() { createPackInstallationDirectory copyDebianDirectory mv target/${BALLERINA_INSTALL_DIRECTORY} target/ballerina-${BALLERINA_VERSION}-linux-x64 - fakeroot dpkg-deb --build target/ballerina-${BALLERINA_VERSION}-linux-x64 + fakeroot dpkg-deb --build target/${BALLERINA_PLATFORM}-x64 } deleteTargetDirectory From f29113f6949a75c97e157df78aae2f0781d8308d Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Tue, 15 Oct 2024 10:16:20 +0530 Subject: [PATCH 09/80] Add suggestions from previous PR Add suggestions from https://github.com/ballerina-platform/ballerina-distribution/pull/5709 --- .../check-expression/check_expression.bal | 1 + examples/error-reporting/error_reporting.bal | 2 ++ examples/error-subtyping/error_subtyping.bal | 4 +-- examples/error-subtyping/error_subtyping.md | 4 +-- .../error_type_intersection.bal | 28 +++++++------------ .../error_type_intersection.md | 2 +- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/examples/check-expression/check_expression.bal b/examples/check-expression/check_expression.bal index 6d68881fa4..cd634f73bb 100644 --- a/examples/check-expression/check_expression.bal +++ b/examples/check-expression/check_expression.bal @@ -1,5 +1,6 @@ import ballerina/io; +// Convert `bytes` to a `string` value and then to an `int` value. function intFromBytes(byte[] bytes) returns int|error { string|error res = string:fromBytes(bytes); // Explicitly check if the result is an error and diff --git a/examples/error-reporting/error_reporting.bal b/examples/error-reporting/error_reporting.bal index e85a2ff841..61c1270965 100644 --- a/examples/error-reporting/error_reporting.bal +++ b/examples/error-reporting/error_reporting.bal @@ -37,6 +37,8 @@ public function main() { {name: "Bob", age: -1}, {name: "Charlie", age: 30} ]; + // Note how the Person value after the value for which validation fails is + // not processed error? err = validatePeople(people); if err is error { printError(err); diff --git a/examples/error-subtyping/error_subtyping.bal b/examples/error-subtyping/error_subtyping.bal index 5cfb3623b2..26adf0c16b 100644 --- a/examples/error-subtyping/error_subtyping.bal +++ b/examples/error-subtyping/error_subtyping.bal @@ -12,7 +12,7 @@ type InvalidI32Detail record {| // Error with the `InvalidIntDetail` type as the detail type. type InvalidIntError error; -// `error` with `InvalidI32Detail` as the detail type. Thus it is a subtype of `InvalidIntError`. +// Error with `InvalidI32Detail` as the detail type. Thus it is a subtype of `InvalidIntError`. type InvalidI32Error error; // Distinct error with the `InvalidIntDetail` type as the detail type and a unique type ID. @@ -20,7 +20,7 @@ type InvalidI32Error error; // with `AnotherDistinctIntError` because they have different type IDs. type DistinctIntError distinct error; -// Another `error` with `InvalidIntDetail` as the detail type and different type ID to `DistinctIntError` +// Another distinct error with `InvalidIntDetail` as the detail type, but a different type ID to `DistinctIntError` // This is also a proper subtype of `InvalidIntError`, but doesn't have a subtype relationship with `DistinctIntError` type AnotherDistinctIntError distinct error; diff --git a/examples/error-subtyping/error_subtyping.md b/examples/error-subtyping/error_subtyping.md index 6cd53ee3a6..92f96f9408 100644 --- a/examples/error-subtyping/error_subtyping.md +++ b/examples/error-subtyping/error_subtyping.md @@ -1,8 +1,8 @@ # Error subtyping -If we want to identify if a given `error` type (say `ESub`) is a subtype of another error type (say `ESuper`), first we need to check if `ESuper` is a distinct error type. If it is not then `ESub` is a subtype if and only if the detail type of `ESub` is a subtype of the detail type of `ESuper`. +If we want to identify if a given `error` type (say `ESub`) is a subtype of another error type (say `ESuper`), first we need to check if `ESuper` is a distinct error type. If it is not, then `ESub` is a subtype if and only if the detail type of `ESub` is a subtype of the detail type of `ESuper`. -If more explicit control over error type relations is desired you can use `distinct` error types. Each declaration of a distinct error type has a unique type ID. If `ESuper` is a distinct error type there is the additional requirement that type ID of `ESub` must belong to the type ID set of `ESuper` for it to be a subtype. +If more explicit control over error type relations is desired you can use `distinct` error types. Each declaration of a distinct error type has a unique type ID. If `ESuper` is a distinct error type there is the additional requirement that the type ID set of `ESub` must contain all the type IDs of `ESuper`. In other words with distinct error types subtyping relationships behave similarly to nominal typing. Note that you can create subtypes of distinct error types by intersecting them with other error types. diff --git a/examples/error-type-intersection/error_type_intersection.bal b/examples/error-type-intersection/error_type_intersection.bal index 7049dcc62f..87edf2d606 100644 --- a/examples/error-type-intersection/error_type_intersection.bal +++ b/examples/error-type-intersection/error_type_intersection.bal @@ -12,36 +12,28 @@ type InputError error; type NumericError error; -type DistinctInputError distinct error; - -type DistinctNumericError distinct error; - // `NumericInputError` has detail type, `record {| int value |}`. type NumericInputError InputError & NumericError; -// `DistinctNumericInputError` has type ids of both `DistinctInputError` and `DistinctNumericError`. -type DistinctNumericInputError DistinctInputError & DistinctNumericError; +type DistinctInputError distinct error; -function createNumericInputError(int value) returns NumericInputError { - return error("Numeric input error", value = value); -} +type DistinctNumericError distinct error; -function createDistinctNumericInputError(int value) returns DistinctNumericInputError { - return error("Distinct numeric input error", value = value); -} +// `DistinctNumericInputError` has type IDs of both `DistinctInputError` and `DistinctNumericError`. +type DistinctNumericInputError DistinctInputError & DistinctNumericError; public function main() { - NumericInputError e1 = createNumericInputError(5); - // `e1` belong to `InputError` since its detail type is a subtype of `InputErrorDetail`. + NumericInputError e1 = error("Numeric input error", value = 5); + // `e1` belongs to `InputError` since its detail type is a subtype of `InputErrorDetail`. io:println(e1 is InputError); - // `e1` doesn't belong to `DistinctInputError` since it doesn't have the type id of `DistinctInputError`. + // `e1` doesn't belong to `DistinctInputError` since it doesn't have the type ID of `DistinctInputError`. io:println(e1 is DistinctInputError); - DistinctNumericInputError e2 = createDistinctNumericInputError(5); - // `e2` belong to `InputError` since it's detail type is a subtype of `InputErrorDetail`. + DistinctNumericInputError e2 = error("Distinct numeric input error", value = 5); + // `e2` belongs to `InputError` since its detail type is a subtype of `InputErrorDetail`. io:println(e2 is InputError); - // `e2` belong to `DistinctInputError` since it's type id set include the type id of `DistinctInputError`. + // `e2` belongs to `DistinctInputError` since its type ID set include the type id of `DistinctInputError`. io:println(e2 is DistinctInputError); } diff --git a/examples/error-type-intersection/error_type_intersection.md b/examples/error-type-intersection/error_type_intersection.md index 24b8631453..2e3c1bb58e 100644 --- a/examples/error-type-intersection/error_type_intersection.md +++ b/examples/error-type-intersection/error_type_intersection.md @@ -1,6 +1,6 @@ # Type intersection for error types -If you intersect two `error` types, the resulting type's detail type is the intersection of the detail types of both types. Furthermore, if any of the types being intersected is a distinct type, then the resultant type's type ID set includes all the type IDs of that type. Thus it is a subtype of both types and this is how you create subtypes of `distinct` error types. +If you intersect two `error` types, the resulting type's detail type is the intersection of the detail types of both types. Furthermore, if any of the types being intersected is a distinct type, then the resultant type's type ID set includes all the type IDs of that type. Thus it is a subtype of both types. This way, you can create an error type that is a subtype of multiple distinct types and also use a more specific detail type. ::: code error_type_intersection.bal ::: From 821eb2250a78ea74b9b050fe35754c8411a29397 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Tue, 15 Oct 2024 10:51:46 +0530 Subject: [PATCH 10/80] Apply suggestions from code review Co-authored-by: Maryam Ziyad --- examples/error-reporting/error_reporting.bal | 4 ++-- examples/error-subtyping/error_subtyping.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/error-reporting/error_reporting.bal b/examples/error-reporting/error_reporting.bal index 61c1270965..22179d5b5c 100644 --- a/examples/error-reporting/error_reporting.bal +++ b/examples/error-reporting/error_reporting.bal @@ -37,8 +37,8 @@ public function main() { {name: "Bob", age: -1}, {name: "Charlie", age: 30} ]; - // Note how the Person value after the value for which validation fails is - // not processed + // Note how the `Person` value after the value for which validation fails is + // not processed. error? err = validatePeople(people); if err is error { printError(err); diff --git a/examples/error-subtyping/error_subtyping.md b/examples/error-subtyping/error_subtyping.md index 92f96f9408..a6c040dd78 100644 --- a/examples/error-subtyping/error_subtyping.md +++ b/examples/error-subtyping/error_subtyping.md @@ -2,7 +2,7 @@ If we want to identify if a given `error` type (say `ESub`) is a subtype of another error type (say `ESuper`), first we need to check if `ESuper` is a distinct error type. If it is not, then `ESub` is a subtype if and only if the detail type of `ESub` is a subtype of the detail type of `ESuper`. -If more explicit control over error type relations is desired you can use `distinct` error types. Each declaration of a distinct error type has a unique type ID. If `ESuper` is a distinct error type there is the additional requirement that the type ID set of `ESub` must contain all the type IDs of `ESuper`. In other words with distinct error types subtyping relationships behave similarly to nominal typing. +If more explicit control over error type relations is desired you can use `distinct` error types. Each declaration of a distinct error type has a unique type ID. If `ESuper` is a distinct error type there is the additional requirement that the type ID set of `ESub` must contain all the type IDs of `ESuper`. In other words, with distinct error types, typing relationships can be made more like nominal typing. Note that you can create subtypes of distinct error types by intersecting them with other error types. From 4a980f19611aa95fde1d6bbea8b70874cc3776d9 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Tue, 15 Oct 2024 11:34:52 +0530 Subject: [PATCH 11/80] Update examples/error-type-intersection/error_type_intersection.bal Co-authored-by: Maryam Ziyad --- examples/error-type-intersection/error_type_intersection.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/error-type-intersection/error_type_intersection.bal b/examples/error-type-intersection/error_type_intersection.bal index 87edf2d606..28733a1fd2 100644 --- a/examples/error-type-intersection/error_type_intersection.bal +++ b/examples/error-type-intersection/error_type_intersection.bal @@ -34,6 +34,6 @@ public function main() { // `e2` belongs to `InputError` since its detail type is a subtype of `InputErrorDetail`. io:println(e2 is InputError); - // `e2` belongs to `DistinctInputError` since its type ID set include the type id of `DistinctInputError`. + // `e2` belongs to `DistinctInputError` since its type ID set includes the type id of `DistinctInputError`. io:println(e2 is DistinctInputError); } From 02e2915489f8f27b7e6d864517f02dd6fd4b2c41 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Tue, 15 Oct 2024 12:44:35 +0530 Subject: [PATCH 12/80] Fix line numbers in output --- examples/error-reporting/error_reporting.out | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/error-reporting/error_reporting.out b/examples/error-reporting/error_reporting.out index 609403ab5e..1d4ad9acbc 100644 --- a/examples/error-reporting/error_reporting.out +++ b/examples/error-reporting/error_reporting.out @@ -3,8 +3,8 @@ Validating Alice Validating Bob Message: Validation failed for a person Detail: {"person":{"name":"Bob","age":-1}} -Stack trace: [callableName: validatePeople fileName: error_reporting.bal lineNumber: 20,callableName: main fileName: error_reporting.bal lineNumber: 40] +Stack trace: [callableName: validatePeople fileName: error_reporting.bal lineNumber: 20,callableName: main fileName: error_reporting.bal lineNumber: 42] Cause: Message: Age cannot be negative Detail: {"age":-1} -Stack trace: [callableName: validatePerson fileName: error_reporting.bal lineNumber: 30,callableName: validatePeople fileName: error_reporting.bal lineNumber: 16,callableName: main fileName: error_reporting.bal lineNumber: 40] +Stack trace: [callableName: validatePerson fileName: error_reporting.bal lineNumber: 30,callableName: validatePeople fileName: error_reporting.bal lineNumber: 16,callableName: main fileName: error_reporting.bal lineNumber: 42] From 9921e73713a02e06c48a059deb049742c69db1db Mon Sep 17 00:00:00 2001 From: anuruddhal Date: Wed, 16 Oct 2024 14:08:18 +0530 Subject: [PATCH 13/80] Fix formatting in code to cloud guide --- examples/docker-hello-world/docker_hello_world.md | 5 +---- examples/kubernetes-hello-world/kubernetes_hello_world.md | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/docker-hello-world/docker_hello_world.md b/examples/docker-hello-world/docker_hello_world.md index e6d0118486..70fbf99a61 100644 --- a/examples/docker-hello-world/docker_hello_world.md +++ b/examples/docker-hello-world/docker_hello_world.md @@ -11,10 +11,7 @@ For all the supported key value properties, see [Code to Cloud specification](ht ::: code Cloud.toml ::: Execute the `bal build` command to build the Ballerina package. Code to Cloud generates only one container per package. ->**Note:** For Mac users with Apple Silicon chips, set an environment variable `DOCKER_DEFAULT_PLATFORM` to `linux/amd64`, before building the image. This is because the Ballerina Docker image is not supported on Apple Silicon chips yet. -> ``` -> export DOCKER_DEFAULT_PLATFORM=linux/amd64 -> ``` +>**Note:** macOS users with Apple Silicon chips need to set an environment variable named `DOCKER_DEFAULT_PLATFORM` to `linux/amd64`, before building the image. This is because the Ballerina Docker image is not supported on Apple Silicon chips yet. Run `export DOCKER_DEFAULT_PLATFORM=linux/amd64` to set the environment variable. ::: out build_output.out ::: diff --git a/examples/kubernetes-hello-world/kubernetes_hello_world.md b/examples/kubernetes-hello-world/kubernetes_hello_world.md index e2c121dbe6..4af9ab0cb5 100644 --- a/examples/kubernetes-hello-world/kubernetes_hello_world.md +++ b/examples/kubernetes-hello-world/kubernetes_hello_world.md @@ -11,10 +11,7 @@ For all the supported key value properties, see [Code to Cloud Specification](ht ::: code Cloud.toml ::: Execute the `bal build` command to build the Ballerina package. Code to Cloud generates only one container per package. ->**Note:** The macOS users with Apple silicon chip need set an environment variable `DOCKER_DEFAULT_PLATFORM` to `linux/amd64`, before building the image. This is because the Ballerina Docker image is not supported on Apple silicon chips yet. -> ``` -> export DOCKER_DEFAULT_PLATFORM=linux/amd64 -> ``` +>**Note:** macOS users with Apple Silicon chips need to set an environment variable named `DOCKER_DEFAULT_PLATFORM` to `linux/amd64`, before building the image. This is because the Ballerina Docker image is not supported on Apple Silicon chips yet. Run `export DOCKER_DEFAULT_PLATFORM=linux/amd64` to set the environment variable. ::: out build_output.out ::: From 3d264b96e08f01249c60211bc27afe650d5b6e36 Mon Sep 17 00:00:00 2001 From: Poorna Gunathilaka Date: Wed, 16 Oct 2024 15:25:55 +0530 Subject: [PATCH 14/80] Apply suggestions from code review Co-authored-by: Maryam Ziyad --- examples/regexp-find-operations/regexp_find_operations.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/regexp-find-operations/regexp_find_operations.bal b/examples/regexp-find-operations/regexp_find_operations.bal index 2034f1ca71..ef07c5ed3b 100644 --- a/examples/regexp-find-operations/regexp_find_operations.bal +++ b/examples/regexp-find-operations/regexp_find_operations.bal @@ -11,13 +11,13 @@ public function main() { 2024-09-19 10:11:55 INFO [Security] - Security scan completed, no issues found 2024-09-19 10:12:30 ERROR [RequestHandler] - 404 Not Found: /api/v1/products`; - // Regex to match error logs with three groups: + // Regular expression to match error logs with three groups: // 1. Timestamp (e.g., 2024-09-19 10:03:17). // 2. Component (e.g., Database, Scheduler). // 3. Log message (e.g., Connection to database timed out). string:RegExp errorLogPattern = re `(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ERROR \[(\w+)\]\s-\s(.*)`; - // Retrieving the first error log from the `logContent`. + // Retrieve the first error log from `logContent`. regexp:Span? firstErrorLog = errorLogPattern.find(logContent); if firstErrorLog == () { io:println("Failed to find a error log"); From 2839b6ec23967bb16b1bec84019ba2679d3f768e Mon Sep 17 00:00:00 2001 From: Nipuna Madhushan <51471998+NipunaMadhushan@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:07:50 +0530 Subject: [PATCH 15/80] Update ballerina/build.gradle Co-authored-by: Tharik Kanaka --- ballerina/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/ballerina/build.gradle b/ballerina/build.gradle index 1f2dcb712f..c18d518cf1 100644 --- a/ballerina/build.gradle +++ b/ballerina/build.gradle @@ -59,7 +59,6 @@ task unpackBallerinaJre(type: Download) { src([ "${jreBaseURL}/ballerina-jre-linux-64-${ballerinaJreVersion}.zip", "${jreBaseURL}/ballerina-jre-linux-arm-64-${ballerinaJreVersion}.zip", -// "https://github.com/NipunaMadhushan/ballerina-examples/releases/download/test-1.0.0/ballerina-jre-linux-arm-64-${ballerinaJreVersion}.zip", "${jreBaseURL}/ballerina-jre-macos-64-${ballerinaJreVersion}.zip", "${jreBaseURL}/ballerina-jre-macos-arm-64-${ballerinaJreVersion}.zip", "${jreBaseURL}/ballerina-jre-win-64-${ballerinaJreVersion}.zip" From f98ab1c2e0609f4528285e02a9acb5e43bf70423 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Fri, 18 Oct 2024 09:19:33 +0530 Subject: [PATCH 16/80] Update raw template doc --- examples/raw-templates/Ballerina.toml | 2 -- examples/raw-templates/raw_templates.bal | 36 +++++++----------------- examples/raw-templates/raw_templates.md | 19 ++----------- examples/raw-templates/raw_templates.out | 4 +-- 4 files changed, 14 insertions(+), 47 deletions(-) delete mode 100644 examples/raw-templates/Ballerina.toml diff --git a/examples/raw-templates/Ballerina.toml b/examples/raw-templates/Ballerina.toml deleted file mode 100644 index f687b9038e..0000000000 --- a/examples/raw-templates/Ballerina.toml +++ /dev/null @@ -1,2 +0,0 @@ -[[platform.java17.dependency]] -path = "h2-2.1.210.jar" diff --git a/examples/raw-templates/raw_templates.bal b/examples/raw-templates/raw_templates.bal index 13dfc72336..f203013b63 100644 --- a/examples/raw-templates/raw_templates.bal +++ b/examples/raw-templates/raw_templates.bal @@ -1,31 +1,15 @@ -import ballerina/io; -import ballerinax/java.jdbc; -import ballerina/sql; - -jdbc:Client dbClient = check new (url = "jdbc:h2:file:./master/orderdb", - user = "test", password = "test"); -public function main() returns error? { - // Uses a raw template to create the `Orders` table. - _ = check dbClient->execute(`CREATE TABLE IF NOT EXISTS Orders - (orderId INTEGER NOT NULL, customerId INTEGER, noOfItems INTEGER, - PRIMARY KEY (orderId))`); - // Uses a raw template to insert values to the `Orders` table. - _ = check dbClient->execute(`INSERT INTO Orders (orderId, customerId, noOfItems) - VALUES (1, 1, 20)`); - _ = check dbClient->execute(`INSERT INTO Orders (orderId, customerId, noOfItems) - VALUES (2, 1, 15)`); +import ballerina/io; +import ballerina/lang.'object as 'object; - stream strm = getOrders(1); - record {|record {} value;|}|sql:Error? v = strm.next(); - while (v is record {|record {} value;|}) { - record {} value = v.value; - io:println(value); - v = strm.next(); - } +function foo() returns boolean { + return false; } -function getOrders(int customerId) returns stream { - // In this raw template, the `customerId` variable is interpolated in the literal. - return dbClient->query(`SELECT * FROM orders WHERE customerId = ${customerId}`); +public function main() { + int x = 5; + error y = error("foo"); + 'object:RawTemplate rawTemplate = `x is ${x}. y is ${y}. result of calling foo is ${foo()}`; + io:println(rawTemplate.strings); + io:println(rawTemplate.insertions); } diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 172dc6593f..7ae3100fbd 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -1,22 +1,7 @@ # Raw templates -A raw template is a backtick template without a tag. Exposes result of phase 1 without further processing. Raw template is evaluated by evaluating each expression and creating an object containing. - -- an `array` of the `strings` separated by insertions -- an `array` of the results of expression evaluation and an `array` of `strings` separating - ->**Important use case:** SQL parameters. - ->**Note:** The relevant database driver JAR should be defined in the `Ballerina.toml` file as a dependency. This sample is based on an H2 database and the H2 database driver JAR need to be added to `Ballerina.toml` file. This sample is written using H2 2.1.210 and it is recommended to use H2 JAR with versions higher than 2.1.210. - -For a sample configuration and more information on the underlying module, see the [`jdbc` module](https://lib.ballerina.io/ballerinax/java.jdbc/latest/). +Raw template is a backtick string without a tag (such as `string` or `xml`). Backtick string is a sequence of characters interleaved with interpolations (`${expression}`), wrapped by a pair of backticks. The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. `strings` array will have string literals in the backtick string broken at interpolations and `insertions` array will have the resultant value of evaluating each interpolation. ::: code raw_templates.bal ::: -Add the relevant database driver JAR details to the `Ballerina.toml` file. - -::: code Ballerina.toml ::: - -Build and run the project using the `bal run` command. - -::: out raw_templates.out ::: \ No newline at end of file +::: out raw_templates.out ::: diff --git a/examples/raw-templates/raw_templates.out b/examples/raw-templates/raw_templates.out index f0b75ca539..9b3a7f3230 100644 --- a/examples/raw-templates/raw_templates.out +++ b/examples/raw-templates/raw_templates.out @@ -1,3 +1,3 @@ $ bal run -{"ORDERID":1,"CUSTOMERID":1,"NOOFITEMS":20} -{"ORDERID":2,"CUSTOMERID":1,"NOOFITEMS":15} +["x is ",". y is ",". result of calling foo is ",""] +[5,error("foo"),false] From 22e700451de5153bced958ae92e8150e4898d8a6 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Fri, 18 Oct 2024 10:29:19 +0530 Subject: [PATCH 17/80] Update println and add util function --- .../regexp_find_operations.bal | 21 ++++++++++++------- .../regexp_find_operations.md | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/examples/regexp-find-operations/regexp_find_operations.bal b/examples/regexp-find-operations/regexp_find_operations.bal index ef07c5ed3b..1dd1ba7724 100644 --- a/examples/regexp-find-operations/regexp_find_operations.bal +++ b/examples/regexp-find-operations/regexp_find_operations.bal @@ -23,7 +23,7 @@ public function main() { io:println("Failed to find a error log"); return; } - io:println(string `First error log: ${firstErrorLog.substring()}`); + io:println("First error log: ", firstErrorLog.substring()); // Retrieving all error logs from the `logContent`. regexp:Span[] allErrorLogs = errorLogPattern.findAll(logContent); @@ -53,11 +53,18 @@ function printGroupsWithinLog(regexp:Groups logGroup) { // The first element in the `logGroup` is the entire matched string. // The subsequent elements in `logGroup` represent the captured groups // (timestamp, component, message). - string timestamp = (logGroup[1]).substring(); - string component = (logGroup[2]).substring(); - string logMessage = (logGroup[3]).substring(); + string timestamp = extractStringFromMatchGroup(logGroup[1]); + string component = extractStringFromMatchGroup(logGroup[2]); + string logMessage = extractStringFromMatchGroup(logGroup[3]); - io:println(string `Timestamp: ${timestamp}`); - io:println(string `Component: ${component}`); - io:println(string `Message: ${logMessage}`); + io:println("Timestamp: ", timestamp); + io:println("Component: ", component); + io:println("Message: ", logMessage); +} + +function extractStringFromMatchGroup(regexp:Span? span) returns string { + if span !is regexp:Span { + return ""; + } + return span.substring(); } diff --git a/examples/regexp-find-operations/regexp_find_operations.md b/examples/regexp-find-operations/regexp_find_operations.md index 850ed3b18a..d9418540a9 100644 --- a/examples/regexp-find-operations/regexp_find_operations.md +++ b/examples/regexp-find-operations/regexp_find_operations.md @@ -1,6 +1,6 @@ # RegExp find operations -The `RegExp` type provides a set of language library functions to find patterns within strings. These functions enable efficient pattern matching, grouping, and extraction based on specific regular expressions. +The `RegExp` type provides a set of langlib functions to find patterns within strings. These functions enable efficient pattern matching, grouping, and extraction based on specific regular expressions. ::: code regexp_find_operations.bal ::: From de476dbb4c114a312b88928e40c7deecf963b2a2 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Fri, 18 Oct 2024 13:31:06 +0530 Subject: [PATCH 18/80] Fix error-subtyping --- examples/error-subtyping/error_subtyping.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/error-subtyping/error_subtyping.md b/examples/error-subtyping/error_subtyping.md index 6cd53ee3a6..631044c4c5 100644 --- a/examples/error-subtyping/error_subtyping.md +++ b/examples/error-subtyping/error_subtyping.md @@ -6,8 +6,6 @@ If more explicit control over error type relations is desired you can use `disti Note that you can create subtypes of distinct error types by intersecting them with other error types. -```ballerina - ::: code error_subtyping.bal ::: ::: out error_subtyping.out ::: From 82d2c68abb28fc928fc2e3eeca01d6255f832875 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Mon, 21 Oct 2024 09:35:11 +0530 Subject: [PATCH 19/80] Update linux-installer script --- .../build-ballerina-linux-deb-x64.sh | 8 ++++++-- .../resources/{ => amd}/DEBIAN/control | 0 .../resources/{ => amd}/DEBIAN/postinst | 0 .../resources/{ => amd}/DEBIAN/postrm | 0 .../linux-deb/resources/arm/DEBIAN/control | 10 ++++++++++ .../linux-deb/resources/arm/DEBIAN/postinst | 20 +++++++++++++++++++ .../linux-deb/resources/arm/DEBIAN/postrm | 3 +++ 7 files changed, 39 insertions(+), 2 deletions(-) rename installers/linux-deb/resources/{ => amd}/DEBIAN/control (100%) rename installers/linux-deb/resources/{ => amd}/DEBIAN/postinst (100%) rename installers/linux-deb/resources/{ => amd}/DEBIAN/postrm (100%) create mode 100644 installers/linux-deb/resources/arm/DEBIAN/control create mode 100755 installers/linux-deb/resources/arm/DEBIAN/postinst create mode 100755 installers/linux-deb/resources/arm/DEBIAN/postrm diff --git a/installers/linux-deb/build-ballerina-linux-deb-x64.sh b/installers/linux-deb/build-ballerina-linux-deb-x64.sh index 10428fb66b..e221291a5d 100755 --- a/installers/linux-deb/build-ballerina-linux-deb-x64.sh +++ b/installers/linux-deb/build-ballerina-linux-deb-x64.sh @@ -113,7 +113,11 @@ function createPackInstallationDirectory() { } function copyDebianDirectory() { - cp -R resources/DEBIAN target/${BALLERINA_INSTALL_DIRECTORY}/DEBIAN + if [ "$ARCH" = "arm" ]; then + cp -R resources/arm/DEBIAN target/${BALLERINA_INSTALL_DIRECTORY}/DEBIAN + else + cp -R resources/amd/DEBIAN target/${BALLERINA_INSTALL_DIRECTORY}/DEBIAN + fi sed -i -e 's/__BALLERINA_VERSION__/'${BALLERINA_VERSION}'/g' target/${BALLERINA_INSTALL_DIRECTORY}/DEBIAN/postinst sed -i -e 's/__BALLERINA_VERSION__/'${BALLERINA_VERSION}'/g' target/${BALLERINA_INSTALL_DIRECTORY}/DEBIAN/postrm sed -i -e 's/__BALLERINA_VERSION__/'${BALLERINA_VERSION}'/g' target/${BALLERINA_INSTALL_DIRECTORY}/DEBIAN/control @@ -127,7 +131,7 @@ function createBallerinaPlatform() { extractPack "$BALLERINA_DISTRIBUTION_LOCATION/$BALLERINA_PLATFORM.zip" ${BALLERINA_PLATFORM} createPackInstallationDirectory copyDebianDirectory - mv target/${BALLERINA_INSTALL_DIRECTORY} target/ballerina-${BALLERINA_VERSION}-linux-x64 + mv target/${BALLERINA_INSTALL_DIRECTORY} target/${BALLERINA_PLATFORM}-x64 fakeroot dpkg-deb --build target/${BALLERINA_PLATFORM}-x64 } diff --git a/installers/linux-deb/resources/DEBIAN/control b/installers/linux-deb/resources/amd/DEBIAN/control similarity index 100% rename from installers/linux-deb/resources/DEBIAN/control rename to installers/linux-deb/resources/amd/DEBIAN/control diff --git a/installers/linux-deb/resources/DEBIAN/postinst b/installers/linux-deb/resources/amd/DEBIAN/postinst similarity index 100% rename from installers/linux-deb/resources/DEBIAN/postinst rename to installers/linux-deb/resources/amd/DEBIAN/postinst diff --git a/installers/linux-deb/resources/DEBIAN/postrm b/installers/linux-deb/resources/amd/DEBIAN/postrm similarity index 100% rename from installers/linux-deb/resources/DEBIAN/postrm rename to installers/linux-deb/resources/amd/DEBIAN/postrm diff --git a/installers/linux-deb/resources/arm/DEBIAN/control b/installers/linux-deb/resources/arm/DEBIAN/control new file mode 100644 index 0000000000..1a252637c9 --- /dev/null +++ b/installers/linux-deb/resources/arm/DEBIAN/control @@ -0,0 +1,10 @@ +Package: ballerina-__BALLERINA_VERSION__ +Version: 2-__BALLERINA_VERSION__ +Maintainer: Ballerina +Architecture: arm64 +Description: Ballerina + Ballerina is a general purpose, concurrent and strongly typed + programming language with both textual and graphical syntaxes, + optimized for integration. +Installed-Size: 331000 + diff --git a/installers/linux-deb/resources/arm/DEBIAN/postinst b/installers/linux-deb/resources/arm/DEBIAN/postinst new file mode 100755 index 0000000000..011f81f664 --- /dev/null +++ b/installers/linux-deb/resources/arm/DEBIAN/postinst @@ -0,0 +1,20 @@ +rm -f /usr/lib/ballerina/bin/ballerina +rm -f /usr/bin/bal + +ln -sf /usr/lib/ballerina/bin/bal /usr/bin/bal +echo "export BALLERINA_HOME=/usr/lib/bal" >> /etc/profile.d/wso2.sh + +if [ "$(basename -- "$SHELL")" = "bash" ]; then + bal completion bash > /usr/share/bash-completion/completions/bal + chmod 766 /usr/share/bash-completion/completions/bal +elif [ "$(basename -- "$SHELL")" = "zsh" ]; then + if [ ! -d ~/.ballerina ]; then + mkdir –m766 ~/.ballerina + fi + mkdir -p –m766 ~/.ballerina/completion + echo 'fpath=(~/.ballerina/completion $fpath)' >> ~/.zshrc + echo 'autoload -U compinit && compinit' >> ~/.zshrc + \cp /usr/lib/ballerina/scripts/_bal ~/.ballerina/completion/ + chmod 766 ~/.ballerina/completion/_bal +fi + diff --git a/installers/linux-deb/resources/arm/DEBIAN/postrm b/installers/linux-deb/resources/arm/DEBIAN/postrm new file mode 100755 index 0000000000..c10fba120e --- /dev/null +++ b/installers/linux-deb/resources/arm/DEBIAN/postrm @@ -0,0 +1,3 @@ +sudo rm /usr/bin/bal +sed -i.bak '/BALLERINA_HOME/d' /etc/profile.d/wso2.sh + From c1580f5d83ca676334ff186a20c5d91819795502 Mon Sep 17 00:00:00 2001 From: Nuvindu Nirmana <63797478+Nuvindu@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:17:05 +0530 Subject: [PATCH 20/80] Update the `avro` version to 1.0.2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bdc4ace615..8535fe5e1c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ stdlibMathVectorVersion=1.0.2 stdlibLdapVersion=1.0.1 # Stdlib Level 02 -stdlibAvroVersion=1.0.1 +stdlibAvroVersion=1.0.2 stdlibConstraintVersion=1.5.0 stdlibCryptoVersion=2.7.2 stdlibDataXmldataVersion=1.0.0 From 4837370f0103d82b9ff61f92fc4ccd4e8df09f33 Mon Sep 17 00:00:00 2001 From: Krishnananthalingam Tharmigan <63336800+TharmiganK@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:18:51 +0530 Subject: [PATCH 21/80] Update HTTP patch version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8535fe5e1c..bbe193c3d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -58,7 +58,7 @@ stdlibTomlVersion=0.6.0 stdlibYamlVersion=0.6.0 # Stdlib Level 05 -stdlibHttpVersion=2.12.0 +stdlibHttpVersion=2.12.2 # Stdlib Level 06 From a941a780dfa885362d8e8db138ec9dc4056b8bc3 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Mon, 21 Oct 2024 13:47:50 +0530 Subject: [PATCH 22/80] Address review suggestions --- examples/raw-templates/raw_templates.bal | 4 +--- examples/raw-templates/raw_templates.md | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/raw-templates/raw_templates.bal b/examples/raw-templates/raw_templates.bal index f203013b63..4dd68d49a6 100644 --- a/examples/raw-templates/raw_templates.bal +++ b/examples/raw-templates/raw_templates.bal @@ -1,6 +1,4 @@ - import ballerina/io; -import ballerina/lang.'object as 'object; function foo() returns boolean { return false; @@ -9,7 +7,7 @@ function foo() returns boolean { public function main() { int x = 5; error y = error("foo"); - 'object:RawTemplate rawTemplate = `x is ${x}. y is ${y}. result of calling foo is ${foo()}`; + object:RawTemplate rawTemplate = `x is ${x}. y is ${y}. The result of calling foo is ${foo()}`; io:println(rawTemplate.strings); io:println(rawTemplate.insertions); } diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 7ae3100fbd..5f03d84e04 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -1,7 +1,10 @@ # Raw templates -Raw template is a backtick string without a tag (such as `string` or `xml`). Backtick string is a sequence of characters interleaved with interpolations (`${expression}`), wrapped by a pair of backticks. The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. `strings` array will have string literals in the backtick string broken at interpolations and `insertions` array will have the resultant value of evaluating each interpolation. +Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form`${expression}`). The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. ::: code raw_templates.bal ::: ::: out raw_templates.out ::: + +## Related links +- [Backtick templates](https://ballerina.io/learn/by-example/backtick-templates/) From 712dd87e664ec573d561b2206f0557ea38924d0c Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Mon, 21 Oct 2024 14:12:01 +0530 Subject: [PATCH 23/80] Use ensureType --- .../regexp_find_operations.bal | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/examples/regexp-find-operations/regexp_find_operations.bal b/examples/regexp-find-operations/regexp_find_operations.bal index 1dd1ba7724..df16e181fd 100644 --- a/examples/regexp-find-operations/regexp_find_operations.bal +++ b/examples/regexp-find-operations/regexp_find_operations.bal @@ -1,7 +1,7 @@ import ballerina/io; import ballerina/lang.regexp; -public function main() { +public function main() returns error? { string logContent = string ` 2024-09-19 10:02:01 WARN [UserLogin] - Failed login attempt for user: johndoe 2024-09-19 10:03:17 ERROR [Database] - Connection to database timed out @@ -25,46 +25,39 @@ public function main() { } io:println("First error log: ", firstErrorLog.substring()); - // Retrieving all error logs from the `logContent`. + // Retrieve all error logs from the `logContent`. regexp:Span[] allErrorLogs = errorLogPattern.findAll(logContent); - io:println("\n", "All error logs:"); + io:println("\nAll error logs:"); foreach regexp:Span errorLog in allErrorLogs { io:println(errorLog.substring()); } - // Retrieving groups (timestamp, component, message) from the first error log. + // Retrieve groups (timestamp, component, message) from the first error log. regexp:Groups? firstErrorLogGroups = errorLogPattern.findGroups(logContent); if firstErrorLogGroups == () { io:println("Failed to find groups in first error log"); return; } - io:println("\n", "Groups within first error log:"); - printGroupsWithinLog(firstErrorLogGroups); + io:println("\nGroups within first error log:"); + check printGroupsWithinLog(firstErrorLogGroups); - // Retrieving groups from all error logs. + // Retrieve groups from all error logs. regexp:Groups[] allErrorLogGroups = errorLogPattern.findAllGroups(logContent); - io:println("\n", "Groups in all error logs"); + io:println("\nGroups in all error logs"); foreach regexp:Groups logGroup in allErrorLogGroups { - printGroupsWithinLog(logGroup); + check printGroupsWithinLog(logGroup); } } -function printGroupsWithinLog(regexp:Groups logGroup) { +function printGroupsWithinLog(regexp:Groups logGroup) returns error? { // The first element in the `logGroup` is the entire matched string. // The subsequent elements in `logGroup` represent the captured groups // (timestamp, component, message). - string timestamp = extractStringFromMatchGroup(logGroup[1]); - string component = extractStringFromMatchGroup(logGroup[2]); - string logMessage = extractStringFromMatchGroup(logGroup[3]); + string timestamp = (check logGroup[1].ensureType(regexp:Span)).substring(); + string component = (check logGroup[2].ensureType(regexp:Span)).substring(); + string logMessage = (check logGroup[3].ensureType(regexp:Span)).substring(); io:println("Timestamp: ", timestamp); io:println("Component: ", component); io:println("Message: ", logMessage); } - -function extractStringFromMatchGroup(regexp:Span? span) returns string { - if span !is regexp:Span { - return ""; - } - return span.substring(); -} From 1e6285814e2775340fb8e377ffeda4a88f2a5c21 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Mon, 21 Oct 2024 16:14:05 +0530 Subject: [PATCH 24/80] Add a better example --- examples/raw-templates/raw_templates.bal | 21 +++++++++++++++++---- examples/raw-templates/raw_templates.md | 5 ++++- examples/raw-templates/raw_templates.out | 6 ++++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/examples/raw-templates/raw_templates.bal b/examples/raw-templates/raw_templates.bal index 4dd68d49a6..3a18087003 100644 --- a/examples/raw-templates/raw_templates.bal +++ b/examples/raw-templates/raw_templates.bal @@ -1,13 +1,26 @@ import ballerina/io; -function foo() returns boolean { +function col3() returns boolean { return false; } +type MyCSVRawTemplate object { + *object:RawTemplate; + public (string[] & readonly) strings; + public [int, int, boolean] insertions; +}; + public function main() { - int x = 5; - error y = error("foo"); - object:RawTemplate rawTemplate = `x is ${x}. y is ${y}. The result of calling foo is ${foo()}`; + int col1 = 5; + int col2 = 10; + + // No static type validation for interpolation + object:RawTemplate rawTemplate = `${col1}, ${col2}, ${col3()}`; io:println(rawTemplate.strings); io:println(rawTemplate.insertions); + + // validate interpolations at compile time + MyCSVRawTemplate myCSVRawTemplate = `${col1}, ${col2}, ${col3()}`; + io:println(myCSVRawTemplate.strings); + io:println(myCSVRawTemplate.insertions); } diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 5f03d84e04..34d7ee5a49 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -1,6 +1,8 @@ # Raw templates -Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form`${expression}`). The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. +Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form`${expression}`). The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. + +If you want to control the type of values used for interpolation more precisely, you can define an object type that includes the `RawTemplate` type and give a narrower type for the `insertions` fields. Then, the compiler will statically verify that the corresponding values used for interpolation belong to the desired type. ::: code raw_templates.bal ::: @@ -8,3 +10,4 @@ Raw template expressions are backtick templates without a tag (such as `string` ## Related links - [Backtick templates](https://ballerina.io/learn/by-example/backtick-templates/) +- [Object type inclusion](https://ballerina.io/learn/by-example/object-type-inclusion/) diff --git a/examples/raw-templates/raw_templates.out b/examples/raw-templates/raw_templates.out index 9b3a7f3230..e9475adff1 100644 --- a/examples/raw-templates/raw_templates.out +++ b/examples/raw-templates/raw_templates.out @@ -1,3 +1,5 @@ $ bal run -["x is ",". y is ",". result of calling foo is ",""] -[5,error("foo"),false] +["",", ",", ",""] +[5,10,false] +["",", ",", ",""] +[5,10,false] From 3b6fa3202b2617654094af3778a73854d59767e4 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Mon, 21 Oct 2024 17:18:17 +0530 Subject: [PATCH 25/80] Temporary ignore trivy failures --- .trivyignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.trivyignore b/.trivyignore index 8bf29cb9eb..b368b1a740 100644 --- a/.trivyignore +++ b/.trivyignore @@ -14,4 +14,8 @@ CVE-2024-21742 # Fixed version is released yet CVE-2023-33201 -CVE-2023-33202 +CVE-2023-33202 + +# Temporary false positive +CVE-2024-7254 +CVE-2024-47554 From 31568a79c21d110e399dc1821e7afab2c1875ad0 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 22 Oct 2024 01:07:01 +0530 Subject: [PATCH 26/80] Fix archive linux-arm deb hashes --- .github/workflows/daily-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index 1fdb034ca6..e19ba8bdb9 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -351,7 +351,7 @@ jobs: - name: Archive Linux deb Hashes uses: actions/upload-artifact@v4 with: - name: Linux deb Hashes + name: Linux-ARM deb Hashes path: ballerina-${{ needs.ubuntu-build.outputs.project-version }}-linux-arm-x64.deb.sha256 macos-installer-build: From 6b88fc9a68d3d3712d5100f6d48132c4d5ee215a Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Mon, 21 Oct 2024 19:36:26 +0530 Subject: [PATCH 27/80] Update the RegExp type BBE --- examples/regexp-type/regexp_type.bal | 27 ++++++++++++++++++--------- examples/regexp-type/regexp_type.md | 7 ++++--- examples/regexp-type/regexp_type.out | 2 ++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/examples/regexp-type/regexp_type.bal b/examples/regexp-type/regexp_type.bal index b9f4b9611e..06d2cf6cd3 100644 --- a/examples/regexp-type/regexp_type.bal +++ b/examples/regexp-type/regexp_type.bal @@ -3,10 +3,16 @@ import ballerina/lang.regexp; public function main() returns error? { - // Declare a RegExp using regular expression literal. - string:RegExp _ = re `[a-zA-Z0-9]`; + // Declare a `RegExp` value using a regular expression literal. + regexp:RegExp alphanumericPattern = re `[a-zA-Z0-9]`; + // Matches any string that is a single alphanumeric character. + io:println("Pattern `[a-zA-Z0-9]` matches `a`: ", alphanumericPattern.isFullMatch("a")); - // Declare a RegExp using the `fromString` constructor method. + // `string:RegExp` is an alias for `regexp:RegExp`. + string:RegExp alphanumericPattern2 = re `[a-zA-Z0-9]`; + io:println("Pattern `[a-zA-Z0-9]` matches `a1`: ", alphanumericPattern2.isFullMatch("a1")); + + // Construct a `RegExp` value from a string using the `fromString` langlib function. string:RegExp pattern = check regexp:fromString("HELLO*"); // Matches any string that starts with "HELLO" and ends with zero or more characters. io:println("Pattern `HELLO*` matches `HELLO`: ", pattern.isFullMatch("HELLO")); @@ -15,13 +21,13 @@ public function main() returns error? { boolean result = re `a+`.isFullMatch("aaa"); io:println("Pattern `a+` matches `aaa`: ", result); - // Interpolation can be used to change the pattern dynamically. + // Interpolations can be used to construct the pattern dynamically. string literal = "xyz"; string:RegExp pattern2 = re `abc|${literal}`; // Matches any string that starts with "abc" or "XYZ". io:println("Pattern `abc|${\"xyz\"}` matches `xyz`: ", pattern2.isFullMatch("xyz")); - // RegExp supports writing Unicode general category patterns. + // The `RegExp` type supports Unicode general category patterns. // Characters are matched based on their Unicode properties. string:RegExp pattern3 = re `\p{Ll}`; io:println("Pattern `\\p{Ll}` matches `a`: ", "a".matches(pattern3)); @@ -31,12 +37,15 @@ public function main() returns error? { string:RegExp pattern4 = re `\P{P}`; io:println("Pattern `\\p{P}` matches `0`: ", "0".matches(pattern4)); - // RegExp supports matching characters according to the script using Unicode script patterns. + // The `RegExp` type supports matching characters according to the script using Unicode script patterns. string:RegExp pattern5 = re `\p{sc=Latin}`; - regexp:Span? latinValue = pattern5.find("aεЛ"); - io:println("Pattern `\\p{sc=Latin}` matches `aεЛ`: ", (latinValue).substring()); + regexp:Span? findResult = pattern5.find("aεЛ"); + // The `find` function returns nil if no match is found. Since we know a + // match is found here, use the `ensureType` function to narrow the type down to `regexp:Span`. + regexp:Span latinValue = check findResult.ensureType(); + io:println("Pattern `\\p{sc=Latin}` matches `aεЛ`: ", latinValue.substring()); - // RegExp supports non-capturing groups to control the behavior of regular expression patterns. + // The `RegExp` type supports non-capturing groups to control the behavior of regular expression patterns. // The `i` flag will ignore the case of the pattern. string:RegExp pattern6 = re `(?i:BalleRINA)`; io:println("Pattern `(?i:BalleRINA)` matches `Ballerina`: ", "Ballerina".matches(pattern6)); diff --git a/examples/regexp-type/regexp_type.md b/examples/regexp-type/regexp_type.md index 622a422169..d3607f1bba 100644 --- a/examples/regexp-type/regexp_type.md +++ b/examples/regexp-type/regexp_type.md @@ -4,7 +4,7 @@ The `RegExp` type is defined in the `lang.regexp` module, and can also be referenced using the type alias named the same in the `lang.string` module. The `RegExp` type conforms to a subset of the ECMAScript specification for regular expressions. -A `RegExp` value can be created by using the regexp template expression or calling the `fromString` method of the [lang.regexp](https://lib.ballerina.io/ballerina/lang.regexp/latest#fromString) module. +A `RegExp` value can be created by using the regexp template expression or calling the [`fromString` method of the lang.regexp](https://lib.ballerina.io/ballerina/lang.regexp/latest#fromString) module. ::: code regexp_type.bal ::: @@ -13,5 +13,6 @@ A `RegExp` value can be created by using the regexp template expression or calli ## Related links - [Ballerina regular expression grammar](https://ballerina.io/spec/lang/master/#section_10.1) - [RegExp langlib functions](/learn/by-example/regexp-operations) -- [RegExp API Docs](https://lib.ballerina.io/ballerina/lang.regexp) -- [string API Docs](https://lib.ballerina.io/ballerina/lang.string) +- [`regexp` langlib API Docs](https://lib.ballerina.io/ballerina/lang.regexp) +- [`string` langlib API Docs](https://lib.ballerina.io/ballerina/lang.string) +- [The `ensureType` function](/learn/by-example/ensureType-function/) diff --git a/examples/regexp-type/regexp_type.out b/examples/regexp-type/regexp_type.out index d5b8c9f0e8..cba26a1ac4 100644 --- a/examples/regexp-type/regexp_type.out +++ b/examples/regexp-type/regexp_type.out @@ -1,4 +1,6 @@ $ bal run regexp_type.bal +Pattern `[a-zA-Z0-9]` matches `a`: true +Pattern `[a-zA-Z0-9]` matches `a1`: false Pattern `HELLO*` matches `HELLO`: true Pattern `a+` matches `aaa`: true Pattern `abc|${"xyz"}` matches `xyz`: true From 681a277b736be76a588192deed7a573dfd2ee8c3 Mon Sep 17 00:00:00 2001 From: anupama-pathirage Date: Tue, 22 Oct 2024 12:52:33 -0500 Subject: [PATCH 28/80] Add issue template --- .github/ISSUE_TEMPLATE/bug.yml | 31 +++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 11 ++++++++ .github/ISSUE_TEMPLATE/improvement.yml | 25 +++++++++++++++++ .github/ISSUE_TEMPLATE/new-feature.yml | 32 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/task.yml | 18 ++++++++++++ .github/ISSUE_TEMPLATE/type_bug.md | 24 ---------------- .github/ISSUE_TEMPLATE/type_improvement.md | 22 --------------- .github/ISSUE_TEMPLATE/type_new_feature.md | 22 --------------- .github/ISSUE_TEMPLATE/type_task.md | 20 -------------- 9 files changed, 117 insertions(+), 88 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/improvement.yml create mode 100644 .github/ISSUE_TEMPLATE/new-feature.yml create mode 100644 .github/ISSUE_TEMPLATE/task.yml delete mode 100644 .github/ISSUE_TEMPLATE/type_bug.md delete mode 100644 .github/ISSUE_TEMPLATE/type_improvement.md delete mode 100644 .github/ISSUE_TEMPLATE/type_new_feature.md delete mode 100644 .github/ISSUE_TEMPLATE/type_task.md diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000000..1c1bfe3ff4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,31 @@ +name: "🐞 Report a Bug" +description: Create an issue if something does not work as expected. +labels: ["Type/Bug"] +body: + - type: textarea + id: background + attributes: + label: Description + description: Please share a clear and concise description of the problem. + placeholder: Description + - type: textarea + id: steps + attributes: + label: Steps to Reproduce + description: List the steps you followed when you encountered the issue. Provide sample source code to reproduce the issue where applicable. + validations: + required: true + - type: input + id: version + attributes: + label: Version + description: Enter product/component version. + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment Details (with versions) + description: Mention the environment details (OS, Client, etc.) that the product is running on. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..aa6f24cfbd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: false +contact_links: +- name: '📚 Documentation Issue' + about: Request a new article, missing topic, or report an issue if a topic is incorrect in the current documentation. + url: https://github.com/ballerina-platform/ballerina-dev-website/issues/new/choose +- name: General Question + url: https://stackoverflow.com/questions/tagged/ballerina + about: "If you have a question then please ask on Stack Overflow using the #ballerina tag." +- name: Chat on Ballerina Discord Channel + url: https://discord.gg/ballerinalang + about: "Chat about anything else with the community." diff --git a/.github/ISSUE_TEMPLATE/improvement.yml b/.github/ISSUE_TEMPLATE/improvement.yml new file mode 100644 index 0000000000..053bfa803d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/improvement.yml @@ -0,0 +1,25 @@ +name: "🚀 Improvement Request" +description: Suggest an improvement to the product. +labels: ["Type/Improvement"] +body: + - type: textarea + id: limitation + attributes: + label: Current Limitation + description: Describe the the current limitation. + validations: + required: true + - type: textarea + id: suggestion + attributes: + label: Suggested Improvement + description: Describe the the improvement you suggest. + validations: + required: true + - type: input + id: version + attributes: + label: Version + description: Enter component version. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/new-feature.yml b/.github/ISSUE_TEMPLATE/new-feature.yml new file mode 100644 index 0000000000..39dd56f35e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new-feature.yml @@ -0,0 +1,32 @@ +name: "💡 New Feature Request" +description: Suggest new functionality and features for the product. +labels: ["Type/NewFeature"] +body: + - type: textarea + id: problem + attributes: + label: Problem + description: What is the problem this feature will solve? + validations: + required: true + - type: textarea + id: solution + attributes: + label: Proposed Solution + description: Describe the solution you'd like to have. + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternatives + description: Describe any alternatives have you considered + validations: + required: false + - type: input + id: version + attributes: + label: Version + description: Enter product/component version. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/task.yml b/.github/ISSUE_TEMPLATE/task.yml new file mode 100644 index 0000000000..ff238a0ec7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/task.yml @@ -0,0 +1,18 @@ +name: "✍️ Create a Task" +description: Create a new task. +labels: ["Type/Task"] +body: + - type: textarea + id: description + attributes: + label: Description + description: A clear description of what needs to be done. + validations: + required: true + - type: input + id: version + attributes: + label: Version + description: Enter product/component version. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/type_bug.md b/.github/ISSUE_TEMPLATE/type_bug.md deleted file mode 100644 index b14deabca5..0000000000 --- a/.github/ISSUE_TEMPLATE/type_bug.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: "Bug Report" -about: "Report a bug if something is not working as expected" -labels: 'Type/Bug' - ---- - -**Description:** - - -**Steps to reproduce:** - -**Affected Versions:** - -**OS, DB, other environment details and versions:** - -**Related Issues (optional):** - - -**Suggested Labels (optional):** - - -**Suggested Assignees (optional):** - diff --git a/.github/ISSUE_TEMPLATE/type_improvement.md b/.github/ISSUE_TEMPLATE/type_improvement.md deleted file mode 100644 index c7af3704ec..0000000000 --- a/.github/ISSUE_TEMPLATE/type_improvement.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: "Improvement Request" -about: "Create an improvement request for an existing feature" -labels: 'Type/Improvement' - ---- - -**Description:** - - -**Describe your problem(s)** - -**Describe your solution(s)** - -**Related Issues (optional):** - - -**Suggested Labels (optional):** - - -**Suggested Assignees (optional):** - diff --git a/.github/ISSUE_TEMPLATE/type_new_feature.md b/.github/ISSUE_TEMPLATE/type_new_feature.md deleted file mode 100644 index 72c00dfc4f..0000000000 --- a/.github/ISSUE_TEMPLATE/type_new_feature.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: "New Feature Request" -about: "Create a new feature request" -labels: 'Type/NewFeature' - ---- - -**Description:** - - -**Describe your problem(s)** - -**Describe your solution(s)** - -**Related Issues (optional):** - - -**Suggested Labels (optional):** - - -**Suggested Assignees (optional):** - diff --git a/.github/ISSUE_TEMPLATE/type_task.md b/.github/ISSUE_TEMPLATE/type_task.md deleted file mode 100644 index 2cc8fbedb4..0000000000 --- a/.github/ISSUE_TEMPLATE/type_task.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: "Task" -about: "Create a task which you want to keep track" -labels: 'Type/Task' - ---- - -**Description:** - - -**Describe your task(s)** - -**Related Issues (optional):** - - -**Suggested Labels (optional):** - - -**Suggested Assignees (optional):** - From 71a8d44c00c7c043a6976f4368e73c2a18a9a448 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Wed, 23 Oct 2024 19:07:02 +0530 Subject: [PATCH 29/80] Change output --- examples/raw-templates/raw_templates.bal | 4 ++-- examples/raw-templates/raw_templates.out | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/raw-templates/raw_templates.bal b/examples/raw-templates/raw_templates.bal index 3a18087003..5283aa85af 100644 --- a/examples/raw-templates/raw_templates.bal +++ b/examples/raw-templates/raw_templates.bal @@ -15,12 +15,12 @@ public function main() { int col2 = 10; // No static type validation for interpolation - object:RawTemplate rawTemplate = `${col1}, ${col2}, ${col3()}`; + object:RawTemplate rawTemplate = `${col1}, fixed_string1, ${col2}, ${col3()}, fixed_string3`; io:println(rawTemplate.strings); io:println(rawTemplate.insertions); // validate interpolations at compile time - MyCSVRawTemplate myCSVRawTemplate = `${col1}, ${col2}, ${col3()}`; + MyCSVRawTemplate myCSVRawTemplate = `fixed_string4, ${col1}, ${col2}, fixed_string_5, ${col3()}`; io:println(myCSVRawTemplate.strings); io:println(myCSVRawTemplate.insertions); } diff --git a/examples/raw-templates/raw_templates.out b/examples/raw-templates/raw_templates.out index e9475adff1..6e88292894 100644 --- a/examples/raw-templates/raw_templates.out +++ b/examples/raw-templates/raw_templates.out @@ -1,5 +1,5 @@ $ bal run -["",", ",", ",""] +["",", fixed_string1, ",", ",", fixed_string3"] [5,10,false] -["",", ",", ",""] +["fixed_string4, ",", ",", fixed_string_5, ",""] [5,10,false] From b951d3a104b3588f7b5707ad39ab315fe00c3dac Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 26 Sep 2024 10:39:11 +0530 Subject: [PATCH 30/80] Regex replace operations --- examples/index.json | 7 ++++++ .../regexp_replace_operations.bal | 23 +++++++++++++++++++ .../regexp_replace_operations.md | 12 ++++++++++ .../regexp_replace_operations.metatags | 2 ++ .../regexp_replace_operations.out | 3 +++ 5 files changed, 47 insertions(+) create mode 100644 examples/regexp-replace-operations/regexp_replace_operations.bal create mode 100644 examples/regexp-replace-operations/regexp_replace_operations.md create mode 100644 examples/regexp-replace-operations/regexp_replace_operations.metatags create mode 100644 examples/regexp-replace-operations/regexp_replace_operations.out diff --git a/examples/index.json b/examples/index.json index d0e4ceb86b..f5373b1e95 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1223,6 +1223,13 @@ "verifyBuild": true, "verifyOutput": true, "isLearnByExample": true + }, + { + "name": "RegExp replace operations", + "url": "regexp-replace-operations", + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true } ] }, diff --git a/examples/regexp-replace-operations/regexp_replace_operations.bal b/examples/regexp-replace-operations/regexp_replace_operations.bal new file mode 100644 index 0000000000..14bf926c0e --- /dev/null +++ b/examples/regexp-replace-operations/regexp_replace_operations.bal @@ -0,0 +1,23 @@ +import ballerina/io; + +public function main() { + string creditCardNumber = "1234-5678-9876-5432"; + string:RegExp pattern = re `(\d{4})-(\d{4})-(\d{4})`; + // Replaces the first occurrence of the credit card pattern with a masked representation. + string maskedCardNumber = pattern.replace(creditCardNumber, "****-****-****"); + io:println(maskedCardNumber); + + string xmlString = "" + + "" + + "Value 1" + + "Value 2" + + "" + + "Value 3" + + ""; + + // Regular expression to match XML comments + string:RegExp commentPattern = re ``; + // Replaces all occurrences of XML comments with an empty string, effectively removing them. + string commentsRemoved = commentPattern.replaceAll(xmlString, ""); + io:println(string `Comments removed XML: ${commentsRemoved}`); +} diff --git a/examples/regexp-replace-operations/regexp_replace_operations.md b/examples/regexp-replace-operations/regexp_replace_operations.md new file mode 100644 index 0000000000..f952793961 --- /dev/null +++ b/examples/regexp-replace-operations/regexp_replace_operations.md @@ -0,0 +1,12 @@ +# RegExp operations + +The ``RegExp`` type supports a set of anguage library functions for replacing patterns in strings. + +::: code regexp_replace_operations.bal ::: + +::: out regexp_replace_operations.out ::: + +## Related links +- [RegExp type](/learn/by-example/regexp-type) +- [RegExp API Docs](https://lib.ballerina.io/ballerina/lang.regexp) +- [string API Docs](https://lib.ballerina.io/ballerina/lang.string) diff --git a/examples/regexp-replace-operations/regexp_replace_operations.metatags b/examples/regexp-replace-operations/regexp_replace_operations.metatags new file mode 100644 index 0000000000..51eae072fa --- /dev/null +++ b/examples/regexp-replace-operations/regexp_replace_operations.metatags @@ -0,0 +1,2 @@ +description: This BBE demonstrates how to use the regexp langlib functions relevant to regex replace operations. +keywords: ballerina, ballerina by example, bbe, regexp, RegExp, regex, regular expressions, ballerina regex functions, regexp langlib functions, replace, replaceAll diff --git a/examples/regexp-replace-operations/regexp_replace_operations.out b/examples/regexp-replace-operations/regexp_replace_operations.out new file mode 100644 index 0000000000..ddb83cec6b --- /dev/null +++ b/examples/regexp-replace-operations/regexp_replace_operations.out @@ -0,0 +1,3 @@ +$ bal run regexp_replace_operations.bal +****-****-****-5432 +Comments removed XML: Value 1Value 2Value 3 From b8268de85762afedc1e466990591446f80f1f23d Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Fri, 18 Oct 2024 11:45:38 +0530 Subject: [PATCH 31/80] Address review suggestions --- examples/index.json | 4 ++-- ...ons.bal => regexp_operations_overview.bal} | 0 ...tions.md => regexp_operations_overview.md} | 4 ++-- ...gs => regexp_operations_overview.metatags} | 0 ...ons.out => regexp_operations_overview.out} | 0 .../regexp_replace_operations.bal | 19 +++++++------------ .../regexp_replace_operations.md | 2 +- .../regexp_replace_operations.out | 2 +- 8 files changed, 13 insertions(+), 18 deletions(-) rename examples/regexp-operations/{regexp_operations.bal => regexp_operations_overview.bal} (100%) rename examples/regexp-operations/{regexp_operations.md => regexp_operations_overview.md} (78%) rename examples/regexp-operations/{regexp_operations.metatags => regexp_operations_overview.metatags} (100%) rename examples/regexp-operations/{regexp_operations.out => regexp_operations_overview.out} (100%) diff --git a/examples/index.json b/examples/index.json index f5373b1e95..0f16c08a45 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1218,8 +1218,8 @@ "isLearnByExample": true }, { - "name": "RegExp operations", - "url": "regexp-operations", + "name": "RegExp operations overview", + "url": "regexp_operations_overview", "verifyBuild": true, "verifyOutput": true, "isLearnByExample": true diff --git a/examples/regexp-operations/regexp_operations.bal b/examples/regexp-operations/regexp_operations_overview.bal similarity index 100% rename from examples/regexp-operations/regexp_operations.bal rename to examples/regexp-operations/regexp_operations_overview.bal diff --git a/examples/regexp-operations/regexp_operations.md b/examples/regexp-operations/regexp_operations_overview.md similarity index 78% rename from examples/regexp-operations/regexp_operations.md rename to examples/regexp-operations/regexp_operations_overview.md index ae4bf653f9..8843f7712d 100644 --- a/examples/regexp-operations/regexp_operations.md +++ b/examples/regexp-operations/regexp_operations_overview.md @@ -2,9 +2,9 @@ The ``RegExp`` type supports a set of langlib functions to search and manipulate string values. -::: code regexp_operations.bal ::: +::: code regexp_operations_overview.bal ::: -::: out regexp_operations.out ::: +::: out regexp_operations_overview.out ::: ## Related links - [RegExp type](/learn/by-example/regexp-type) diff --git a/examples/regexp-operations/regexp_operations.metatags b/examples/regexp-operations/regexp_operations_overview.metatags similarity index 100% rename from examples/regexp-operations/regexp_operations.metatags rename to examples/regexp-operations/regexp_operations_overview.metatags diff --git a/examples/regexp-operations/regexp_operations.out b/examples/regexp-operations/regexp_operations_overview.out similarity index 100% rename from examples/regexp-operations/regexp_operations.out rename to examples/regexp-operations/regexp_operations_overview.out diff --git a/examples/regexp-replace-operations/regexp_replace_operations.bal b/examples/regexp-replace-operations/regexp_replace_operations.bal index 14bf926c0e..761a9164c9 100644 --- a/examples/regexp-replace-operations/regexp_replace_operations.bal +++ b/examples/regexp-replace-operations/regexp_replace_operations.bal @@ -3,21 +3,16 @@ import ballerina/io; public function main() { string creditCardNumber = "1234-5678-9876-5432"; string:RegExp pattern = re `(\d{4})-(\d{4})-(\d{4})`; - // Replaces the first occurrence of the credit card pattern with a masked representation. + // Replace the first occurrence of the credit card pattern with a masked representation. string maskedCardNumber = pattern.replace(creditCardNumber, "****-****-****"); io:println(maskedCardNumber); - string xmlString = "" + - "" + - "Value 1" + - "Value 2" + - "" + - "Value 3" + - ""; + xml xmlString = + xml `value1value2>`; - // Regular expression to match XML comments + // Regular expression to match XML comments. string:RegExp commentPattern = re ``; - // Replaces all occurrences of XML comments with an empty string, effectively removing them. - string commentsRemoved = commentPattern.replaceAll(xmlString, ""); - io:println(string `Comments removed XML: ${commentsRemoved}`); + // Replace all occurrences of XML comments with an empty string, effectively removing them. + string commentsRemovedXml = commentPattern.replaceAll(xmlString.toString(), ""); + io:println("XML string with comments removed: ", commentsRemovedXml); } diff --git a/examples/regexp-replace-operations/regexp_replace_operations.md b/examples/regexp-replace-operations/regexp_replace_operations.md index f952793961..c4dd8cf6eb 100644 --- a/examples/regexp-replace-operations/regexp_replace_operations.md +++ b/examples/regexp-replace-operations/regexp_replace_operations.md @@ -1,6 +1,6 @@ # RegExp operations -The ``RegExp`` type supports a set of anguage library functions for replacing patterns in strings. +The `RegExp` type supports a set of langlib functions to replace parts of strings that match specific patterns. ::: code regexp_replace_operations.bal ::: diff --git a/examples/regexp-replace-operations/regexp_replace_operations.out b/examples/regexp-replace-operations/regexp_replace_operations.out index ddb83cec6b..fcb91c4c2f 100644 --- a/examples/regexp-replace-operations/regexp_replace_operations.out +++ b/examples/regexp-replace-operations/regexp_replace_operations.out @@ -1,3 +1,3 @@ $ bal run regexp_replace_operations.bal ****-****-****-5432 -Comments removed XML: Value 1Value 2Value 3 +XML string with comments removed: value1value2> \ No newline at end of file From 2b50c1775ae39ca072c6db781cd6b43e28c7ea8d Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Mon, 21 Oct 2024 14:22:55 +0530 Subject: [PATCH 32/80] Update regex and folder name --- .../regexp-replace-operations/regexp_replace_operations.bal | 2 +- .../regexp-replace-operations/regexp_replace_operations.out | 2 +- .../regexp_operations_overview.bal | 0 .../regexp_operations_overview.md | 0 .../regexp_operations_overview.metatags | 0 .../regexp_operations_overview.out | 2 +- 6 files changed, 3 insertions(+), 3 deletions(-) rename examples/{regexp-operations => regexp_operations_overview}/regexp_operations_overview.bal (100%) rename examples/{regexp-operations => regexp_operations_overview}/regexp_operations_overview.md (100%) rename examples/{regexp-operations => regexp_operations_overview}/regexp_operations_overview.metatags (100%) rename examples/{regexp-operations => regexp_operations_overview}/regexp_operations_overview.out (82%) diff --git a/examples/regexp-replace-operations/regexp_replace_operations.bal b/examples/regexp-replace-operations/regexp_replace_operations.bal index 761a9164c9..abd6375d9c 100644 --- a/examples/regexp-replace-operations/regexp_replace_operations.bal +++ b/examples/regexp-replace-operations/regexp_replace_operations.bal @@ -2,7 +2,7 @@ import ballerina/io; public function main() { string creditCardNumber = "1234-5678-9876-5432"; - string:RegExp pattern = re `(\d{4})-(\d{4})-(\d{4})`; + string:RegExp pattern = re `\d{4}-\d{4}-\d{4}`; // Replace the first occurrence of the credit card pattern with a masked representation. string maskedCardNumber = pattern.replace(creditCardNumber, "****-****-****"); io:println(maskedCardNumber); diff --git a/examples/regexp-replace-operations/regexp_replace_operations.out b/examples/regexp-replace-operations/regexp_replace_operations.out index fcb91c4c2f..49d925fb52 100644 --- a/examples/regexp-replace-operations/regexp_replace_operations.out +++ b/examples/regexp-replace-operations/regexp_replace_operations.out @@ -1,3 +1,3 @@ $ bal run regexp_replace_operations.bal ****-****-****-5432 -XML string with comments removed: value1value2> \ No newline at end of file +XML string with comments removed: value1value2> diff --git a/examples/regexp-operations/regexp_operations_overview.bal b/examples/regexp_operations_overview/regexp_operations_overview.bal similarity index 100% rename from examples/regexp-operations/regexp_operations_overview.bal rename to examples/regexp_operations_overview/regexp_operations_overview.bal diff --git a/examples/regexp-operations/regexp_operations_overview.md b/examples/regexp_operations_overview/regexp_operations_overview.md similarity index 100% rename from examples/regexp-operations/regexp_operations_overview.md rename to examples/regexp_operations_overview/regexp_operations_overview.md diff --git a/examples/regexp-operations/regexp_operations_overview.metatags b/examples/regexp_operations_overview/regexp_operations_overview.metatags similarity index 100% rename from examples/regexp-operations/regexp_operations_overview.metatags rename to examples/regexp_operations_overview/regexp_operations_overview.metatags diff --git a/examples/regexp-operations/regexp_operations_overview.out b/examples/regexp_operations_overview/regexp_operations_overview.out similarity index 82% rename from examples/regexp-operations/regexp_operations_overview.out rename to examples/regexp_operations_overview/regexp_operations_overview.out index 97c4630eaf..96c43e6822 100644 --- a/examples/regexp-operations/regexp_operations_overview.out +++ b/examples/regexp_operations_overview/regexp_operations_overview.out @@ -1,4 +1,4 @@ -$ bal run regexp_operations.bal +$ bal run regexp_operations_overview.bal ["bob@example.net","alice@example.com","charlie@example.org","david@example.xyz","invalid#@example.n%t"] ["bob","alice","charlie","david"] ["example.net","example.com","example.org","example.xyz"] From c1f6ecb5e26d84d5f5a96d0e14af323821222df7 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Wed, 23 Oct 2024 10:19:27 +0530 Subject: [PATCH 33/80] Update the regex_type link for functions --- examples/regexp-type/regexp_type.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/regexp-type/regexp_type.md b/examples/regexp-type/regexp_type.md index d3607f1bba..17703a4e7e 100644 --- a/examples/regexp-type/regexp_type.md +++ b/examples/regexp-type/regexp_type.md @@ -12,7 +12,6 @@ A `RegExp` value can be created by using the regexp template expression or calli ## Related links - [Ballerina regular expression grammar](https://ballerina.io/spec/lang/master/#section_10.1) -- [RegExp langlib functions](/learn/by-example/regexp-operations) -- [`regexp` langlib API Docs](https://lib.ballerina.io/ballerina/lang.regexp) -- [`string` langlib API Docs](https://lib.ballerina.io/ballerina/lang.string) -- [The `ensureType` function](/learn/by-example/ensureType-function/) +- [RegExp langlib functions overview](/learn/by-example/regexp_operations_overview) +- [RegExp API Docs](https://lib.ballerina.io/ballerina/lang.regexp) +- [string API Docs](https://lib.ballerina.io/ballerina/lang.string) From 26f2158929c8545600f96f494c4f51b6fccb7b83 Mon Sep 17 00:00:00 2001 From: rdulmina Date: Thu, 24 Oct 2024 16:42:08 +0530 Subject: [PATCH 34/80] Fix issue #9285 --- examples/joining-iterable-objects/joining_iterable_objects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/joining-iterable-objects/joining_iterable_objects.md b/examples/joining-iterable-objects/joining_iterable_objects.md index e66928aa2d..e0f2aab7c9 100644 --- a/examples/joining-iterable-objects/joining_iterable_objects.md +++ b/examples/joining-iterable-objects/joining_iterable_objects.md @@ -1,6 +1,6 @@ # Join iterable objects -A `join` clause performs an inner or left outer equijoin. The result is similar to using the nested `from` clauses and `where` clause. +A `join` clause performs an inner or left outer equi-join. The result is similar to using the nested `from` clauses and `where` clause. Variables declared in the query expression before the join clause are accessible only on the left side of the join condition, while variables declared in the join clause are accessible only on the right side of the join condition. ::: code joining_iterable_objects.bal ::: From d4c7e08756ec66230b8c1899edc1d50dba1556e7 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Fri, 25 Oct 2024 14:56:36 +0530 Subject: [PATCH 35/80] Include linux-arm installer build to release --- .github/workflows/publish-release.yml | 99 ++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 04048936f6..f53003b634 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -195,6 +195,8 @@ jobs: run: | cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}.sig --yes cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip --output-certificate ballerina-${{ steps.version-set.outputs.sversion }}.pem --output-signature ballerina-${{ steps.version-set.outputs.sversion }}.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig --yes cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig --yes cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig --yes cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig --yes @@ -202,6 +204,8 @@ jobs: run: | cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip --certificate ballerina-${{ steps.version-set.outputs.sversion }}.pem --signature ballerina-${{ steps.version-set.outputs.sversion }}.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com @@ -313,6 +317,60 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig asset_content_type: application/octet-stream + - name: Upload Linux zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip + asset_content_type: application/octet-stream + - name: Upload Linux zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem + asset_content_type: application/octet-stream + - name: Upload Linux zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig + asset_content_type: application/octet-stream + - name: Upload Linux-ARM zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip + asset_content_type: application/octet-stream + - name: Upload Linux-ARM zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem + asset_content_type: application/octet-stream + - name: Upload Linux-ARM zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig + asset_content_type: application/octet-stream - name: Upload MacOS zip artifacts uses: actions/upload-release-asset@v1 env: @@ -443,6 +501,45 @@ jobs: run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true env: TEST_MODE_ACTIVE: true + - name: Create linux-arm-deb Installer + id: run_installers_deb + run: | + cd installers/linux-deb + ./build-ballerina-linux-deb-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions -a arm + echo "Created linux-arm-deb successfully" + - name: Sign the linux-arm-deb installer + run: | + cosign sign-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig --yes + - name: Verify the linux-arm-deb installer + run: | + cosign verify-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Upload Linux-ARM deb Installer + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb + asset_path: installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb + asset_content_type: application/octet-stream + - name: Upload Linux-ARM deb Installer's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem + asset_content_type: application/octet-stream + - name: Upload Linux-ARM deb Installer's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig + asset_content_type: application/octet-stream - name: Post release PR env: GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} @@ -538,7 +635,7 @@ jobs: run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true env: TEST_MODE_ACTIVE: true - - name: Download MacOS-ARM Intaller Zip + - name: Download MacOS-ARM Installer Zip run: | wget https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{ needs.publish-release.outputs.release-version }}/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm.zip - name: Create macos-arm-pkg Installer From b770eadde3e4aa7afc2e246b0c2070ed21d2f588 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Mon, 28 Oct 2024 09:41:59 +0530 Subject: [PATCH 36/80] Update release workflow --- .github/workflows/publish-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index f53003b634..90c0a4adff 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -162,7 +162,6 @@ jobs: draft: false prerelease: ${{ github.event.inputs.isPreRelease }} - name: Create linux-deb Installer - id: run_installers_deb run: | cd installers/linux-deb ./build-ballerina-linux-deb-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions @@ -502,7 +501,6 @@ jobs: env: TEST_MODE_ACTIVE: true - name: Create linux-arm-deb Installer - id: run_installers_deb run: | cd installers/linux-deb ./build-ballerina-linux-deb-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions -a arm From e96bcfd3e8490a33ac679747a4b664aaac835a78 Mon Sep 17 00:00:00 2001 From: Dulmina Renuke Date: Mon, 28 Oct 2024 11:05:23 +0530 Subject: [PATCH 37/80] Update examples/joining-iterable-objects/joining_iterable_objects.md Co-authored-by: Gimantha Bandara --- examples/joining-iterable-objects/joining_iterable_objects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/joining-iterable-objects/joining_iterable_objects.md b/examples/joining-iterable-objects/joining_iterable_objects.md index e0f2aab7c9..52be878463 100644 --- a/examples/joining-iterable-objects/joining_iterable_objects.md +++ b/examples/joining-iterable-objects/joining_iterable_objects.md @@ -1,6 +1,6 @@ # Join iterable objects -A `join` clause performs an inner or left outer equi-join. The result is similar to using the nested `from` clauses and `where` clause. Variables declared in the query expression before the join clause are accessible only on the left side of the join condition, while variables declared in the join clause are accessible only on the right side of the join condition. +A `join` clause performs an inner or left outer equi-join. The result is similar to using the nested `from` clauses and a `where` clause. Variables declared in the query expression before the join clause are accessible only on the left side of the join condition, while variables declared in the join clause are accessible only on the right side of the join condition. ::: code joining_iterable_objects.bal ::: From 6c7b3eb1ccfff1ef6f36d11fabd38b82a7271c1d Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 26 Sep 2024 09:21:51 +0530 Subject: [PATCH 38/80] Add regexp match operations --- .../regexp-match-operations.bal | 40 +++++++++++++++++++ .../regexp-match-operations.md | 12 ++++++ .../regexp-match-operations.metatags | 2 + .../regexp-match-operations.out | 16 ++++++++ 4 files changed, 70 insertions(+) create mode 100644 examples/regexp-match-operations/regexp-match-operations.bal create mode 100644 examples/regexp-match-operations/regexp-match-operations.md create mode 100644 examples/regexp-match-operations/regexp-match-operations.metatags create mode 100644 examples/regexp-match-operations/regexp-match-operations.out diff --git a/examples/regexp-match-operations/regexp-match-operations.bal b/examples/regexp-match-operations/regexp-match-operations.bal new file mode 100644 index 0000000000..de4dd977b6 --- /dev/null +++ b/examples/regexp-match-operations/regexp-match-operations.bal @@ -0,0 +1,40 @@ +import ballerina/io; +import ballerina/lang.regexp; + +public function main() { + string[] productCodes = ["ELEC-1234", "FURN-5678", "CLOT-1111", "FOOD-3333"]; + + // Regular expression to match and validate product codes. + // Format: [PRODUCT_TYPE]-[UNIQUE_ID] + string:RegExp productCodePattern = re `^([A-Z]{4})-(\d{4})$`; + + foreach string productCode in productCodes { + // Check if the product code fully matches the expected format. + boolean isValidProductCode = productCodePattern.isFullMatch(productCode); + io:println(string `Product Code: ${productCode}, Valid: ${isValidProductCode}`); + + // If valid, extract the product type and unique ID from the match groups. + regexp:Groups? matchGroups = productCodePattern.fullMatchGroups(productCode); + if matchGroups is regexp:Groups { + string productType = (matchGroups[1]).substring(); + string uniqueID = (matchGroups[2]).substring(); + + io:println(string `Product Type: ${productType}`); + io:println(string `Unique ID: ${uniqueID}`); + } + } + + // Match product code from a specific starting index in the string. + regexp:Span productCode = productCodePattern.matchAt("Product code: FURN-5678", 14); + io:println(string `Matched product: ${productCode.substring()}`); + + // Regular expression to extract production time (HH:MM) from a log string + string:RegExp timePattern = re `([01][0-9]|2[0-3]):([0-5][0-9])`; + + // Find groups of the matching string from a specified starting index. + regexp:Groups timeMatchGroups = timePattern.matchGroupsAt("Production time: 14:35", 17); + string hour = (timeMatchGroups[1]).substring(); + string minutes = (timeMatchGroups[2]).substring(); + io:println(string `Production hour: ${hour}`); + io:println(string `Production minute: ${minutes}`); +} diff --git a/examples/regexp-match-operations/regexp-match-operations.md b/examples/regexp-match-operations/regexp-match-operations.md new file mode 100644 index 0000000000..5ae50eb3a9 --- /dev/null +++ b/examples/regexp-match-operations/regexp-match-operations.md @@ -0,0 +1,12 @@ +# RegExp operations + +The ``RegExp`` type include a set of langlib functions for matching patterns in strings, enabling operations to find, validate, group, and extract data based on regular expressions. + +::: code regexp-match-operations.bal ::: + +::: out regexp-match-operations.out ::: + +## Related links +- [RegExp type](/learn/by-example/regexp-type) +- [RegExp API Docs](https://lib.ballerina.io/ballerina/lang.regexp) +- [string API Docs](https://lib.ballerina.io/ballerina/lang.string) diff --git a/examples/regexp-match-operations/regexp-match-operations.metatags b/examples/regexp-match-operations/regexp-match-operations.metatags new file mode 100644 index 0000000000..5a3f330377 --- /dev/null +++ b/examples/regexp-match-operations/regexp-match-operations.metatags @@ -0,0 +1,2 @@ +description: This BBE demonstrates how to use the regexp langlib functions relevant to regex match operations. +keywords: ballerina, ballerina by example, bbe, regexp, RegExp, regex, regular expressions, ballerina regex functions, regexp langlib functions, fullMatchGroups, isFullMatch, matchAt, matchGroupsAt diff --git a/examples/regexp-match-operations/regexp-match-operations.out b/examples/regexp-match-operations/regexp-match-operations.out new file mode 100644 index 0000000000..dc77cb75d8 --- /dev/null +++ b/examples/regexp-match-operations/regexp-match-operations.out @@ -0,0 +1,16 @@ +$ bal run regexp-match-operations.bal +Product Code: ELEC-1234, Valid: true +Product Type: ELEC +Unique ID: 1234 +Product Code: FURN-5678, Valid: true +Product Type: FURN +Unique ID: 5678 +Product Code: CLOT-1111, Valid: true +Product Type: CLOT +Unique ID: 1111 +Product Code: FOOD-3333, Valid: true +Product Type: FOOD +Unique ID: 3333 +Matched product: FURN-5678 +Production hour: 14 +Production minute: 35 From d59768cde29c0822962a80c53a604060232ee176 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 26 Sep 2024 09:39:14 +0530 Subject: [PATCH 39/80] Update the index.json --- examples/index.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/index.json b/examples/index.json index e27e681cb7..811785646f 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1231,6 +1231,13 @@ "verifyOutput": true, "isLearnByExample": true } + { + "name": "RegExp match operations", + "url": "regexp-match-operations", + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true + } ] }, { From 7e4946870e2a938472b0d9e22b107167abfca606 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 26 Sep 2024 10:49:21 +0530 Subject: [PATCH 40/80] Update file names --- ...egexp-match-operations.bal => regexp_match_operations.bal} | 0 ...{regexp-match-operations.md => regexp_match_operations.md} | 4 ++-- ...h-operations.metatags => regexp_match_operations.metatags} | 0 ...egexp-match-operations.out => regexp_match_operations.out} | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename examples/regexp-match-operations/{regexp-match-operations.bal => regexp_match_operations.bal} (100%) rename examples/regexp-match-operations/{regexp-match-operations.md => regexp_match_operations.md} (83%) rename examples/regexp-match-operations/{regexp-match-operations.metatags => regexp_match_operations.metatags} (100%) rename examples/regexp-match-operations/{regexp-match-operations.out => regexp_match_operations.out} (90%) diff --git a/examples/regexp-match-operations/regexp-match-operations.bal b/examples/regexp-match-operations/regexp_match_operations.bal similarity index 100% rename from examples/regexp-match-operations/regexp-match-operations.bal rename to examples/regexp-match-operations/regexp_match_operations.bal diff --git a/examples/regexp-match-operations/regexp-match-operations.md b/examples/regexp-match-operations/regexp_match_operations.md similarity index 83% rename from examples/regexp-match-operations/regexp-match-operations.md rename to examples/regexp-match-operations/regexp_match_operations.md index 5ae50eb3a9..3f35c2c3d7 100644 --- a/examples/regexp-match-operations/regexp-match-operations.md +++ b/examples/regexp-match-operations/regexp_match_operations.md @@ -2,9 +2,9 @@ The ``RegExp`` type include a set of langlib functions for matching patterns in strings, enabling operations to find, validate, group, and extract data based on regular expressions. -::: code regexp-match-operations.bal ::: +::: code regexp_match_operations.bal ::: -::: out regexp-match-operations.out ::: +::: out regexp_match_operations.out ::: ## Related links - [RegExp type](/learn/by-example/regexp-type) diff --git a/examples/regexp-match-operations/regexp-match-operations.metatags b/examples/regexp-match-operations/regexp_match_operations.metatags similarity index 100% rename from examples/regexp-match-operations/regexp-match-operations.metatags rename to examples/regexp-match-operations/regexp_match_operations.metatags diff --git a/examples/regexp-match-operations/regexp-match-operations.out b/examples/regexp-match-operations/regexp_match_operations.out similarity index 90% rename from examples/regexp-match-operations/regexp-match-operations.out rename to examples/regexp-match-operations/regexp_match_operations.out index dc77cb75d8..e929b8b8d6 100644 --- a/examples/regexp-match-operations/regexp-match-operations.out +++ b/examples/regexp-match-operations/regexp_match_operations.out @@ -1,4 +1,4 @@ -$ bal run regexp-match-operations.bal +$ bal run regexp_match_operations.bal Product Code: ELEC-1234, Valid: true Product Type: ELEC Unique ID: 1234 From 6d4c795daf70f196678d326ddf16d825cdd9a54d Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Fri, 27 Sep 2024 10:13:33 +0530 Subject: [PATCH 41/80] Address review suggestions --- .../regexp_match_operations.bal | 21 ++++++++++++------- .../regexp_match_operations.md | 2 +- .../regexp_match_operations.out | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/regexp-match-operations/regexp_match_operations.bal b/examples/regexp-match-operations/regexp_match_operations.bal index de4dd977b6..373e42ead2 100644 --- a/examples/regexp-match-operations/regexp_match_operations.bal +++ b/examples/regexp-match-operations/regexp_match_operations.bal @@ -16,6 +16,9 @@ public function main() { // If valid, extract the product type and unique ID from the match groups. regexp:Groups? matchGroups = productCodePattern.fullMatchGroups(productCode); if matchGroups is regexp:Groups { + // The first element in the `matchGroups` is the entire matched string. + // The subsequent elements in `matchGroups` represent the captured groups + // (productType, uniqueID). string productType = (matchGroups[1]).substring(); string uniqueID = (matchGroups[2]).substring(); @@ -25,16 +28,20 @@ public function main() { } // Match product code from a specific starting index in the string. - regexp:Span productCode = productCodePattern.matchAt("Product code: FURN-5678", 14); - io:println(string `Matched product: ${productCode.substring()}`); + regexp:Span? productCode = productCodePattern.matchAt("Product code: FURN-5678", 14); + if productCode is regexp:Span { + io:println(string `Matched product: ${productCode.substring()}`); + } // Regular expression to extract production time (HH:MM) from a log string string:RegExp timePattern = re `([01][0-9]|2[0-3]):([0-5][0-9])`; // Find groups of the matching string from a specified starting index. - regexp:Groups timeMatchGroups = timePattern.matchGroupsAt("Production time: 14:35", 17); - string hour = (timeMatchGroups[1]).substring(); - string minutes = (timeMatchGroups[2]).substring(); - io:println(string `Production hour: ${hour}`); - io:println(string `Production minute: ${minutes}`); + regexp:Groups? timeMatchGroups = timePattern.matchGroupsAt("Production time: 14:35", 17); + if timeMatchGroups is regexp:Groups { + string hour = (timeMatchGroups[1]).substring(); + string minutes = (timeMatchGroups[2]).substring(); + io:println(string `Production hour: ${hour}`); + io:println(string `Production minutes: ${minutes}`); + } } diff --git a/examples/regexp-match-operations/regexp_match_operations.md b/examples/regexp-match-operations/regexp_match_operations.md index 3f35c2c3d7..8c5ae3c7f0 100644 --- a/examples/regexp-match-operations/regexp_match_operations.md +++ b/examples/regexp-match-operations/regexp_match_operations.md @@ -1,6 +1,6 @@ # RegExp operations -The ``RegExp`` type include a set of langlib functions for matching patterns in strings, enabling operations to find, validate, group, and extract data based on regular expressions. +The `RegExp` type include a set of langlib functions for matching patterns in strings, enabling operations to find, validate, group, and extract data based on regular expressions. ::: code regexp_match_operations.bal ::: diff --git a/examples/regexp-match-operations/regexp_match_operations.out b/examples/regexp-match-operations/regexp_match_operations.out index e929b8b8d6..eb32915f5f 100644 --- a/examples/regexp-match-operations/regexp_match_operations.out +++ b/examples/regexp-match-operations/regexp_match_operations.out @@ -13,4 +13,4 @@ Product Type: FOOD Unique ID: 3333 Matched product: FURN-5678 Production hour: 14 -Production minute: 35 +Production minutes: 35 From 49e970476291dac13eae793caafd3af86e498043 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Fri, 18 Oct 2024 10:16:23 +0530 Subject: [PATCH 42/80] Address review suggestions --- .../regexp_match_operations.bal | 42 ++++++++++++------- .../regexp_match_operations.md | 2 +- .../regexp_match_operations.out | 7 ++-- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/examples/regexp-match-operations/regexp_match_operations.bal b/examples/regexp-match-operations/regexp_match_operations.bal index 373e42ead2..921b3036b2 100644 --- a/examples/regexp-match-operations/regexp_match_operations.bal +++ b/examples/regexp-match-operations/regexp_match_operations.bal @@ -2,7 +2,7 @@ import ballerina/io; import ballerina/lang.regexp; public function main() { - string[] productCodes = ["ELEC-1234", "FURN-5678", "CLOT-1111", "FOOD-3333"]; + string[] productCodes = ["ELEC-1234", "FURN-5678", "CLOT-1111", "FOOD-3333", "BAR-123"]; // Regular expression to match and validate product codes. // Format: [PRODUCT_TYPE]-[UNIQUE_ID] @@ -13,35 +13,45 @@ public function main() { boolean isValidProductCode = productCodePattern.isFullMatch(productCode); io:println(string `Product Code: ${productCode}, Valid: ${isValidProductCode}`); - // If valid, extract the product type and unique ID from the match groups. + if !isValidProductCode { + continue; + } + + // For a valid product code, extract the product type and unique ID from the match groups. regexp:Groups? matchGroups = productCodePattern.fullMatchGroups(productCode); if matchGroups is regexp:Groups { - // The first element in the `matchGroups` is the entire matched string. - // The subsequent elements in `matchGroups` represent the captured groups - // (productType, uniqueID). - string productType = (matchGroups[1]).substring(); - string uniqueID = (matchGroups[2]).substring(); - - io:println(string `Product Type: ${productType}`); - io:println(string `Unique ID: ${uniqueID}`); + // The first member in the `matchGroups` tuple is the entire matched string. + // The subsequent members represent the captured groups. + // (assigned to `productType` and `uniqueID` respectively). + io:println("Product Type: ", extractStringFromMatchGroup(matchGroups[1])); + io:println("Unique ID: ", extractStringFromMatchGroup(matchGroups[2])); } } // Match product code from a specific starting index in the string. - regexp:Span? productCode = productCodePattern.matchAt("Product code: FURN-5678", 14); + regexp:Span? productCode = productCodePattern.matchAt( + "Product code: FURN-5678, Product code: CLOT-1234", 39); if productCode is regexp:Span { - io:println(string `Matched product: ${productCode.substring()}`); + io:println("Matched product: ", productCode.substring()); } - // Regular expression to extract production time (HH:MM) from a log string + // Regular expression to extract the time in the format `HH:MM` from a log string. string:RegExp timePattern = re `([01][0-9]|2[0-3]):([0-5][0-9])`; // Find groups of the matching string from a specified starting index. - regexp:Groups? timeMatchGroups = timePattern.matchGroupsAt("Production time: 14:35", 17); + regexp:Groups? timeMatchGroups = timePattern.matchGroupsAt( + "Production time: 14:35, Production time: 16:15", 41); if timeMatchGroups is regexp:Groups { string hour = (timeMatchGroups[1]).substring(); string minutes = (timeMatchGroups[2]).substring(); - io:println(string `Production hour: ${hour}`); - io:println(string `Production minutes: ${minutes}`); + io:println("Production hour: ", hour); + io:println("Production minutes: ", minutes); + } +} + +function extractStringFromMatchGroup(regexp:Span? span) returns string { + if span !is regexp:Span { + return ""; } + return span.substring(); } diff --git a/examples/regexp-match-operations/regexp_match_operations.md b/examples/regexp-match-operations/regexp_match_operations.md index 8c5ae3c7f0..b0905582b2 100644 --- a/examples/regexp-match-operations/regexp_match_operations.md +++ b/examples/regexp-match-operations/regexp_match_operations.md @@ -1,6 +1,6 @@ # RegExp operations -The `RegExp` type include a set of langlib functions for matching patterns in strings, enabling operations to find, validate, group, and extract data based on regular expressions. +The `RegExp` type support a set of langlib functions to match patterns in strings and enable operations such as finding, validating, grouping, and extracting data based on regular expressions. ::: code regexp_match_operations.bal ::: diff --git a/examples/regexp-match-operations/regexp_match_operations.out b/examples/regexp-match-operations/regexp_match_operations.out index eb32915f5f..c5b091b4dc 100644 --- a/examples/regexp-match-operations/regexp_match_operations.out +++ b/examples/regexp-match-operations/regexp_match_operations.out @@ -11,6 +11,7 @@ Unique ID: 1111 Product Code: FOOD-3333, Valid: true Product Type: FOOD Unique ID: 3333 -Matched product: FURN-5678 -Production hour: 14 -Production minutes: 35 +Product Code: BAR-123, Valid: false +Matched product: CLOT-1234 +Production hour: 16 +Production minutes: 15 From e8f092933eeadc9542a8096eaf947a1bf0abeb46 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Mon, 21 Oct 2024 14:18:33 +0530 Subject: [PATCH 43/80] Use ensureType instead of cast --- .../regexp_match_operations.bal | 21 +++++++------------ .../regexp_match_operations.md | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/examples/regexp-match-operations/regexp_match_operations.bal b/examples/regexp-match-operations/regexp_match_operations.bal index 921b3036b2..7dd7932af8 100644 --- a/examples/regexp-match-operations/regexp_match_operations.bal +++ b/examples/regexp-match-operations/regexp_match_operations.bal @@ -1,7 +1,7 @@ import ballerina/io; import ballerina/lang.regexp; -public function main() { +public function main() returns error? { string[] productCodes = ["ELEC-1234", "FURN-5678", "CLOT-1111", "FOOD-3333", "BAR-123"]; // Regular expression to match and validate product codes. @@ -21,10 +21,12 @@ public function main() { regexp:Groups? matchGroups = productCodePattern.fullMatchGroups(productCode); if matchGroups is regexp:Groups { // The first member in the `matchGroups` tuple is the entire matched string. - // The subsequent members represent the captured groups. + // The subsequent members represent the captured groups // (assigned to `productType` and `uniqueID` respectively). - io:println("Product Type: ", extractStringFromMatchGroup(matchGroups[1])); - io:println("Unique ID: ", extractStringFromMatchGroup(matchGroups[2])); + io:println("Product Type: ", + (check matchGroups[1].ensureType(regexp:Span)).substring()); + io:println("Unique ID: ", + (check matchGroups[2].ensureType(regexp:Span)).substring()); } } @@ -42,16 +44,9 @@ public function main() { regexp:Groups? timeMatchGroups = timePattern.matchGroupsAt( "Production time: 14:35, Production time: 16:15", 41); if timeMatchGroups is regexp:Groups { - string hour = (timeMatchGroups[1]).substring(); - string minutes = (timeMatchGroups[2]).substring(); + string hour = (check timeMatchGroups[1].ensureType(regexp:Span)).substring(); + string minutes = (check timeMatchGroups[2].ensureType(regexp:Span)).substring(); io:println("Production hour: ", hour); io:println("Production minutes: ", minutes); } } - -function extractStringFromMatchGroup(regexp:Span? span) returns string { - if span !is regexp:Span { - return ""; - } - return span.substring(); -} diff --git a/examples/regexp-match-operations/regexp_match_operations.md b/examples/regexp-match-operations/regexp_match_operations.md index b0905582b2..93bfe22249 100644 --- a/examples/regexp-match-operations/regexp_match_operations.md +++ b/examples/regexp-match-operations/regexp_match_operations.md @@ -1,6 +1,6 @@ # RegExp operations -The `RegExp` type support a set of langlib functions to match patterns in strings and enable operations such as finding, validating, grouping, and extracting data based on regular expressions. +The `RegExp` type supports a set of langlib functions to match patterns in strings and enable operations such as finding, validating, grouping, and extracting data based on regular expressions. ::: code regexp_match_operations.bal ::: From 0640e41c562314145f550a359b9f32286a9475cc Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 24 Oct 2024 12:13:07 +0530 Subject: [PATCH 44/80] Adjust comments --- examples/index.json | 2 +- examples/regexp-match-operations/regexp_match_operations.bal | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/index.json b/examples/index.json index 811785646f..97ab04bc67 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1230,7 +1230,7 @@ "verifyBuild": true, "verifyOutput": true, "isLearnByExample": true - } + }, { "name": "RegExp match operations", "url": "regexp-match-operations", diff --git a/examples/regexp-match-operations/regexp_match_operations.bal b/examples/regexp-match-operations/regexp_match_operations.bal index 7dd7932af8..4b9909a6fe 100644 --- a/examples/regexp-match-operations/regexp_match_operations.bal +++ b/examples/regexp-match-operations/regexp_match_operations.bal @@ -13,6 +13,7 @@ public function main() returns error? { boolean isValidProductCode = productCodePattern.isFullMatch(productCode); io:println(string `Product Code: ${productCode}, Valid: ${isValidProductCode}`); + // If the product code is invalid, skip further processing. if !isValidProductCode { continue; } @@ -22,7 +23,7 @@ public function main() returns error? { if matchGroups is regexp:Groups { // The first member in the `matchGroups` tuple is the entire matched string. // The subsequent members represent the captured groups - // (assigned to `productType` and `uniqueID` respectively). + // corresponding to product type and unique ID respectively. io:println("Product Type: ", (check matchGroups[1].ensureType(regexp:Span)).substring()); io:println("Unique ID: ", From a099fce782c4004a0aa7f2f9f660610c9b4fe74a Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Mon, 28 Oct 2024 15:23:41 +0530 Subject: [PATCH 45/80] Update examples/raw-templates/raw_templates.md Co-authored-by: Maryam Ziyad --- examples/raw-templates/raw_templates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 34d7ee5a49..caf45fabb7 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -1,6 +1,6 @@ # Raw templates -Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form`${expression}`). The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. +Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form `${expression}`). The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. If you want to control the type of values used for interpolation more precisely, you can define an object type that includes the `RawTemplate` type and give a narrower type for the `insertions` fields. Then, the compiler will statically verify that the corresponding values used for interpolation belong to the desired type. From 451fb4228819222bc3ef86a4a68b4b14916fff7e Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Mon, 28 Oct 2024 15:27:38 +0530 Subject: [PATCH 46/80] Fix comments --- examples/raw-templates/raw_templates.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/raw-templates/raw_templates.bal b/examples/raw-templates/raw_templates.bal index 5283aa85af..e25bdaafa6 100644 --- a/examples/raw-templates/raw_templates.bal +++ b/examples/raw-templates/raw_templates.bal @@ -14,12 +14,12 @@ public function main() { int col1 = 5; int col2 = 10; - // No static type validation for interpolation + // Allow any value as interpolations since object:RawTemplate has any|error[] as insertions type. object:RawTemplate rawTemplate = `${col1}, fixed_string1, ${col2}, ${col3()}, fixed_string3`; io:println(rawTemplate.strings); io:println(rawTemplate.insertions); - // validate interpolations at compile time + // Ensure we have 2 ints followed by a boolean value as interpolations based on insertions type. MyCSVRawTemplate myCSVRawTemplate = `fixed_string4, ${col1}, ${col2}, fixed_string_5, ${col3()}`; io:println(myCSVRawTemplate.strings); io:println(myCSVRawTemplate.insertions); From 9ddf89b850f6cf5818a05d198b5d4c994e0c9d02 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Tue, 29 Oct 2024 11:03:13 +0530 Subject: [PATCH 47/80] Update url --- examples/index.json | 2 +- .../regexp_operations_overview.bal | 0 .../regexp_operations_overview.md | 0 .../regexp_operations_overview.metatags | 0 .../regexp_operations_overview.out | 0 examples/regexp-type/regexp_type.md | 2 +- 6 files changed, 2 insertions(+), 2 deletions(-) rename examples/{regexp_operations_overview => regexp-operations-overview}/regexp_operations_overview.bal (100%) rename examples/{regexp_operations_overview => regexp-operations-overview}/regexp_operations_overview.md (100%) rename examples/{regexp_operations_overview => regexp-operations-overview}/regexp_operations_overview.metatags (100%) rename examples/{regexp_operations_overview => regexp-operations-overview}/regexp_operations_overview.out (100%) diff --git a/examples/index.json b/examples/index.json index 0f16c08a45..690fae3e89 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1219,7 +1219,7 @@ }, { "name": "RegExp operations overview", - "url": "regexp_operations_overview", + "url": "regexp-operations-overview", "verifyBuild": true, "verifyOutput": true, "isLearnByExample": true diff --git a/examples/regexp_operations_overview/regexp_operations_overview.bal b/examples/regexp-operations-overview/regexp_operations_overview.bal similarity index 100% rename from examples/regexp_operations_overview/regexp_operations_overview.bal rename to examples/regexp-operations-overview/regexp_operations_overview.bal diff --git a/examples/regexp_operations_overview/regexp_operations_overview.md b/examples/regexp-operations-overview/regexp_operations_overview.md similarity index 100% rename from examples/regexp_operations_overview/regexp_operations_overview.md rename to examples/regexp-operations-overview/regexp_operations_overview.md diff --git a/examples/regexp_operations_overview/regexp_operations_overview.metatags b/examples/regexp-operations-overview/regexp_operations_overview.metatags similarity index 100% rename from examples/regexp_operations_overview/regexp_operations_overview.metatags rename to examples/regexp-operations-overview/regexp_operations_overview.metatags diff --git a/examples/regexp_operations_overview/regexp_operations_overview.out b/examples/regexp-operations-overview/regexp_operations_overview.out similarity index 100% rename from examples/regexp_operations_overview/regexp_operations_overview.out rename to examples/regexp-operations-overview/regexp_operations_overview.out diff --git a/examples/regexp-type/regexp_type.md b/examples/regexp-type/regexp_type.md index 17703a4e7e..683d7935ab 100644 --- a/examples/regexp-type/regexp_type.md +++ b/examples/regexp-type/regexp_type.md @@ -12,6 +12,6 @@ A `RegExp` value can be created by using the regexp template expression or calli ## Related links - [Ballerina regular expression grammar](https://ballerina.io/spec/lang/master/#section_10.1) -- [RegExp langlib functions overview](/learn/by-example/regexp_operations_overview) +- [RegExp langlib functions overview](/learn/by-example/regexp-operations-overview) - [RegExp API Docs](https://lib.ballerina.io/ballerina/lang.regexp) - [string API Docs](https://lib.ballerina.io/ballerina/lang.string) From a1e9f0edc3c44a95fa418bcc48892758756b4d84 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 29 Oct 2024 14:27:45 +0530 Subject: [PATCH 48/80] Add release workflow for BI distribution --- .github/workflows/publish_release_bi.yml | 796 +++++++++++++++++++++++ 1 file changed, 796 insertions(+) create mode 100644 .github/workflows/publish_release_bi.yml diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml new file mode 100644 index 0000000000..00eb4ff82d --- /dev/null +++ b/.github/workflows/publish_release_bi.yml @@ -0,0 +1,796 @@ +name: Publish Release Kola Distribution + +on: + workflow_dispatch: + inputs: + isPreRelease: + description: 'Tag created is a pre-release tag' + required: true + default: 'false' + preReleaseSuffix: + description: 'The text that will be suffixed to the Git tag. e.g., rc1' + required: false + default: '' + +permissions: + id-token: write + contents: write + +jobs: + publish-release: + name: Publish Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17.0.7' + - name: Clone ballerina-dev-tools + run: git clone -b flow_model https://github.com/ballerina-platform/ballerina-dev-tools.git + - name: Build ballerina-dev-tools + id: build-dev-tools + env: + packageUser: ${{ github.actor }} + packagePAT: ${{ secrets.GITHUB_TOKEN }} + devCentralToken: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} + githubAccessToken: ${{ secrets.GITHUB_TOKEN }} + ballerinaBotWorkflow: $ {{ secrets.BALLERINA_BOT_WORKFLOW }} + TEST_MODE_ACTIVE: true + run: | + cd ballerina-dev-tools + echo "::set-output name=version::$(grep "^version=" gradle.properties | cut -d'=' -f2)" + echo "::set-output name=langVersion::$(grep "^ballerinaLangVersion=" gradle.properties | cut -d'=' -f2)" + ./gradlew clean build --stacktrace --scan -x test --console=plain --no-daemon --continue publishToMavenLocal + - name: Set version env variable + id: version-set + run: | + sed -i "s/^devToolsVersion=.*/devToolsVersion=${{ steps.build-dev-tools.outputs.version }}/" gradle.properties + sed -i "s/^ballerinaLangVersion=.*/ballerinaLangVersion=${{ steps.build-dev-tools.outputs.langVersion }}/" gradle.properties + SHORT_VERSION=$((grep -w 'version' | cut -d= -f2 | cut -d- -f1) < gradle.properties) + DIST_VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev) + LANG_VERSION=$((grep -w "ballerinaLangVersion" | cut -d= -f2 | cut -d- -f1 | xargs) < gradle.properties) + CODE_NAME=$((grep -w 'codeName' | cut -d= -f2) < gradle.properties) + RELEASE_VERSION=$DIST_VERSION + TAGGED_VERSION=$RELEASE_VERSION + LONG_VERSION=$DIST_VERSION-$CODE_NAME + if [ -n "${{ github.event.inputs.preReleaseSuffix }}" ]; then + TAGGED_VERSION=$RELEASE_VERSION-${{ github.event.inputs.preReleaseSuffix }} + fi + echo VERSION=$RELEASE_VERSION >> $GITHUB_ENV + echo GIT_TAG=$TAGGED_VERSION >> $GITHUB_ENV + echo "::set-output name=version::$RELEASE_VERSION" + echo "::set-output name=sversion::$SHORT_VERSION" + echo "::set-output name=taggedVersion::$TAGGED_VERSION" + echo "::set-output name=longVersion::$LONG_VERSION" + echo "::set-output name=langVersion::$LANG_VERSION" + - name: Pre release depenency version update + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + run: | + echo "Version: ${VERSION}" + echo "Tagged Version: ${GIT_TAG}" + git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }} + git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }} + git checkout -b release-${GIT_TAG} + - name: Generate UUID + run: | + UUID=$(uuidgen) + perl -pi -e "s/^\s*installerVersion=.*/installerVersion=$UUID/" gradle.properties + git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }} + git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }} + git add gradle.properties + git commit -m "Update UUID for installer" + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Publish artifact + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + devCentralToken: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} + prodCentralToken: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} + githubAccessToken: ${{ secrets.GITHUB_TOKEN }} + ballerinaBotWorkflow: $ {{ secrets.BALLERINA_BOT_WORKFLOW }} + run: | + ./gradlew build -x project-api-tests:test -Pversion=${VERSION} + ./gradlew release -Prelease.useAutomaticVersion=true -x test + - name: Checkout docker repo + uses: actions/checkout@v3 + with: + repository: ballerina-platform/module-ballerina-docker + path: module-ballerina-docker + - name: Copy zip artifact + run: cp ballerina/build/distributions/ballerina-22*.zip module-ballerina-docker/base/docker/ + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Build the docker image + id: docker_build + uses: docker/build-push-action@v2 + with: + context: module-ballerina-docker/base/docker/ + load: true + push: false + tags: ballerina/ballerina:release-test + build-args: | + BALLERINA_DIST=ballerina-${{ steps.version-set.outputs.sversion }}.zip + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'ballerina/ballerina:release-test' + skip-dirs: 'ballerina/runtime/examples' + format: 'table' + exit-code: '1' + timeout: "10m0s" + - name: cosign-installer + uses: sigstore/cosign-installer@v3.5.0 + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Install GitHub CLI + run: | + npm install -g github-cli + gh --version + - name: Get Markdown file + id: file-url + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh repo view ballerina-platform/ballerina-dev-website --json url --jq '.clone_url' + gh api repos/ballerina-platform/ballerina-dev-website/contents/downloads/verify-ballerina-artifacts.md -H 'Accept: application/vnd.github.v3.raw' > release_notes.md + sed -i '1,10d' release_notes.md + - name: Retrieve Branch + id: retrieve-branch + run: | + branchName=$(echo ${{ github.ref }} | cut -d'/' -f3) + echo "::set-output name=branchName::$branchName" + - name: Update Markdown file + run: | + if ${{ github.event.inputs.isPreRelease }} == 'true'; then + echo "" > release_notes.md; + else sed -i 's/{{ version }}/${{ steps.version-set.outputs.taggedVersion }}/g' release_notes.md; sed -i 's/{{ branch }}/${{ steps.retrieve-branch.outputs.branchName }}/g' release_notes.md; fi + - name: Read release notes from file + id: release_notes + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.BALLERINA_BOT_TOKEN }} + script: | + const fs = require('fs'); + const releaseNotes = fs.readFileSync('release_notes.md', 'utf8'); + core.setOutput('notes', releaseNotes); + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + tag_name: "v${{ steps.version-set.outputs.taggedVersion }}" + release_name: ${{ steps.version-set.outputs.taggedVersion }} + body: ${{ steps.release_notes.outputs.notes }} + draft: false + prerelease: ${{ github.event.inputs.isPreRelease }} + - name: Create linux-deb Installer + run: | + cd installers/linux-deb + ./build-ballerina-linux-deb-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions + echo "Created linux-deb successfully" + - name: Sign the linux-deb installer + run: | + cosign sign-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig --yes + - name: Verify the linux-deb installer + run: | + cosign verify-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Create linux-rpm Installer + id: run_installers_rpm + run: | + cd installers/linux-rpm + ./build-ballerina-linux-rpm-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions + echo "Created linux-rpm successfully" + - name: Sign the linux-rpm installer + run: | + cosign sign-blob installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig --yes + - name: Verify the linux-rpm installer + run: | + cosign verify-blob installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Generate Hashes + run: | + openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sha256 installers/linux-deb/target/ballerina-*-linux-x64.deb + openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sha256 installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-*-linux-x64.rpm + openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.longVersion }}.zip.sha256 ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip + openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.sversion }}.zip.sha256 ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip + - name: Sign the zip artifacts + run: | + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip --output-certificate ballerina-${{ steps.version-set.outputs.sversion }}.pem --output-signature ballerina-${{ steps.version-set.outputs.sversion }}.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig --yes + cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig --yes + - name: Verify the zip artifacts + run: | + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip --certificate ballerina-${{ steps.version-set.outputs.sversion }}.pem --signature ballerina-${{ steps.version-set.outputs.sversion }}.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Upload zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip + asset_content_type: application/octet-stream + - name: Upload zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}.pem + asset_content_type: application/octet-stream + - name: Upload zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}.sig + asset_content_type: application/octet-stream + - name: Upload zip without tool artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip + asset_content_type: application/octet-stream + - name: Upload zip without tool artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.sversion }}.pem + asset_content_type: application/octet-stream + - name: Upload zip without tool artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.sversion }}.sig + asset_content_type: application/octet-stream + - name: Upload Linux deb Installer + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb + asset_path: installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb + asset_content_type: application/octet-stream + - name: Upload Linux deb Installer's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem + asset_content_type: application/octet-stream + - name: Upload Linux deb Installer's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig + asset_content_type: application/octet-stream + - name: Upload Linux rpm Installer + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm + asset_path: installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm + asset_content_type: application/octet-stream + - name: Upload Linux rpm Installer's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem + asset_content_type: application/octet-stream + - name: Upload Linux rpm Installer's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig + asset_content_type: application/octet-stream + - name: Upload Linux zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip + asset_content_type: application/octet-stream + - name: Upload Linux zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem + asset_content_type: application/octet-stream + - name: Upload Linux zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig + asset_content_type: application/octet-stream + - name: Upload Linux-ARM zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip + asset_content_type: application/octet-stream + - name: Upload Linux-ARM zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem + asset_content_type: application/octet-stream + - name: Upload Linux-ARM zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig + asset_content_type: application/octet-stream + - name: Upload MacOS zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip + asset_content_type: application/octet-stream + - name: Upload MacOS zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem + asset_content_type: application/octet-stream + - name: Upload MacOS zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig + asset_content_type: application/octet-stream + - name: Upload MacOS-ARM zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip + asset_content_type: application/octet-stream + - name: Upload MacOS-ARM zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem + asset_content_type: application/octet-stream + - name: Upload MacOS-ARM zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig + asset_content_type: application/octet-stream + - name: Upload Windows zip artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip + asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip + asset_content_type: application/octet-stream + - name: Upload Windows zip artifact's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem + asset_content_type: application/octet-stream + - name: Upload Windows zip artifact's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig + asset_content_type: application/octet-stream + - name: Upload Linux deb Hashes + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sha256 + asset_path: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sha256 + asset_content_type: application/octet-stream + - name: Upload Linux rpm Hashes + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sha256 + asset_path: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sha256 + asset_content_type: application/octet-stream + - name: Upload Ballerina zip Hashes + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}.zip.sha256 + asset_path: ballerina-${{ steps.version-set.outputs.longVersion }}.zip.sha256 + asset_content_type: application/octet-stream + - name: Upload ballerina Short Name zip Hashes + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.zip.sha256 + asset_path: ballerina-${{ steps.version-set.outputs.sversion }}.zip.sha256 + asset_content_type: application/octet-stream + - name: Install Ballerina DEB + run: sudo dpkg -i installers/linux-deb/target/ballerina-*-linux-x64.deb + - name: Update Installer Test Configs + run: | + DISPLAY_TEXT=${{ steps.version-set.outputs.langVersion }} + SWAN_LAKE_LATEST_VERSION="swan-lake-"+$DISPLAY_TEXT + perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=$DISPLAY_TEXT/" ballerina-test-automation/gradle.properties + perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=$SWAN_LAKE_LATEST_VERSION/" ballerina-test-automation/gradle.properties + - name: Run Installer Tests + working-directory: ./ballerina-test-automation/installer-test + run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true + env: + TEST_MODE_ACTIVE: true + - name: Create linux-arm-deb Installer + run: | + cd installers/linux-deb + ./build-ballerina-linux-deb-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions -a arm + echo "Created linux-arm-deb successfully" + - name: Sign the linux-arm-deb installer + run: | + cosign sign-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig --yes + - name: Verify the linux-arm-deb installer + run: | + cosign verify-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Upload Linux-ARM deb Installer + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb + asset_path: installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb + asset_content_type: application/octet-stream + - name: Upload Linux-ARM deb Installer's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem + asset_content_type: application/octet-stream + - name: Upload Linux-ARM deb Installer's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig + asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig + asset_content_type: application/octet-stream + + outputs: + project-version: ${{ steps.version-set.outputs.longVersion }} + upload-asset-url: ${{ steps.create_release.outputs.upload_url }} + release-version: ${{ steps.version-set.outputs.taggedVersion }} + lang-version: ${{ steps.version-set.outputs.langVersion }} + + macos-installer-build: + name: MacOS Installer Build + needs: publish-release + runs-on: macos-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17.0.7' + - name: Download MacOS Intaller Zip + run: | + wget https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{ needs.publish-release.outputs.release-version }}/ballerina-${{ needs.publish-release.outputs.project-version }}-macos.zip + - name: cosign-installer + uses: sigstore/cosign-installer@v3.5.0 + - name: Create macos-pkg Installer + id: run_installers_pkg + run: | + cd installers/mac + ./build-ballerina-macos-x64.sh -v ${{ needs.publish-release.outputs.project-version }} -p ./../../ + echo "Created macos-pkg successfully" + - name: Sign the MacOS installer + run: | + cosign sign-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg --output-certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem --output-signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig --yes + - name: Verify the MacOS installer + run: | + cosign verify-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg --certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem --signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Generate Hashes + run: | + openssl dgst -sha256 -out ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sha256 installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg + - name: Upload MacOS pkg Hashes + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sha256 + asset_path: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sha256 + asset_content_type: application/octet-stream + - name: Upload MacOS pkg Installer + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg + asset_path: installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg + asset_content_type: application/octet-stream + - name: Upload MacOS installer's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem + asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem + asset_content_type: application/octet-stream + - name: Upload MacOS installer's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig + asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig + asset_content_type: application/octet-stream + - name: Install Ballerina PKG + run: sudo installer -pkg installers/mac/target/pkg/ballerina-*-macos-x64.pkg -target / + - name: Update Installer Test Configs + run: | + DISPLAY_TEXT=${{ needs.publish-release.outputs.lang-version }} + SWAN_LAKE_LATEST_VERSION="swan-lake-"+$DISPLAY_TEXT + perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=$DISPLAY_TEXT/" ballerina-test-automation/gradle.properties + perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=$SWAN_LAKE_LATEST_VERSION/" ballerina-test-automation/gradle.properties + - name: Run Installer Tests + working-directory: ./ballerina-test-automation/installer-test + run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true + env: + TEST_MODE_ACTIVE: true + - name: Download MacOS-ARM Installer Zip + run: | + wget https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{ needs.publish-release.outputs.release-version }}/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm.zip + - name: Create macos-arm-pkg Installer + id: run_installers_arm_pkg + run: | + cd installers/mac + ./build-ballerina-macos-x64.sh -v ${{ needs.publish-release.outputs.project-version }} -p ./../../ -a arm + echo "Created macos-arm-pkg successfully" + - name: Sign the MacOS-ARM installer + run: | + cosign sign-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg --output-certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem --output-signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig --yes + - name: Verify the MacOS-ARM installer + run: | + cosign verify-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg --certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem --signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Generate Hashes + run: | + openssl dgst -sha256 -out ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sha256 installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg + - name: Upload MacOS-ARM pkg Hashes + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sha256 + asset_path: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sha256 + asset_content_type: application/octet-stream + - name: Upload MacOS-ARM pkg Installer + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg + asset_path: installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg + asset_content_type: application/octet-stream + - name: Upload MacOS-ARM installer's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem + asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem + asset_content_type: application/octet-stream + - name: Upload MacOS-ARM installer's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig + asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig + asset_content_type: application/octet-stream + + windows-installer-build: + name: Windows Installer Build + needs: publish-release + runs-on: windows-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17.0.7' + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: '2.1.x' + - name: Install GUID Generator + run: dotnet tool install -g dotnet-guid --version 0.5.2 + - name: Set up Wix toolkit + run: echo "${WIX}bin" >> $GITHUB_PATH + shell: bash + - name: Set cosign-installer + uses: sigstore/cosign-installer@v3.5.0 + - name: Download Windows Installer Zip + run: | + echo default login ${{ secrets.BALLERINA_BOT_USERNAME }} password ${{ secrets.BALLERINA_BOT_TOKEN }} >> _netrc + curl --netrc-file _netrc -L -o ballerina-${{ needs.publish-release.outputs.project-version }}-windows.zip https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{ needs.publish-release.outputs.release-version }}/ballerina-${{ needs.publish-release.outputs.project-version }}-windows.zip + - name: Create windows-msi Installer + id: run_installers_msi + run: | + move installers\windows .\ + ren windows w + cd w + .\build-ballerina-windows-x64.bat --version ${{ needs.publish-release.outputs.project-version }} --path .\..\ + - name: Sign the Windows installer + run: | + cosign sign-blob w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi --output-certificate ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem --output-signature ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig --yes + - name: Verify the Windows installer + run: | + cosign verify-blob w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi --certificate ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem --signature ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com + - name: Generate Hashes + run: | + openssl dgst -sha256 -out ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sha256 w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi + - name: Upload Windows msi Hashes + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sha256 + asset_path: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sha256 + asset_content_type: application/octet-stream + - name: Upload Windows msi Installer + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi + asset_path: w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi + asset_content_type: application/octet-stream + - name: Upload Windows installer's Certificate + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem + asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem + asset_content_type: application/octet-stream + - name: Upload Windows installer's Signature + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} + with: + upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} + asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig + asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig + asset_content_type: application/octet-stream + - name: Install Ballerina msi + run: msiexec /i w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi /quiet /qr + shell: cmd + - name: Update Installer Test Configs + run: | + set DISPLAY_TEXT=${{ needs.publish-release.outputs.lang-version }} + set SWAN_LAKE_LATEST_VERSION=swan-lake-%DISPLAY_TEXT% + perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=%DISPLAY_TEXT%/" ballerina-test-automation/gradle.properties + perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=%SWAN_LAKE_LATEST_VERSION%/" ballerina-test-automation/gradle.properties + shell: cmd + - name: Run Installer Tests + working-directory: .\ballerina-test-automation\installer-test + run: | + $env:Path += ";C:\Program Files\Ballerina\bin" + .\..\gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true From 16a90caad40009ef5a87f0aef8990362b4b2a73c Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 29 Oct 2024 14:29:20 +0530 Subject: [PATCH 49/80] Add release workflow for BI distribution --- .github/workflows/publish_release_bi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index 00eb4ff82d..9b3315572c 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -95,7 +95,7 @@ jobs: githubAccessToken: ${{ secrets.GITHUB_TOKEN }} ballerinaBotWorkflow: $ {{ secrets.BALLERINA_BOT_WORKFLOW }} run: | - ./gradlew build -x project-api-tests:test -Pversion=${VERSION} + ./gradlew build -x test -x project-api-tests:test -Pversion=${VERSION} ./gradlew release -Prelease.useAutomaticVersion=true -x test - name: Checkout docker repo uses: actions/checkout@v3 From 6cf22b06932b591432ed055ccb6a630b681734dd Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 29 Oct 2024 14:47:41 +0530 Subject: [PATCH 50/80] Set NodeJS version --- .github/workflows/publish_release_bi.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index 9b3315572c..0026cb7b1c 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -28,6 +28,10 @@ jobs: with: distribution: 'temurin' java-version: '17.0.7' + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '10.22.1' - name: Clone ballerina-dev-tools run: git clone -b flow_model https://github.com/ballerina-platform/ballerina-dev-tools.git - name: Build ballerina-dev-tools From bf40c2238a4648ee6a3fa42a31cfc5d73dbb8f2a Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 29 Oct 2024 15:03:36 +0530 Subject: [PATCH 51/80] Remove directory after build --- .github/workflows/publish_release_bi.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index 0026cb7b1c..e5b2156780 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -48,6 +48,8 @@ jobs: echo "::set-output name=version::$(grep "^version=" gradle.properties | cut -d'=' -f2)" echo "::set-output name=langVersion::$(grep "^ballerinaLangVersion=" gradle.properties | cut -d'=' -f2)" ./gradlew clean build --stacktrace --scan -x test --console=plain --no-daemon --continue publishToMavenLocal + cd .. + rm -rf ballerina-dev-tools - name: Set version env variable id: version-set run: | From 089df3a73b2e7a45d0643988affd7d907a71c2db Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 29 Oct 2024 15:20:01 +0530 Subject: [PATCH 52/80] Remove snapshot from version --- .github/workflows/publish_release_bi.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index e5b2156780..001bbf6314 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -45,6 +45,8 @@ jobs: TEST_MODE_ACTIVE: true run: | cd ballerina-dev-tools + VERSION=$((grep -w 'version' | cut -d= -f2 | cut -d- -f1) < gradle.properties) + sed -i "s/^version=.*/version=$VERSION/" gradle.properties echo "::set-output name=version::$(grep "^version=" gradle.properties | cut -d'=' -f2)" echo "::set-output name=langVersion::$(grep "^ballerinaLangVersion=" gradle.properties | cut -d'=' -f2)" ./gradlew clean build --stacktrace --scan -x test --console=plain --no-daemon --continue publishToMavenLocal From 45aaeb709e19c5d34f2d0c355957cd8900735878 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Tue, 29 Oct 2024 15:32:21 +0530 Subject: [PATCH 53/80] Apply suggestions from code review Co-authored-by: Maryam Ziyad --- examples/raw-templates/raw_templates.bal | 6 ++++-- examples/raw-templates/raw_templates.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/raw-templates/raw_templates.bal b/examples/raw-templates/raw_templates.bal index e25bdaafa6..548971fa99 100644 --- a/examples/raw-templates/raw_templates.bal +++ b/examples/raw-templates/raw_templates.bal @@ -14,12 +14,14 @@ public function main() { int col1 = 5; int col2 = 10; - // Allow any value as interpolations since object:RawTemplate has any|error[] as insertions type. + // Any value is allowed as an interpolations with a value of the `object:RawTemplate` type + // since it has `(any|error)[]` as the `insertions` type. object:RawTemplate rawTemplate = `${col1}, fixed_string1, ${col2}, ${col3()}, fixed_string3`; io:println(rawTemplate.strings); io:println(rawTemplate.insertions); - // Ensure we have 2 ints followed by a boolean value as interpolations based on insertions type. + // With the custom `MyCSVRawTemplate ` raw template type, the compiler + // expects two integers followed by a boolean value as interpolations. MyCSVRawTemplate myCSVRawTemplate = `fixed_string4, ${col1}, ${col2}, fixed_string_5, ${col3()}`; io:println(myCSVRawTemplate.strings); io:println(myCSVRawTemplate.insertions); diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index caf45fabb7..18f6f15196 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -2,7 +2,7 @@ Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form `${expression}`). The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. -If you want to control the type of values used for interpolation more precisely, you can define an object type that includes the `RawTemplate` type and give a narrower type for the `insertions` fields. Then, the compiler will statically verify that the corresponding values used for interpolation belong to the desired type. +If you want to control the type of values used for interpolation more precisely, you can define an object type that includes the `object:RawTemplate` type and give a narrower type for the `insertions` fields. Then, the compiler will statically verify that the corresponding values used for interpolation belong to the desired type. ::: code raw_templates.bal ::: From 374bef71fcff86850a4a098a1ef505f588cf703f Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 29 Oct 2024 15:46:44 +0530 Subject: [PATCH 54/80] Remove sigining artifacts --- .github/workflows/publish_release_bi.yml | 370 +++-------------------- 1 file changed, 41 insertions(+), 329 deletions(-) diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index 001bbf6314..65f74f85bb 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -192,48 +192,18 @@ jobs: cd installers/linux-deb ./build-ballerina-linux-deb-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions echo "Created linux-deb successfully" - - name: Sign the linux-deb installer - run: | - cosign sign-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig --yes - - name: Verify the linux-deb installer - run: | - cosign verify-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - name: Create linux-rpm Installer id: run_installers_rpm run: | cd installers/linux-rpm ./build-ballerina-linux-rpm-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions echo "Created linux-rpm successfully" - - name: Sign the linux-rpm installer - run: | - cosign sign-blob installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig --yes - - name: Verify the linux-rpm installer - run: | - cosign verify-blob installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - name: Generate Hashes run: | openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sha256 installers/linux-deb/target/ballerina-*-linux-x64.deb openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sha256 installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-*-linux-x64.rpm openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.longVersion }}.zip.sha256 ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip openssl dgst -sha256 -out ballerina-${{ steps.version-set.outputs.sversion }}.zip.sha256 ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip - - name: Sign the zip artifacts - run: | - cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}.sig --yes - cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip --output-certificate ballerina-${{ steps.version-set.outputs.sversion }}.pem --output-signature ballerina-${{ steps.version-set.outputs.sversion }}.sig --yes - cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig --yes - cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig --yes - cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig --yes - cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig --yes - cosign sign-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig --yes - - name: Verify the zip artifacts - run: | - cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip --certificate ballerina-${{ steps.version-set.outputs.sversion }}.pem --signature ballerina-${{ steps.version-set.outputs.sversion }}.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - cosign verify-blob ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - name: Upload zip artifacts uses: actions/upload-release-asset@v1 env: @@ -243,24 +213,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}.zip asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}.zip asset_content_type: application/octet-stream - - name: Upload zip artifact's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}.pem - asset_content_type: application/octet-stream - - name: Upload zip artifact's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}.sig - asset_content_type: application/octet-stream - name: Upload zip without tool artifacts uses: actions/upload-release-asset@v1 env: @@ -270,24 +222,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.zip asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.sversion }}.zip asset_content_type: application/octet-stream - - name: Upload zip without tool artifact's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.sversion }}.pem - asset_content_type: application/octet-stream - - name: Upload zip without tool artifact's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.sversion }}.sig - asset_content_type: application/octet-stream - name: Upload Linux deb Installer uses: actions/upload-release-asset@v1 env: @@ -297,24 +231,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb asset_path: installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb asset_content_type: application/octet-stream - - name: Upload Linux deb Installer's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.pem - asset_content_type: application/octet-stream - - name: Upload Linux deb Installer's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.deb.sig - asset_content_type: application/octet-stream - name: Upload Linux rpm Installer uses: actions/upload-release-asset@v1 env: @@ -324,24 +240,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm asset_path: installers/linux-rpm/rpmbuild/RPMS/x86_64/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm asset_content_type: application/octet-stream - - name: Upload Linux rpm Installer's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.pem - asset_content_type: application/octet-stream - - name: Upload Linux rpm Installer's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-x64.rpm.sig - asset_content_type: application/octet-stream - name: Upload Linux zip artifacts uses: actions/upload-release-asset@v1 env: @@ -351,24 +249,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux.zip asset_content_type: application/octet-stream - - name: Upload Linux zip artifact's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux.pem - asset_content_type: application/octet-stream - - name: Upload Linux zip artifact's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux.sig - asset_content_type: application/octet-stream - name: Upload Linux-ARM zip artifacts uses: actions/upload-release-asset@v1 env: @@ -378,24 +258,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.zip asset_content_type: application/octet-stream - - name: Upload Linux-ARM zip artifact's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.pem - asset_content_type: application/octet-stream - - name: Upload Linux-ARM zip artifact's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm.sig - asset_content_type: application/octet-stream - name: Upload MacOS zip artifacts uses: actions/upload-release-asset@v1 env: @@ -405,24 +267,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos.zip asset_content_type: application/octet-stream - - name: Upload MacOS zip artifact's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos.pem - asset_content_type: application/octet-stream - - name: Upload MacOS zip artifact's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos.sig - asset_content_type: application/octet-stream - name: Upload MacOS-ARM zip artifacts uses: actions/upload-release-asset@v1 env: @@ -432,24 +276,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.zip asset_content_type: application/octet-stream - - name: Upload MacOS-ARM zip artifact's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.pem - asset_content_type: application/octet-stream - - name: Upload MacOS-ARM zip artifact's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-macos-arm.sig - asset_content_type: application/octet-stream - name: Upload Windows zip artifacts uses: actions/upload-release-asset@v1 env: @@ -459,24 +285,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip asset_path: ballerina/build/distributions/ballerina-${{ steps.version-set.outputs.longVersion }}-windows.zip asset_content_type: application/octet-stream - - name: Upload Windows zip artifact's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-windows.pem - asset_content_type: application/octet-stream - - name: Upload Windows zip artifact's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-windows.sig - asset_content_type: application/octet-stream - name: Upload Linux deb Hashes uses: actions/upload-release-asset@v1 env: @@ -513,30 +321,24 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.sversion }}.zip.sha256 asset_path: ballerina-${{ steps.version-set.outputs.sversion }}.zip.sha256 asset_content_type: application/octet-stream - - name: Install Ballerina DEB - run: sudo dpkg -i installers/linux-deb/target/ballerina-*-linux-x64.deb - - name: Update Installer Test Configs - run: | - DISPLAY_TEXT=${{ steps.version-set.outputs.langVersion }} - SWAN_LAKE_LATEST_VERSION="swan-lake-"+$DISPLAY_TEXT - perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=$DISPLAY_TEXT/" ballerina-test-automation/gradle.properties - perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=$SWAN_LAKE_LATEST_VERSION/" ballerina-test-automation/gradle.properties - - name: Run Installer Tests - working-directory: ./ballerina-test-automation/installer-test - run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true - env: - TEST_MODE_ACTIVE: true +# - name: Install Ballerina DEB +# run: sudo dpkg -i installers/linux-deb/target/ballerina-*-linux-x64.deb +# - name: Update Installer Test Configs +# run: | +# DISPLAY_TEXT=${{ steps.version-set.outputs.langVersion }} +# SWAN_LAKE_LATEST_VERSION="swan-lake-"+$DISPLAY_TEXT +# perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=$DISPLAY_TEXT/" ballerina-test-automation/gradle.properties +# perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=$SWAN_LAKE_LATEST_VERSION/" ballerina-test-automation/gradle.properties +# - name: Run Installer Tests +# working-directory: ./ballerina-test-automation/installer-test +# run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true +# env: +# TEST_MODE_ACTIVE: true - name: Create linux-arm-deb Installer run: | cd installers/linux-deb ./build-ballerina-linux-deb-x64.sh -v ${{ steps.version-set.outputs.longVersion }} -p ./../../ballerina/build/distributions -a arm echo "Created linux-arm-deb successfully" - - name: Sign the linux-arm-deb installer - run: | - cosign sign-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb --output-certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem --output-signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig --yes - - name: Verify the linux-arm-deb installer - run: | - cosign verify-blob installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb --certificate ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem --signature ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - name: Upload Linux-ARM deb Installer uses: actions/upload-release-asset@v1 env: @@ -546,24 +348,6 @@ jobs: asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb asset_path: installers/linux-deb/target/ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb asset_content_type: application/octet-stream - - name: Upload Linux-ARM deb Installer's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.pem - asset_content_type: application/octet-stream - - name: Upload Linux-ARM deb Installer's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_name: ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig - asset_path: ./ballerina-${{ steps.version-set.outputs.longVersion }}-linux-arm-x64.deb.sig - asset_content_type: application/octet-stream outputs: project-version: ${{ steps.version-set.outputs.longVersion }} @@ -595,12 +379,6 @@ jobs: cd installers/mac ./build-ballerina-macos-x64.sh -v ${{ needs.publish-release.outputs.project-version }} -p ./../../ echo "Created macos-pkg successfully" - - name: Sign the MacOS installer - run: | - cosign sign-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg --output-certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem --output-signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig --yes - - name: Verify the MacOS installer - run: | - cosign verify-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg --certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem --signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - name: Generate Hashes run: | openssl dgst -sha256 -out ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sha256 installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg @@ -622,37 +400,19 @@ jobs: asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg asset_path: installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg asset_content_type: application/octet-stream - - name: Upload MacOS installer's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} - asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem - asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.pem - asset_content_type: application/octet-stream - - name: Upload MacOS installer's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} - asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig - asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-x64.pkg.sig - asset_content_type: application/octet-stream - - name: Install Ballerina PKG - run: sudo installer -pkg installers/mac/target/pkg/ballerina-*-macos-x64.pkg -target / - - name: Update Installer Test Configs - run: | - DISPLAY_TEXT=${{ needs.publish-release.outputs.lang-version }} - SWAN_LAKE_LATEST_VERSION="swan-lake-"+$DISPLAY_TEXT - perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=$DISPLAY_TEXT/" ballerina-test-automation/gradle.properties - perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=$SWAN_LAKE_LATEST_VERSION/" ballerina-test-automation/gradle.properties - - name: Run Installer Tests - working-directory: ./ballerina-test-automation/installer-test - run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true - env: - TEST_MODE_ACTIVE: true +# - name: Install Ballerina PKG +# run: sudo installer -pkg installers/mac/target/pkg/ballerina-*-macos-x64.pkg -target / +# - name: Update Installer Test Configs +# run: | +# DISPLAY_TEXT=${{ needs.publish-release.outputs.lang-version }} +# SWAN_LAKE_LATEST_VERSION="swan-lake-"+$DISPLAY_TEXT +# perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=$DISPLAY_TEXT/" ballerina-test-automation/gradle.properties +# perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=$SWAN_LAKE_LATEST_VERSION/" ballerina-test-automation/gradle.properties +# - name: Run Installer Tests +# working-directory: ./ballerina-test-automation/installer-test +# run: ./../gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true +# env: +# TEST_MODE_ACTIVE: true - name: Download MacOS-ARM Installer Zip run: | wget https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{ needs.publish-release.outputs.release-version }}/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm.zip @@ -662,12 +422,6 @@ jobs: cd installers/mac ./build-ballerina-macos-x64.sh -v ${{ needs.publish-release.outputs.project-version }} -p ./../../ -a arm echo "Created macos-arm-pkg successfully" - - name: Sign the MacOS-ARM installer - run: | - cosign sign-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg --output-certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem --output-signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig --yes - - name: Verify the MacOS-ARM installer - run: | - cosign verify-blob installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg --certificate ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem --signature ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - name: Generate Hashes run: | openssl dgst -sha256 -out ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sha256 installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg @@ -689,24 +443,6 @@ jobs: asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg asset_path: installers/mac/target/pkg/ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg asset_content_type: application/octet-stream - - name: Upload MacOS-ARM installer's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} - asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem - asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.pem - asset_content_type: application/octet-stream - - name: Upload MacOS-ARM installer's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} - asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig - asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-macos-arm-x64.pkg.sig - asset_content_type: application/octet-stream windows-installer-build: name: Windows Installer Build @@ -742,12 +478,6 @@ jobs: ren windows w cd w .\build-ballerina-windows-x64.bat --version ${{ needs.publish-release.outputs.project-version }} --path .\..\ - - name: Sign the Windows installer - run: | - cosign sign-blob w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi --output-certificate ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem --output-signature ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig --yes - - name: Verify the Windows installer - run: | - cosign verify-blob w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi --certificate ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem --signature ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig --certificate-identity=https://github.com/ballerina-platform/ballerina-distribution/.github/workflows/publish-release.yml@${{ github.ref }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com - name: Generate Hashes run: | openssl dgst -sha256 -out ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sha256 w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi @@ -769,36 +499,18 @@ jobs: asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi asset_path: w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi asset_content_type: application/octet-stream - - name: Upload Windows installer's Certificate - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} - asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem - asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.pem - asset_content_type: application/octet-stream - - name: Upload Windows installer's Signature - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} - with: - upload_url: ${{ needs.publish-release.outputs.upload-asset-url }} - asset_name: ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig - asset_path: ./ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi.sig - asset_content_type: application/octet-stream - - name: Install Ballerina msi - run: msiexec /i w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi /quiet /qr - shell: cmd - - name: Update Installer Test Configs - run: | - set DISPLAY_TEXT=${{ needs.publish-release.outputs.lang-version }} - set SWAN_LAKE_LATEST_VERSION=swan-lake-%DISPLAY_TEXT% - perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=%DISPLAY_TEXT%/" ballerina-test-automation/gradle.properties - perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=%SWAN_LAKE_LATEST_VERSION%/" ballerina-test-automation/gradle.properties - shell: cmd - - name: Run Installer Tests - working-directory: .\ballerina-test-automation\installer-test - run: | - $env:Path += ";C:\Program Files\Ballerina\bin" - .\..\gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true +# - name: Install Ballerina msi +# run: msiexec /i w\target\msi\ballerina-${{ needs.publish-release.outputs.project-version }}-windows-x64.msi /quiet /qr +# shell: cmd +# - name: Update Installer Test Configs +# run: | +# set DISPLAY_TEXT=${{ needs.publish-release.outputs.lang-version }} +# set SWAN_LAKE_LATEST_VERSION=swan-lake-%DISPLAY_TEXT% +# perl -pi -e "s/^\s*swan-lake-latest-version-display-text=.*/swan-lake-latest-version-display-text=%DISPLAY_TEXT%/" ballerina-test-automation/gradle.properties +# perl -pi -e "s/^\s*swan-lake-latest-version=.*/swan-lake-latest-version=%SWAN_LAKE_LATEST_VERSION%/" ballerina-test-automation/gradle.properties +# shell: cmd +# - name: Run Installer Tests +# working-directory: .\ballerina-test-automation\installer-test +# run: | +# $env:Path += ";C:\Program Files\Ballerina\bin" +# .\..\gradlew build --stacktrace -scan --console=plain --no-daemon -DballerinaInstalled=true From 5ac3aeb3c7ef250e1b85911832fa1cbf5241b51b Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Tue, 29 Oct 2024 21:50:02 +0530 Subject: [PATCH 55/80] Apply suggestions from code review Co-authored-by: Maryam Ziyad --- examples/raw-templates/raw_templates.bal | 2 +- examples/raw-templates/raw_templates.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/raw-templates/raw_templates.bal b/examples/raw-templates/raw_templates.bal index 548971fa99..8da0e2decc 100644 --- a/examples/raw-templates/raw_templates.bal +++ b/examples/raw-templates/raw_templates.bal @@ -14,7 +14,7 @@ public function main() { int col1 = 5; int col2 = 10; - // Any value is allowed as an interpolations with a value of the `object:RawTemplate` type + // Any value is allowed as an interpolation when defining a value of the `object:RawTemplate` type // since it has `(any|error)[]` as the `insertions` type. object:RawTemplate rawTemplate = `${col1}, fixed_string1, ${col2}, ${col3()}, fixed_string3`; io:println(rawTemplate.strings); diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 18f6f15196..324337c5fc 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -1,8 +1,8 @@ # Raw templates -Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form `${expression}`). The result of evaluating such a raw template is a `RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. +Raw template expressions are backtick templates without a tag (such as `string` or `xml`). This is a sequence of characters interleaved with interpolations within a pair of backticks (in the form `${expression}`). The result of evaluating such a raw template is an `object:RawTemplate` object that has two fields `(readonly & string[]) strings` and `(any|error)[] insertions`. The `strings` array will have string literals in the backtick string broken at interpolations and the `insertions` array will have the resultant values of evaluating each interpolation. -If you want to control the type of values used for interpolation more precisely, you can define an object type that includes the `object:RawTemplate` type and give a narrower type for the `insertions` fields. Then, the compiler will statically verify that the corresponding values used for interpolation belong to the desired type. +If you want to control the type of the strings or the interpolations more precisely, you can define an object type that includes the `object:RawTemplate` type and override the relevant field(s) with narrower types. Then, the compiler will statically validate the values against the expected type(s). ::: code raw_templates.bal ::: From 7bea09297d481b03c34a71e395f5c2ecf946492c Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Tue, 29 Oct 2024 21:55:13 +0530 Subject: [PATCH 56/80] Describe common use case for raw templates --- examples/raw-templates/raw_templates.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 324337c5fc..875c5deddd 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -4,6 +4,8 @@ Raw template expressions are backtick templates without a tag (such as `string` If you want to control the type of the strings or the interpolations more precisely, you can define an object type that includes the `object:RawTemplate` type and override the relevant field(s) with narrower types. Then, the compiler will statically validate the values against the expected type(s). +A common use case for raw templates is to create SQL queries. + ::: code raw_templates.bal ::: ::: out raw_templates.out ::: @@ -11,3 +13,4 @@ If you want to control the type of the strings or the interpolations more precis ## Related links - [Backtick templates](https://ballerina.io/learn/by-example/backtick-templates/) - [Object type inclusion](https://ballerina.io/learn/by-example/object-type-inclusion/) +- [Database Access - Simple query](https://ballerina.io/learn/by-example/mysql-query-operation/) From 26e37b0ef83f44d53325d9a1c935cdf2bbbd55ea Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Wed, 30 Oct 2024 09:16:30 +0530 Subject: [PATCH 57/80] Apply suggestions from code review Co-authored-by: Maryam Ziyad --- examples/raw-templates/raw_templates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 875c5deddd..f40101316f 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -4,7 +4,7 @@ Raw template expressions are backtick templates without a tag (such as `string` If you want to control the type of the strings or the interpolations more precisely, you can define an object type that includes the `object:RawTemplate` type and override the relevant field(s) with narrower types. Then, the compiler will statically validate the values against the expected type(s). -A common use case for raw templates is to create SQL queries. +An important use case of custom raw templates is SQL parameterized queries. ::: code raw_templates.bal ::: From dd1c30fe3fd243e2085451b7c6a52cec1eec8afb Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Wed, 30 Oct 2024 10:09:41 +0530 Subject: [PATCH 58/80] Upddate Kola release workflow to run on schedule --- .github/workflows/publish_release_bi.yml | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index 65f74f85bb..4302f9e1bc 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -2,15 +2,8 @@ name: Publish Release Kola Distribution on: workflow_dispatch: - inputs: - isPreRelease: - description: 'Tag created is a pre-release tag' - required: true - default: 'false' - preReleaseSuffix: - description: 'The text that will be suffixed to the Git tag. e.g., rc1' - required: false - default: '' + schedule: + - cron: '0 2 * * *' # 07:30 in LK time (GMT+5:30) permissions: id-token: write @@ -62,11 +55,8 @@ jobs: LANG_VERSION=$((grep -w "ballerinaLangVersion" | cut -d= -f2 | cut -d- -f1 | xargs) < gradle.properties) CODE_NAME=$((grep -w 'codeName' | cut -d= -f2) < gradle.properties) RELEASE_VERSION=$DIST_VERSION - TAGGED_VERSION=$RELEASE_VERSION + TAGGED_VERSION=$RELEASE_VERSION-$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00') LONG_VERSION=$DIST_VERSION-$CODE_NAME - if [ -n "${{ github.event.inputs.preReleaseSuffix }}" ]; then - TAGGED_VERSION=$RELEASE_VERSION-${{ github.event.inputs.preReleaseSuffix }} - fi echo VERSION=$RELEASE_VERSION >> $GITHUB_ENV echo GIT_TAG=$TAGGED_VERSION >> $GITHUB_ENV echo "::set-output name=version::$RELEASE_VERSION" @@ -163,10 +153,7 @@ jobs: branchName=$(echo ${{ github.ref }} | cut -d'/' -f3) echo "::set-output name=branchName::$branchName" - name: Update Markdown file - run: | - if ${{ github.event.inputs.isPreRelease }} == 'true'; then - echo "" > release_notes.md; - else sed -i 's/{{ version }}/${{ steps.version-set.outputs.taggedVersion }}/g' release_notes.md; sed -i 's/{{ branch }}/${{ steps.retrieve-branch.outputs.branchName }}/g' release_notes.md; fi + run: echo "" > release_notes.md; - name: Read release notes from file id: release_notes uses: actions/github-script@v4 @@ -186,7 +173,7 @@ jobs: release_name: ${{ steps.version-set.outputs.taggedVersion }} body: ${{ steps.release_notes.outputs.notes }} draft: false - prerelease: ${{ github.event.inputs.isPreRelease }} + prerelease: true - name: Create linux-deb Installer run: | cd installers/linux-deb From 221a4850d1ceee21e5470a1068ecfb2b8f864d36 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Wed, 30 Oct 2024 11:26:11 +0530 Subject: [PATCH 59/80] Upddate Kola release workflow to run on schedule --- .github/workflows/publish_release_bi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index 4302f9e1bc..f615619e17 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -55,7 +55,7 @@ jobs: LANG_VERSION=$((grep -w "ballerinaLangVersion" | cut -d= -f2 | cut -d- -f1 | xargs) < gradle.properties) CODE_NAME=$((grep -w 'codeName' | cut -d= -f2) < gradle.properties) RELEASE_VERSION=$DIST_VERSION - TAGGED_VERSION=$RELEASE_VERSION-$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00') + TAGGED_VERSION=$RELEASE_VERSION-bi-pack-$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00') LONG_VERSION=$DIST_VERSION-$CODE_NAME echo VERSION=$RELEASE_VERSION >> $GITHUB_ENV echo GIT_TAG=$TAGGED_VERSION >> $GITHUB_ENV From c267d44206496cf05772b0fbca8f4729259dcbdb Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Thu, 31 Oct 2024 10:58:26 +0530 Subject: [PATCH 60/80] Update regex bbe topics --- examples/regexp-match-operations/regexp_match_operations.md | 2 +- examples/regexp-replace-operations/regexp_replace_operations.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/regexp-match-operations/regexp_match_operations.md b/examples/regexp-match-operations/regexp_match_operations.md index 93bfe22249..71c104f8bd 100644 --- a/examples/regexp-match-operations/regexp_match_operations.md +++ b/examples/regexp-match-operations/regexp_match_operations.md @@ -1,4 +1,4 @@ -# RegExp operations +# RegExp match operations The `RegExp` type supports a set of langlib functions to match patterns in strings and enable operations such as finding, validating, grouping, and extracting data based on regular expressions. diff --git a/examples/regexp-replace-operations/regexp_replace_operations.md b/examples/regexp-replace-operations/regexp_replace_operations.md index c4dd8cf6eb..6d3dc580e6 100644 --- a/examples/regexp-replace-operations/regexp_replace_operations.md +++ b/examples/regexp-replace-operations/regexp_replace_operations.md @@ -1,4 +1,4 @@ -# RegExp operations +# RegExp replace operations The `RegExp` type supports a set of langlib functions to replace parts of strings that match specific patterns. From 39ed1f4805327866c629d595eefda36613026677 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Tue, 5 Nov 2024 14:35:11 +0530 Subject: [PATCH 61/80] Add the rest arguments BBE --- .../default_values_for_function_parameters.md | 1 + examples/functions/functions.md | 1 + examples/index.json | 7 ++ .../provide_function_arguments_by_name.md | 1 + examples/rest-arguments/rest_arguments.bal | 70 +++++++++++++++++++ examples/rest-arguments/rest_arguments.md | 15 ++++ .../rest-arguments/rest_arguments.metatags | 2 + examples/rest-arguments/rest_arguments.out | 7 ++ 8 files changed, 104 insertions(+) create mode 100644 examples/rest-arguments/rest_arguments.bal create mode 100644 examples/rest-arguments/rest_arguments.md create mode 100644 examples/rest-arguments/rest_arguments.metatags create mode 100644 examples/rest-arguments/rest_arguments.out diff --git a/examples/default-values-for-function-parameters/default_values_for_function_parameters.md b/examples/default-values-for-function-parameters/default_values_for_function_parameters.md index c86c909de6..87c5669983 100644 --- a/examples/default-values-for-function-parameters/default_values_for_function_parameters.md +++ b/examples/default-values-for-function-parameters/default_values_for_function_parameters.md @@ -9,3 +9,4 @@ Ballerina allows specifying default values for function parameters. You can use ## Related links - [Rest Parameters](/learn/by-example/rest-parameters/) - [Provide function arguments by name](/learn/by-example/provide-function-arguments-by-name/) +- [Rest arguments](/learn/by-example/rest-arguments/) diff --git a/examples/functions/functions.md b/examples/functions/functions.md index d067214c13..1fba2d9cf4 100644 --- a/examples/functions/functions.md +++ b/examples/functions/functions.md @@ -13,6 +13,7 @@ Function parameters are final variables and cannot be modified within the functi - [Rest Parameters](/learn/by-example/rest-parameters/) - [Default values for function parameters](/learn/by-example/default-values-for-function-parameters/) - [Provide function arguments by name](/learn/by-example/provide-function-arguments-by-name/) +- [Rest arguments](/learn/by-example/rest-arguments/) - [Function pointers](/learn/by-example/function-pointers/) - [Function values](/learn/by-example/function-values/) - [Function types](/learn/by-example/function-types/) diff --git a/examples/index.json b/examples/index.json index f0d6ec820f..6b1d24ccc1 100644 --- a/examples/index.json +++ b/examples/index.json @@ -224,6 +224,13 @@ "verifyOutput": true, "isLearnByExample": true }, + { + "name": "Rest arguments", + "url": "rest-arguments", + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true + }, { "name": "Function pointers", "url": "function-pointers", diff --git a/examples/provide-function-arguments-by-name/provide_function_arguments_by_name.md b/examples/provide-function-arguments-by-name/provide_function_arguments_by_name.md index e9fc9dd173..698c2b73be 100644 --- a/examples/provide-function-arguments-by-name/provide_function_arguments_by_name.md +++ b/examples/provide-function-arguments-by-name/provide_function_arguments_by_name.md @@ -9,3 +9,4 @@ Ballerina allows you to call functions with named arguments, which do not have t ## Related links - [Functions](/learn/by-example/functions/) - [Included record parameters](/learn/by-example/included-record-parameters/) +- [Rest arguments](/learn/by-example/rest-arguments/) diff --git a/examples/rest-arguments/rest_arguments.bal b/examples/rest-arguments/rest_arguments.bal new file mode 100644 index 0000000000..f6b1e13be8 --- /dev/null +++ b/examples/rest-arguments/rest_arguments.bal @@ -0,0 +1,70 @@ +import ballerina/http; +import ballerina/io; + +// A function to print the sum of two or more integers. +function sum(int first, int second, int... others) { + int sum = first + second; + foreach int othVal in others { + sum += othVal; + } + io:println(sum); +} + +// A record with some HTTP client configuration values. +type Configuration record {| + string url; + decimal timeout; + http:HttpVersion httpVersion; +|}; + +// A function that initializes an HTTP client using some configuration. +function initializeHttpClient(string url, decimal timeout, http:HttpVersion httpVersion) { + // Intialize the client just for demonstration. + http:Client|error cl = new (url, {timeout, httpVersion}); + if cl is error { + io:println("Failed to initialize an HTTP client", cl); + return; + } + io:println( + string `Initialized client with URL: ${url}, timeout: ${timeout}, HTTP version: ${httpVersion}`); +} + +public function main() { + // Call the `sum` function using an array of length 4 as a rest argument. + int[4] ints1 = [1, 2, 3, 4]; + sum(...ints1); + + // Since the `sum` function has two required parameters, when providing only a list rest + // argument, the length of the list should be guaranteed by the static type to be at + // least 2. + // Call the `sum` function using a tuple with at least two members. + [int, int, int...] ints2 = [5, 6]; + sum(...ints2); + + // A rest argument can be used along with positional arguments, + // providing only some of the arguments. + // Call the `sum` function with a rest argument after two positional arguments. + sum(5, 6, ...ints1); + + // Call the `sum` function with a rest argument after one positonal argument. + // Note how the rest argument provides arguments for both a required parameter + // and the rest parameter. Since only one positional argument is provided, the list + // type of the expression used in the rest argument should guarantee the presence of + // at least one member in the list to provide an argument for the second required parameter. + [int, int...] ints3 = [5, 6, 7]; + sum(4, ...ints3); + + // Call the `initializeHttpClient` function using a record value in the rest argument + // providing values for all the parameters. + Configuration config1 = {httpVersion: http:HTTP_2_0, url: "http://localhost:8080", timeout: 60}; + initializeHttpClient(...config1); + + // Call the `initializeHttpClient` function using a positional argument and a rest argument with + // a record value. The positional argument provides the argument for the first parameter (`url`) and the + // rest argument provides values for the other two parameters. + record {| + decimal timeout; + http:HttpVersion httpVersion; + |} config2 = {httpVersion: http:HTTP_1_1, timeout: 15}; + initializeHttpClient("http://localhost:8080", ...config2); +} diff --git a/examples/rest-arguments/rest_arguments.md b/examples/rest-arguments/rest_arguments.md new file mode 100644 index 0000000000..74740680dc --- /dev/null +++ b/examples/rest-arguments/rest_arguments.md @@ -0,0 +1,15 @@ +# Rest arguments + +Ballerina allows you to call functions with rest arguments, with an expression of a mapping or list type, spreading the members of the mapping or the list as individual arguments to the function. + +If the type of the expression used in the rest argument is a list type, the rest argument is equivalent to specifying each member of the list value as a positional argument. If it is a mapping type, the rest argument is equivalent to specifying each field of the mapping value as a named argument, where the name and the value of the named argument come from the name and the value of the field. In either case, the static type of the expression must ensure that the equivalent positional and/or named arguments would be valid and that arguments are provided for all the required parameters. + +::: code rest_arguments.bal ::: + +::: out rest_arguments.out ::: + +## Related links +- [Functions](/learn/by-example/functions/) +- [Provide function arguments by name](/learn/by-example/provide-function-arguments-by-name/) +- [Included record parameters](/learn/by-example/included-record-parameters/) +- [Aggregation](/learn/by-example/aggregation/) diff --git a/examples/rest-arguments/rest_arguments.metatags b/examples/rest-arguments/rest_arguments.metatags new file mode 100644 index 0000000000..cf8b8fcfab --- /dev/null +++ b/examples/rest-arguments/rest_arguments.metatags @@ -0,0 +1,2 @@ +description: This BBE demonstrates calling functions with rest arguments in Ballerina. +keywords: ballerina, ballerina by example, bbe, rest arguments, functions, function definition, parameters diff --git a/examples/rest-arguments/rest_arguments.out b/examples/rest-arguments/rest_arguments.out new file mode 100644 index 0000000000..53af2b56da --- /dev/null +++ b/examples/rest-arguments/rest_arguments.out @@ -0,0 +1,7 @@ +$ bal run rest_arguments.bal +10 +11 +21 +22 +Initialized client with URL: http://localhost:8080, timeout: 60, HTTP version: 2.0 +Initialized client with URL: http://localhost:8080, timeout: 15, HTTP version: 1.1 From a9e5bb4023e3c150214cd50bfcebecf4b56fee64 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 7 Nov 2024 12:42:21 +0530 Subject: [PATCH 62/80] Move backtick templates to string templates --- examples/index.json | 19 ++++++++----------- examples/raw-templates/raw_templates.md | 2 +- .../string_templates.bal} | 0 .../string_templates.md} | 0 .../string_templates.metatags} | 0 .../string_templates.out} | 0 6 files changed, 9 insertions(+), 12 deletions(-) rename examples/{backtick-templates/backtick_templates.bal => string-templates/string_templates.bal} (100%) rename examples/{backtick-templates/backtick_templates.md => string-templates/string_templates.md} (100%) rename examples/{backtick-templates/backtick_templates.metatags => string-templates/string_templates.metatags} (100%) rename examples/{backtick-templates/backtick_templates.out => string-templates/string_templates.out} (100%) diff --git a/examples/index.json b/examples/index.json index f0d6ec820f..7bc4c71b17 100644 --- a/examples/index.json +++ b/examples/index.json @@ -132,7 +132,6 @@ "column": 0, "category": "Language concepts", "samples": [ - { "name": "Binary operators", "url": "binary-operators", @@ -448,7 +447,7 @@ "title": "Equality", "column": 0, "category": "Language concepts", - "samples": [ + "samples": [ { "name": "Expression equality", "url": "expression-equality", @@ -1094,13 +1093,11 @@ "url": "raw-templates", "verifyBuild": false, "verifyOutput": false, - "disableVerificationReason": "Includes ballerinax components", - "disablePlayground": true, "isLearnByExample": true }, { - "name": "Backtick templates", - "url": "backtick-templates", + "name": "String templates", + "url": "string-templates", "verifyBuild": true, "verifyOutput": true, "isLearnByExample": true @@ -1398,11 +1395,11 @@ "isLearnByExample": true }, { - "name": "Trap expression", - "url": "trap-expression", - "verifyBuild": true, - "verifyOutput": true, - "isLearnByExample": true + "name": "Trap expression", + "url": "trap-expression", + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true }, { "name": "Type intersection for error types", diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index f40101316f..365a9c862b 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -11,6 +11,6 @@ An important use case of custom raw templates is SQL parameterized queries. ::: out raw_templates.out ::: ## Related links -- [Backtick templates](https://ballerina.io/learn/by-example/backtick-templates/) +- [String templates](https://ballerina.io/learn/by-example/string-templates/) - [Object type inclusion](https://ballerina.io/learn/by-example/object-type-inclusion/) - [Database Access - Simple query](https://ballerina.io/learn/by-example/mysql-query-operation/) diff --git a/examples/backtick-templates/backtick_templates.bal b/examples/string-templates/string_templates.bal similarity index 100% rename from examples/backtick-templates/backtick_templates.bal rename to examples/string-templates/string_templates.bal diff --git a/examples/backtick-templates/backtick_templates.md b/examples/string-templates/string_templates.md similarity index 100% rename from examples/backtick-templates/backtick_templates.md rename to examples/string-templates/string_templates.md diff --git a/examples/backtick-templates/backtick_templates.metatags b/examples/string-templates/string_templates.metatags similarity index 100% rename from examples/backtick-templates/backtick_templates.metatags rename to examples/string-templates/string_templates.metatags diff --git a/examples/backtick-templates/backtick_templates.out b/examples/string-templates/string_templates.out similarity index 100% rename from examples/backtick-templates/backtick_templates.out rename to examples/string-templates/string_templates.out From 5bf42cb12ef5efb85ee306f8e6a214c2af274a2f Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 7 Nov 2024 12:55:51 +0530 Subject: [PATCH 63/80] Fix string templates --- .../string-templates/string_templates.bal | 22 ++++++++++--------- examples/string-templates/string_templates.md | 13 ++--------- .../string_templates.metatags | 4 ++-- .../string-templates/string_templates.out | 10 +++++---- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/examples/string-templates/string_templates.bal b/examples/string-templates/string_templates.bal index 2ab87ce3bc..5cfa924724 100644 --- a/examples/string-templates/string_templates.bal +++ b/examples/string-templates/string_templates.bal @@ -1,19 +1,21 @@ import ballerina/io; public function main() { - string name = "James"; - - // Concatenates `Hello, ` strings with the `name` value. - string s1 = string `Hello, ${name}`; + // Note first \n is treated as is. + string s1 = string `line one \n rest of line 1 ${"\n"} second line`; io:println(s1); - // Concatenates `Backtick:` strings with `. - string s2 = string `Backtick:${"`"}`; + // You can use interpolations to add ` and $ characters. + string s2 = string `Backtick: ${"`"} Dollar: ${"$"}`; io:println(s2); - // If required, a single-line string template can be split into a multiline string template by breaking - // at an interpolation point or using string concatenation. - string s3 = string `A string-template-expr is evaluated by evaluating the expression in each interpolation in ${ - ""}the order in which they occur.`; + // You can nest template expressions. + string s3 = string `outer ${string `inner ${5} inner rest`} rest`; io:println(s3); + + // You can use an empty string interpolation to break a template expression + // across multiple lines + string s4 = string `prefix ${ + ""}suffix`; + io:println(s4); } diff --git a/examples/string-templates/string_templates.md b/examples/string-templates/string_templates.md index 511bdb502b..7b4dc327b4 100644 --- a/examples/string-templates/string_templates.md +++ b/examples/string-templates/string_templates.md @@ -1,12 +1,3 @@ -# Backtick templates +# String templates -The backtick templates consist of a tag followed by characters surrounded by backticks. They can contain `expressions` in `${...}` to be interpolated. If no escapes are recognized: use an `expression` to escape. - -They can contain newlines and are processed in two phases. - -1. Phase 1 does tag-independent parse: result is a list of `strings` and `expressions` -2. Phase 2 is tag-dependent: Phase 2 for `string...` converts `expressions` to `strings` and concatenates. `base16` and `base64` tags do not allow `expressions`. - -::: code backtick_templates.bal ::: - -::: out backtick_templates.out ::: \ No newline at end of file +A string template is a template expression that can be used to create a string literal. It consists of a `string` tag and a sequence of characters interleaved with interpolations (in the form `${expression}`). Each interpolation must be a subtype of `boolean|int|float|decimal|string`. Every character not a part of the interpolation is interpreted as is to form a sequence of string literals broken at interpolations. This means if you want to add any escape characters you must add them as interpolations (for example `${"\n"}`). Every interpolation is converted to a string using the `toString` method and concatenated with the other string literals to form a single string literal. diff --git a/examples/string-templates/string_templates.metatags b/examples/string-templates/string_templates.metatags index a138d0cda9..2316bed77a 100644 --- a/examples/string-templates/string_templates.metatags +++ b/examples/string-templates/string_templates.metatags @@ -1,2 +1,2 @@ -description: This BBE demonstrates backtick templates in Ballerina. -keywords: ballerina, ballerina by example, bbe, backtick templates +description: This BBE demonstrates string templates in Ballerina. +keywords: ballerina, ballerina by example, bbe, string templates diff --git a/examples/string-templates/string_templates.out b/examples/string-templates/string_templates.out index 042cd85271..cd6f38aea9 100644 --- a/examples/string-templates/string_templates.out +++ b/examples/string-templates/string_templates.out @@ -1,4 +1,6 @@ -$ bal run backtick_templates.bal -Hello, James -Backtick:` -A string-template-expr is evaluated by evaluating the expression in each interpolation in the order in which they occur. +$ bal run string_templates.bal +line one \n rest of line 1 + second line +Backtick: ` Dollar: $ +outer inner 5 inner rest rest +prefix suffix From 73ef2f3660408e267324290d72140d7b9ed55421 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 7 Nov 2024 12:56:58 +0530 Subject: [PATCH 64/80] Fix raw templates not running tests --- examples/index.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/index.json b/examples/index.json index 7bc4c71b17..7b45b7b5ab 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1091,8 +1091,8 @@ { "name": "Raw templates", "url": "raw-templates", - "verifyBuild": false, - "verifyOutput": false, + "verifyBuild": true, + "verifyOutput": true, "isLearnByExample": true }, { @@ -1103,11 +1103,11 @@ "isLearnByExample": true }, { - "name": "XML templates", + "name": "xml templates", "url": "xml-templates", - "verifyBuild": true, - "verifyOutput": true, - "isLearnByExample": true + "verifybuild": true, + "verifyoutput": true, + "islearnbyexample": true } ] }, From 61a3f56c4066deda26bc65903815ed476900814f Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 7 Nov 2024 13:10:36 +0530 Subject: [PATCH 65/80] Add regex example --- examples/index.json | 7 +++++++ examples/regex-templates/regex_templates.bal | 17 +++++++++++++++++ examples/regex-templates/regex_templates.md | 5 +++++ .../regex-templates/regex_templates.metatags | 2 ++ examples/regex-templates/regex_templates.out | 6 ++++++ 5 files changed, 37 insertions(+) create mode 100644 examples/regex-templates/regex_templates.bal create mode 100644 examples/regex-templates/regex_templates.md create mode 100644 examples/regex-templates/regex_templates.metatags create mode 100644 examples/regex-templates/regex_templates.out diff --git a/examples/index.json b/examples/index.json index 7b45b7b5ab..58d2c3dcb2 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1108,6 +1108,13 @@ "verifybuild": true, "verifyoutput": true, "islearnbyexample": true + }, + { + "name": "Regex templates", + "url": "regex-templates", + "verifybuild": true, + "verifyoutput": true, + "islearnbyexample": true } ] }, diff --git a/examples/regex-templates/regex_templates.bal b/examples/regex-templates/regex_templates.bal new file mode 100644 index 0000000000..e770b81721 --- /dev/null +++ b/examples/regex-templates/regex_templates.bal @@ -0,0 +1,17 @@ +import ballerina/io; + +public function main() { + string:RegExp pat1 = re `a+`; + string a0 = ""; + io:println(pat1.isFullMatch(a0)); + string a1 = "a"; + io:println(pat1.isFullMatch(a1)); + string a2 = "aa"; + io:println(pat1.isFullMatch(a2)); + + string:RegExp pat2 = re `[a-z]+`; + string b = "bb"; + io:println(pat2.isFullMatch(b)); + string b1 = "bb1"; + io:println(pat2.isFullMatch(b1)); +} diff --git a/examples/regex-templates/regex_templates.md b/examples/regex-templates/regex_templates.md new file mode 100644 index 0000000000..428119a7b6 --- /dev/null +++ b/examples/regex-templates/regex_templates.md @@ -0,0 +1,5 @@ +# Regex templates + +You can use template expressions with `re` tag to create regular expressions. Ballerina regular expressions are based on the ECMAScript 2022 in unicode mode. + ++ [Regular Expressions](https://ballerina.io/learn/advanced-general-purpose-language-features/#regular-expressions) diff --git a/examples/regex-templates/regex_templates.metatags b/examples/regex-templates/regex_templates.metatags new file mode 100644 index 0000000000..c62d04816d --- /dev/null +++ b/examples/regex-templates/regex_templates.metatags @@ -0,0 +1,2 @@ +description: This BBE demonstrates regex templates in Ballerina. +keywords: ballerina, ballerina by example, bbe, regex templates, regex diff --git a/examples/regex-templates/regex_templates.out b/examples/regex-templates/regex_templates.out new file mode 100644 index 0000000000..ebb0532ff9 --- /dev/null +++ b/examples/regex-templates/regex_templates.out @@ -0,0 +1,6 @@ +$ bal run regex_template.bal +false +true +true +true +false From c61fad0cd8575b6889b65b8510996f1164ddd23b Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 7 Nov 2024 13:14:47 +0530 Subject: [PATCH 66/80] Remove unwanted changes --- examples/index.json | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/index.json b/examples/index.json index 58d2c3dcb2..d6af23631f 100644 --- a/examples/index.json +++ b/examples/index.json @@ -132,6 +132,7 @@ "column": 0, "category": "Language concepts", "samples": [ + { "name": "Binary operators", "url": "binary-operators", @@ -1103,18 +1104,18 @@ "isLearnByExample": true }, { - "name": "xml templates", + "name": "XML templates", "url": "xml-templates", - "verifybuild": true, - "verifyoutput": true, - "islearnbyexample": true + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true }, { "name": "Regex templates", "url": "regex-templates", - "verifybuild": true, - "verifyoutput": true, - "islearnbyexample": true + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true } ] }, @@ -1402,11 +1403,11 @@ "isLearnByExample": true }, { - "name": "Trap expression", - "url": "trap-expression", - "verifyBuild": true, - "verifyOutput": true, - "isLearnByExample": true + "name": "Trap expression", + "url": "trap-expression", + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true }, { "name": "Type intersection for error types", From 087eef5219fe2d1b9c464f8ff0e767aea167b1c3 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 7 Nov 2024 14:20:55 +0530 Subject: [PATCH 67/80] Update distinct object examples --- .../distinct_object_types.bal | 45 ++++++++++++++----- .../distinct_object_types.md | 5 +-- .../distinct_object_types.out | 7 ++- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/examples/distinct-object-types/distinct_object_types.bal b/examples/distinct-object-types/distinct_object_types.bal index f20469474e..52011fc9ee 100644 --- a/examples/distinct-object-types/distinct_object_types.bal +++ b/examples/distinct-object-types/distinct_object_types.bal @@ -1,22 +1,36 @@ import ballerina/io; -// The `Person` object type that contains a string field called `name`. -type Person distinct object { +// DistinctPerson is a proper subtype of Person +class Person { public string name; + + function init(string name) { + self.name = name; + } }; -// The `Engineer` and `Manager` classes are structurally the same but introducing the -// `distinct` keyword distinguishes them by considering them as nominal types. -distinct class Engineer { - *Person; +distinct class DistinctPerson { + public string name; function init(string name) { self.name = name; } } -distinct class Manager { - *Person; +// SomeWhatDistinctPerson is a subtype of DistinctPerson since inherit the same type ID via inclusion +class SomeWhatDistinctPerson { + *DistinctPerson; + public string name; + + function init(string name) { + self.name = name; + } +} + +// EvenMoreDistinctPerson is a proper subtype of DistinctPerson since it has a additional type ID +distinct class EvenMoreDistinctPerson { + *DistinctPerson; + public string name; function init(string name) { self.name = name; @@ -24,7 +38,16 @@ distinct class Manager { } public function main() { - Person person = new Engineer("Alice"); - // The `is` operator can be used to distinguish distinct subtypes. - io:println(person is Engineer ? "Engineer" : "Manager"); + Person person = new ("person"); + io:println(person is DistinctPerson); + DistinctPerson distinctPerson = new ("distinctPerson"); + io:println(distinctPerson is Person); + + SomeWhatDistinctPerson someWhatDistinctPerson = new ("someWhatDistinctPerson"); + io:println(someWhatDistinctPerson is DistinctPerson); + io:println(distinctPerson is SomeWhatDistinctPerson); + + EvenMoreDistinctPerson evenMoreDistinctPerson = new ("evenMoreDistinctPerson"); + io:println(evenMoreDistinctPerson is DistinctPerson); + io:println(distinctPerson is EvenMoreDistinctPerson); } diff --git a/examples/distinct-object-types/distinct_object_types.md b/examples/distinct-object-types/distinct_object_types.md index 7a6d247505..4f64e27724 100644 --- a/examples/distinct-object-types/distinct_object_types.md +++ b/examples/distinct-object-types/distinct_object_types.md @@ -1,8 +1,7 @@ # Distinct object types +For more explicit control over object type relations you can use `distinct` object types. Each distinct object type declaration has a unique type ID. When you include a distinct object type within another object type declaration, the new type's type ID set will include the type ID of the included type. When checking if a given object type `OSub` is a subtype of a distinct object type `OSuper` there is the additional requirement that `OSub` must contain all the type IDs of `OSuper`. -Using the `distinct` keyword in the type definition creates distinct object types. This concept allows defining a type with nominal typing within a structured type system. This is useful when interacting with the external world through API interfaces like `GraphQL`. You may want to leverage nominal typing via this distinct typing feature of Ballerina. - -Conceptually, a distinct type including another distinct type results in multiple interface inheritance. +This way you can achieve the same behavior as a nominal type system within the Ballerina's structured type system, which is useful for things such as GraphQL API interfaces. ::: code distinct_object_types.bal ::: diff --git a/examples/distinct-object-types/distinct_object_types.out b/examples/distinct-object-types/distinct_object_types.out index a7c9955961..5c2f046965 100644 --- a/examples/distinct-object-types/distinct_object_types.out +++ b/examples/distinct-object-types/distinct_object_types.out @@ -1,2 +1,7 @@ $ bal distinct_object_types.bal -Engineer +false +true +true +true +true +false From dc37276d5eaaaa2d67858c926b312c0f31bd2fba Mon Sep 17 00:00:00 2001 From: Heshan Padamsiri Date: Sun, 10 Nov 2024 20:18:46 +0530 Subject: [PATCH 68/80] Apply suggestions from code review Co-authored-by: Maryam Ziyad --- examples/string-templates/string_templates.bal | 11 ++++++----- examples/string-templates/string_templates.md | 2 +- examples/string-templates/string_templates.out | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/string-templates/string_templates.bal b/examples/string-templates/string_templates.bal index 5cfa924724..35a748f2ef 100644 --- a/examples/string-templates/string_templates.bal +++ b/examples/string-templates/string_templates.bal @@ -1,21 +1,22 @@ import ballerina/io; public function main() { - // Note first \n is treated as is. + // Note how the first `\n` is treated as is. string s1 = string `line one \n rest of line 1 ${"\n"} second line`; io:println(s1); - // You can use interpolations to add ` and $ characters. + // Use interpolations to add ` and $ characters. string s2 = string `Backtick: ${"`"} Dollar: ${"$"}`; io:println(s2); - // You can nest template expressions. + // Template expressions can be nested. string s3 = string `outer ${string `inner ${5} inner rest`} rest`; io:println(s3); // You can use an empty string interpolation to break a template expression - // across multiple lines + // across multiple lines. string s4 = string `prefix ${ - ""}suffix`; + ""}middle ${"" + }suffix`; io:println(s4); } diff --git a/examples/string-templates/string_templates.md b/examples/string-templates/string_templates.md index 7b4dc327b4..db2bcae0e1 100644 --- a/examples/string-templates/string_templates.md +++ b/examples/string-templates/string_templates.md @@ -1,3 +1,3 @@ # String templates -A string template is a template expression that can be used to create a string literal. It consists of a `string` tag and a sequence of characters interleaved with interpolations (in the form `${expression}`). Each interpolation must be a subtype of `boolean|int|float|decimal|string`. Every character not a part of the interpolation is interpreted as is to form a sequence of string literals broken at interpolations. This means if you want to add any escape characters you must add them as interpolations (for example `${"\n"}`). Every interpolation is converted to a string using the `toString` method and concatenated with the other string literals to form a single string literal. +A string template is a template expression that can be used to create a string literal. It consists of a `string` tag and a sequence of characters interleaved with interpolations (in the form `${expression}`). Each interpolation must be a subtype of `boolean|int|float|decimal|string`. Every character not a part of the interpolation is interpreted as is to form a sequence of string literals broken at interpolations. This means if you want to add any escape characters you must add them as interpolations (for example `${"\n"}`). Every interpolation is converted to a string using the `toString` lang lib function and concatenated with the other string literals to form a single string literal. diff --git a/examples/string-templates/string_templates.out b/examples/string-templates/string_templates.out index cd6f38aea9..b56c2c75f9 100644 --- a/examples/string-templates/string_templates.out +++ b/examples/string-templates/string_templates.out @@ -3,4 +3,4 @@ line one \n rest of line 1 second line Backtick: ` Dollar: $ outer inner 5 inner rest rest -prefix suffix +prefix middle suffix From 0c7b30a7f8613cc98f2adbeec86e0a2955446072 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Sun, 10 Nov 2024 20:18:37 +0530 Subject: [PATCH 69/80] Remove regex_templates --- examples/index.json | 7 ------- examples/raw-templates/raw_templates.md | 1 + examples/regex-templates/regex_templates.bal | 17 ----------------- examples/regex-templates/regex_templates.md | 5 ----- .../regex-templates/regex_templates.metatags | 2 -- examples/regex-templates/regex_templates.out | 6 ------ 6 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 examples/regex-templates/regex_templates.bal delete mode 100644 examples/regex-templates/regex_templates.md delete mode 100644 examples/regex-templates/regex_templates.metatags delete mode 100644 examples/regex-templates/regex_templates.out diff --git a/examples/index.json b/examples/index.json index d6af23631f..c2eb3f3bb9 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1109,13 +1109,6 @@ "verifyBuild": true, "verifyOutput": true, "isLearnByExample": true - }, - { - "name": "Regex templates", - "url": "regex-templates", - "verifyBuild": true, - "verifyOutput": true, - "isLearnByExample": true } ] }, diff --git a/examples/raw-templates/raw_templates.md b/examples/raw-templates/raw_templates.md index 365a9c862b..9c1fdbce63 100644 --- a/examples/raw-templates/raw_templates.md +++ b/examples/raw-templates/raw_templates.md @@ -12,5 +12,6 @@ An important use case of custom raw templates is SQL parameterized queries. ## Related links - [String templates](https://ballerina.io/learn/by-example/string-templates/) +- [RegExp type](https://ballerina.io/learn/by-example/regexp-type/) - [Object type inclusion](https://ballerina.io/learn/by-example/object-type-inclusion/) - [Database Access - Simple query](https://ballerina.io/learn/by-example/mysql-query-operation/) diff --git a/examples/regex-templates/regex_templates.bal b/examples/regex-templates/regex_templates.bal deleted file mode 100644 index e770b81721..0000000000 --- a/examples/regex-templates/regex_templates.bal +++ /dev/null @@ -1,17 +0,0 @@ -import ballerina/io; - -public function main() { - string:RegExp pat1 = re `a+`; - string a0 = ""; - io:println(pat1.isFullMatch(a0)); - string a1 = "a"; - io:println(pat1.isFullMatch(a1)); - string a2 = "aa"; - io:println(pat1.isFullMatch(a2)); - - string:RegExp pat2 = re `[a-z]+`; - string b = "bb"; - io:println(pat2.isFullMatch(b)); - string b1 = "bb1"; - io:println(pat2.isFullMatch(b1)); -} diff --git a/examples/regex-templates/regex_templates.md b/examples/regex-templates/regex_templates.md deleted file mode 100644 index 428119a7b6..0000000000 --- a/examples/regex-templates/regex_templates.md +++ /dev/null @@ -1,5 +0,0 @@ -# Regex templates - -You can use template expressions with `re` tag to create regular expressions. Ballerina regular expressions are based on the ECMAScript 2022 in unicode mode. - -+ [Regular Expressions](https://ballerina.io/learn/advanced-general-purpose-language-features/#regular-expressions) diff --git a/examples/regex-templates/regex_templates.metatags b/examples/regex-templates/regex_templates.metatags deleted file mode 100644 index c62d04816d..0000000000 --- a/examples/regex-templates/regex_templates.metatags +++ /dev/null @@ -1,2 +0,0 @@ -description: This BBE demonstrates regex templates in Ballerina. -keywords: ballerina, ballerina by example, bbe, regex templates, regex diff --git a/examples/regex-templates/regex_templates.out b/examples/regex-templates/regex_templates.out deleted file mode 100644 index ebb0532ff9..0000000000 --- a/examples/regex-templates/regex_templates.out +++ /dev/null @@ -1,6 +0,0 @@ -$ bal run regex_template.bal -false -true -true -true -false From 1126a92eaa1b3bf8eda27e4dc021036cd7282021 Mon Sep 17 00:00:00 2001 From: Heshan Padamsiri Date: Tue, 12 Nov 2024 08:21:48 +0530 Subject: [PATCH 70/80] Apply suggestions from code review Co-Authored-By: Maryam Ziyad --- .../distinct_object_types.bal | 18 +++++++++++------- .../distinct_object_types.md | 6 ++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/distinct-object-types/distinct_object_types.bal b/examples/distinct-object-types/distinct_object_types.bal index 52011fc9ee..14140b7a79 100644 --- a/examples/distinct-object-types/distinct_object_types.bal +++ b/examples/distinct-object-types/distinct_object_types.bal @@ -1,6 +1,5 @@ import ballerina/io; -// DistinctPerson is a proper subtype of Person class Person { public string name; @@ -9,6 +8,7 @@ class Person { } }; +// The `DistinctPerson` type is a proper subtype of the `Person` type. distinct class DistinctPerson { public string name; @@ -17,9 +17,11 @@ distinct class DistinctPerson { } } -// SomeWhatDistinctPerson is a subtype of DistinctPerson since inherit the same type ID via inclusion +// The `SomeWhatDistinctPerson` type is a subtype of the `DistinctPerson` type +// since it includes the `DistinctPerson` type's type IDs via inclusion. class SomeWhatDistinctPerson { *DistinctPerson; + public string name; function init(string name) { @@ -27,9 +29,10 @@ class SomeWhatDistinctPerson { } } -// EvenMoreDistinctPerson is a proper subtype of DistinctPerson since it has a additional type ID +// `EvenMoreDistinctPerson` is a proper subtype of `DistinctPerson` since it has an additional type ID. distinct class EvenMoreDistinctPerson { *DistinctPerson; + public string name; function init(string name) { @@ -38,16 +41,17 @@ distinct class EvenMoreDistinctPerson { } public function main() { - Person person = new ("person"); + Person person = new ("John Smith"); io:println(person is DistinctPerson); - DistinctPerson distinctPerson = new ("distinctPerson"); + + DistinctPerson distinctPerson = new ("Alice Johnson"); io:println(distinctPerson is Person); - SomeWhatDistinctPerson someWhatDistinctPerson = new ("someWhatDistinctPerson"); + SomeWhatDistinctPerson someWhatDistinctPerson = new ("Michael Brown"); io:println(someWhatDistinctPerson is DistinctPerson); io:println(distinctPerson is SomeWhatDistinctPerson); - EvenMoreDistinctPerson evenMoreDistinctPerson = new ("evenMoreDistinctPerson"); + EvenMoreDistinctPerson evenMoreDistinctPerson = new ("Sarah Wilson"); io:println(evenMoreDistinctPerson is DistinctPerson); io:println(distinctPerson is EvenMoreDistinctPerson); } diff --git a/examples/distinct-object-types/distinct_object_types.md b/examples/distinct-object-types/distinct_object_types.md index 4f64e27724..00594a2f5e 100644 --- a/examples/distinct-object-types/distinct_object_types.md +++ b/examples/distinct-object-types/distinct_object_types.md @@ -1,7 +1,8 @@ # Distinct object types -For more explicit control over object type relations you can use `distinct` object types. Each distinct object type declaration has a unique type ID. When you include a distinct object type within another object type declaration, the new type's type ID set will include the type ID of the included type. When checking if a given object type `OSub` is a subtype of a distinct object type `OSuper` there is the additional requirement that `OSub` must contain all the type IDs of `OSuper`. -This way you can achieve the same behavior as a nominal type system within the Ballerina's structured type system, which is useful for things such as GraphQL API interfaces. +For more explicit control over object type relations you can use `distinct` object types. Each distinct object type declaration has a unique type ID. When you include a distinct object type within another object type declaration, the new type's type ID set will include the type IDs of the included type. When checking if a given object type `OSub` is a subtype of a distinct object type `OSuper` there is the additional requirement that the `OSub` type must contain all the type IDs of the `OSuper` type. + +This way you can achieve the same behavior as a nominal type system within Ballerina's structured type system, which is useful to support features such as GraphQL API interfaces. ::: code distinct_object_types.bal ::: @@ -12,3 +13,4 @@ This way you can achieve the same behavior as a nominal type system within the B - [Error subtyping](/learn/by-example/error-subtyping/) - [Defining classes](/learn/by-example/defining-classes/) - [Flexibly typed](https://ballerina.io/why-ballerina/flexibly-typed/) +- [GraphQL service - Interfaces](https://ballerina.io/learn/by-example/graphql-interfaces/) From 669261a56e5db78fef43bd293630c6745fdc9068 Mon Sep 17 00:00:00 2001 From: Heshan Padamsiri Date: Fri, 15 Nov 2024 07:54:06 +0530 Subject: [PATCH 71/80] Update examples/distinct-object-types/distinct_object_types.bal Co-authored-by: Maryam Ziyad --- examples/distinct-object-types/distinct_object_types.bal | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/distinct-object-types/distinct_object_types.bal b/examples/distinct-object-types/distinct_object_types.bal index 14140b7a79..01042b2b70 100644 --- a/examples/distinct-object-types/distinct_object_types.bal +++ b/examples/distinct-object-types/distinct_object_types.bal @@ -29,7 +29,8 @@ class SomeWhatDistinctPerson { } } -// `EvenMoreDistinctPerson` is a proper subtype of `DistinctPerson` since it has an additional type ID. +// The `EvenMoreDistinctPerson` type is a proper subtype of the `DistinctPerson` +// type since it has an additional type ID. distinct class EvenMoreDistinctPerson { *DistinctPerson; From 714c721414338061831294644607e5eedc5f6b33 Mon Sep 17 00:00:00 2001 From: Heshan Padamsiri Date: Wed, 13 Nov 2024 08:10:28 +0530 Subject: [PATCH 72/80] Address review comments Co-Authored-By: Maryam Ziyad --- .../string-templates/string_templates.bal | 19 +++++++++++++------ examples/string-templates/string_templates.md | 2 +- .../string-templates/string_templates.out | 5 +++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/examples/string-templates/string_templates.bal b/examples/string-templates/string_templates.bal index 35a748f2ef..48517c814c 100644 --- a/examples/string-templates/string_templates.bal +++ b/examples/string-templates/string_templates.bal @@ -1,20 +1,27 @@ import ballerina/io; public function main() { + string word = "world"; + string s0 = string `Hello, ${word}!`; + io:println(s0); + + // Use interpolations to use escape characters. // Note how the first `\n` is treated as is. string s1 = string `line one \n rest of line 1 ${"\n"} second line`; io:println(s1); - // Use interpolations to add ` and $ characters. + // Use interpolations to add the ` and $ characters. string s2 = string `Backtick: ${"`"} Dollar: ${"$"}`; io:println(s2); - // Template expressions can be nested. - string s3 = string `outer ${string `inner ${5} inner rest`} rest`; + // A string template expression can be written on multiple lines by breaking at interpolations. + string s3 = string `T_1 is ${ + 1}, T_2 is ${1 + + 2} and T_3 is ${1 + 2 + 3 + }`; io:println(s3); - - // You can use an empty string interpolation to break a template expression - // across multiple lines. + // If there are no interpolations to break at a required point, you can introduce an interpolation with an empty + // string. string s4 = string `prefix ${ ""}middle ${"" }suffix`; diff --git a/examples/string-templates/string_templates.md b/examples/string-templates/string_templates.md index db2bcae0e1..de854c2bf5 100644 --- a/examples/string-templates/string_templates.md +++ b/examples/string-templates/string_templates.md @@ -1,3 +1,3 @@ # String templates -A string template is a template expression that can be used to create a string literal. It consists of a `string` tag and a sequence of characters interleaved with interpolations (in the form `${expression}`). Each interpolation must be a subtype of `boolean|int|float|decimal|string`. Every character not a part of the interpolation is interpreted as is to form a sequence of string literals broken at interpolations. This means if you want to add any escape characters you must add them as interpolations (for example `${"\n"}`). Every interpolation is converted to a string using the `toString` lang lib function and concatenated with the other string literals to form a single string literal. +A string template is a template expression that can be used to create a string literal. It consists of the `string` tag and a sequence of characters interleaved with interpolations (in the form `${expression}`). Each interpolation must be a subtype of `boolean|int|float|decimal|string`. Every character not a part of the interpolation is interpreted as is to form a sequence of string literals broken at interpolations. This means if you want to add any escape characters you must add them as interpolations (for example `${"\n"}`). Every interpolation is converted to a string using the `toString` lang lib function and concatenated with the other string literals to form a single string literal. diff --git a/examples/string-templates/string_templates.out b/examples/string-templates/string_templates.out index b56c2c75f9..422e868db7 100644 --- a/examples/string-templates/string_templates.out +++ b/examples/string-templates/string_templates.out @@ -1,6 +1,7 @@ $ bal run string_templates.bal -line one \n rest of line 1 +Hello, world! +line one \n rest of line 1 second line Backtick: ` Dollar: $ -outer inner 5 inner rest rest +T_1 is 1, T_2 is 3 and T_3 is 6 prefix middle suffix From e72fc294d1df339c0bb80a44c69cba75ddd03d15 Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Sun, 17 Nov 2024 18:22:20 +0530 Subject: [PATCH 73/80] Migrate to Java 21 --- .github/workflows/daily-build-2201.10.x.yml | 24 ++--- .github/workflows/daily-build-2201.8.x.yml | 24 ++--- .github/workflows/daily-build-2201.9.x.yml | 24 ++--- .github/workflows/daily-build-editor.yml | 4 +- .github/workflows/daily-build.yml | 32 +++--- .../language_server_simulator_fhir.yml | 4 +- .../language_server_simulator_nballerina.yml | 4 +- .github/workflows/main.yml | 4 +- .../workflows/publish-release-artifacts.yml | 4 +- .github/workflows/publish-release.yml | 12 +-- .github/workflows/publish_release_bi.yml | 12 +-- .github/workflows/pull-request.yml | 13 +-- README.md | 2 +- .../test/BallerinaCommandTest.java | 2 +- .../OpenAPIDistributionArtifactCheck.java | 2 +- ballerina/build.gradle | 2 +- build.gradle | 4 +- .../ballerina/gencache/cmd/GenCacheCmd.java | 2 +- .../io/ballerina/dist/DistRepoBuilder.java | 2 +- docs/build-ballerina-from-source.md | 2 +- gradle.properties | 98 +++++++++---------- gradle/javaProject.gradle | 2 +- .../org/ballerina/projectapi/CentralTest.java | 2 +- .../projectapi/CentralTestUtils.java | 2 +- .../resources/central/projectB/Ballerina.toml | 4 +- resources/tools/INSTALL.txt | 12 +-- 26 files changed, 150 insertions(+), 149 deletions(-) diff --git a/.github/workflows/daily-build-2201.10.x.yml b/.github/workflows/daily-build-2201.10.x.yml index 84a4453e90..11277c04c8 100644 --- a/.github/workflows/daily-build-2201.10.x.yml +++ b/.github/workflows/daily-build-2201.10.x.yml @@ -16,11 +16,11 @@ jobs: uses: actions/checkout@v3 with: ref: 2201.10.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Get daily docker version id: version run: echo "::set-output name=version::$(date +'%Y-%m-%d')" @@ -229,11 +229,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.10.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -254,11 +254,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.10.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -278,11 +278,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.10.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Setup Files run: | cd /etc/yum.repos.d/ @@ -362,11 +362,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download MacOS-ARM Intaller Zip uses: actions/download-artifact@v4 with: @@ -401,11 +401,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.10.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - uses: actions/setup-dotnet@v1 with: dotnet-version: '2.1.x' diff --git a/.github/workflows/daily-build-2201.8.x.yml b/.github/workflows/daily-build-2201.8.x.yml index 26ebe726b2..a75054965c 100644 --- a/.github/workflows/daily-build-2201.8.x.yml +++ b/.github/workflows/daily-build-2201.8.x.yml @@ -16,11 +16,11 @@ jobs: uses: actions/checkout@v3 with: ref: 2201.8.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Get daily docker version id: version run: echo "::set-output name=version::$(date +'%Y-%m-%d')" @@ -229,11 +229,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.8.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -254,11 +254,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.8.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -278,11 +278,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.8.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Setup Files run: | cd /etc/yum.repos.d/ @@ -362,11 +362,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download MacOS-ARM Intaller Zip uses: actions/download-artifact@v4 with: @@ -401,11 +401,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.8.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - uses: actions/setup-dotnet@v1 with: dotnet-version: '2.1.x' diff --git a/.github/workflows/daily-build-2201.9.x.yml b/.github/workflows/daily-build-2201.9.x.yml index 05207616c3..19a1cbba8f 100644 --- a/.github/workflows/daily-build-2201.9.x.yml +++ b/.github/workflows/daily-build-2201.9.x.yml @@ -16,11 +16,11 @@ jobs: uses: actions/checkout@v3 with: ref: 2201.9.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Get daily docker version id: version run: echo "::set-output name=version::$(date +'%Y-%m-%d')" @@ -229,11 +229,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.9.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -254,11 +254,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.9.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -278,11 +278,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.9.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Setup Files run: | cd /etc/yum.repos.d/ @@ -362,11 +362,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download MacOS-ARM Intaller Zip uses: actions/download-artifact@v4 with: @@ -401,11 +401,11 @@ jobs: uses: actions/checkout@v2 with: ref: 2201.9.x - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - uses: actions/setup-dotnet@v1 with: dotnet-version: '2.1.x' diff --git a/.github/workflows/daily-build-editor.yml b/.github/workflows/daily-build-editor.yml index e174d7e548..3662754f17 100644 --- a/.github/workflows/daily-build-editor.yml +++ b/.github/workflows/daily-build-editor.yml @@ -12,11 +12,11 @@ jobs: if: github.repository_owner == 'ballerina-platform' steps: - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Use Node.js uses: actions/setup-node@v1 with: diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index e19ba8bdb9..1f02c0c322 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -14,11 +14,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Get daily docker version id: version run: echo "::set-output name=version::$(date +'%Y-%m-%d')" @@ -243,11 +243,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -266,11 +266,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build with Gradle env: packageUser: ${{ github.actor }} @@ -289,11 +289,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Setup Files run: | cd /etc/yum.repos.d/ @@ -326,11 +326,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download Linux-ARM Installer Zip uses: actions/download-artifact@v4 with: @@ -362,11 +362,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download MacOS Installer Zip uses: actions/download-artifact@v4 with: @@ -412,11 +412,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download MacOS-ARM Intaller Zip uses: actions/download-artifact@v4 with: @@ -449,11 +449,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - uses: actions/setup-dotnet@v1 with: dotnet-version: '2.1.x' diff --git a/.github/workflows/language_server_simulator_fhir.yml b/.github/workflows/language_server_simulator_fhir.yml index 2ad7385341..79185e8661 100644 --- a/.github/workflows/language_server_simulator_fhir.yml +++ b/.github/workflows/language_server_simulator_fhir.yml @@ -22,11 +22,11 @@ jobs: with: ref: ${{ matrix.branch }} - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Initialize sub-modules run: git submodule update --init diff --git a/.github/workflows/language_server_simulator_nballerina.yml b/.github/workflows/language_server_simulator_nballerina.yml index 4291cded23..cc9fc600d6 100644 --- a/.github/workflows/language_server_simulator_nballerina.yml +++ b/.github/workflows/language_server_simulator_nballerina.yml @@ -22,11 +22,11 @@ jobs: with: ref: ${{ matrix.branch }} - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Initialize sub-modules run: git submodule update --init diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3b0d2d73c0..660758db17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,11 +19,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Get project version id: project-version run: | diff --git a/.github/workflows/publish-release-artifacts.yml b/.github/workflows/publish-release-artifacts.yml index 622763ac5f..1f6e96b68a 100644 --- a/.github/workflows/publish-release-artifacts.yml +++ b/.github/workflows/publish-release-artifacts.yml @@ -18,11 +18,11 @@ jobs: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Set version env variable id: set-version diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 90c0a4adff..0311ff4dc6 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -23,11 +23,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Set version env variable id: version-set run: | @@ -559,11 +559,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download MacOS Intaller Zip run: | wget https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{ needs.publish-release.outputs.release-version }}/ballerina-${{ needs.publish-release.outputs.project-version }}-macos.zip @@ -696,11 +696,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - uses: actions/setup-dotnet@v1 with: dotnet-version: '2.1.x' diff --git a/.github/workflows/publish_release_bi.yml b/.github/workflows/publish_release_bi.yml index f615619e17..8222eb788e 100644 --- a/.github/workflows/publish_release_bi.yml +++ b/.github/workflows/publish_release_bi.yml @@ -16,11 +16,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Use Node.js uses: actions/setup-node@v1 with: @@ -350,11 +350,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Download MacOS Intaller Zip run: | wget https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{ needs.publish-release.outputs.release-version }}/ballerina-${{ needs.publish-release.outputs.project-version }}-macos.zip @@ -439,11 +439,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - uses: actions/setup-dotnet@v1 with: dotnet-version: '2.1.x' diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index bed871ec95..3b12567923 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,6 +7,7 @@ on: - ballerina-1.1.x - ballerina-1.2.x - 2201.[0-9]+.x + - java21 jobs: ubuntu-integration-tests: @@ -18,11 +19,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build Ballerina Distribution env: packageUser: ${{ github.actor }} @@ -41,11 +42,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build Ballerina Distribution env: packageUser: ${{ github.actor }} @@ -63,11 +64,11 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '17.0.7' + java-version: '21.0.3' - name: Build Ballerina Distribution env: packageUser: ${{ github.actor }} diff --git a/README.md b/README.md index ae0e4a25fd..f44cb9c70e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Alternatively, you can install Ballerina from the source using the following ins #### Prerequisites -* JDK17 ([Adopt OpenJDK17](https://adoptopenjdk.net/) or any other OpenJDK distribution) +* JDK21 ([Adopt OpenJDK21](https://adoptopenjdk.net/) or any other OpenJDK distribution) #### Building the source diff --git a/ballerina-test/src/test/java/org/ballerinalang/distribution/test/BallerinaCommandTest.java b/ballerina-test/src/test/java/org/ballerinalang/distribution/test/BallerinaCommandTest.java index 4ccd9be433..74acdfe1a0 100644 --- a/ballerina-test/src/test/java/org/ballerinalang/distribution/test/BallerinaCommandTest.java +++ b/ballerina-test/src/test/java/org/ballerinalang/distribution/test/BallerinaCommandTest.java @@ -103,7 +103,7 @@ public void testDistCommands() throws IOException { actualOutput = TestUtils.executeCommand(path + " dist pull slp7"); Assert.assertTrue(actualOutput.contains("Fetching the 'slp7' distribution from the remote server...")); Assert.assertTrue(actualOutput.contains("Fetching the dependencies for 'slp7' from the remote server...")); - Assert.assertTrue(actualOutput.contains("Downloading jdk-17.0.7+7-jre")); + Assert.assertTrue(actualOutput.contains("Downloading jdk-21.0.5+11-jre")); Assert.assertTrue(actualOutput.contains("'slp7' successfully set as the active distribution")); TestUtils.testInstallation(path, "swan-lake-preview7", "v2020-09-22", TOOL_VERSION, "Preview 7"); diff --git a/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java b/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java index d57dce7f39..8fa98fa6a8 100644 --- a/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java +++ b/ballerina-test/src/test/java/org/ballerinalang/distribution/test/OpenAPIDistributionArtifactCheck.java @@ -62,7 +62,7 @@ public void openapiAnnotationExistsTest() { .resolve("ballerina") .resolve("openapi") .resolve("2.1.0") - .resolve("java17"); + .resolve("java21"); Path breLibPath = TEST_DISTRIBUTION_PATH .resolve(DIST_NAME) diff --git a/ballerina/build.gradle b/ballerina/build.gradle index c18d518cf1..719b491d8e 100644 --- a/ballerina/build.gradle +++ b/ballerina/build.gradle @@ -1209,7 +1209,7 @@ task testExamples() { def addH2Dependency = { filePath -> // Add the H2 database dependency to Ballerina.toml file def tomlFile = new File(filePath) - tomlFile.append("\n\n[[platform.java17.dependency]]") + tomlFile.append("\n\n[[platform.java21.dependency]]") tomlFile.append("\nartifactId = \"h2\"") tomlFile.append("\nversion = \"2.2.224\"") tomlFile.append("\ngroupId = \"com.h2database\"") diff --git a/build.gradle b/build.gradle index f9413a69ae..cf2ce3ce38 100644 --- a/build.gradle +++ b/build.gradle @@ -70,8 +70,8 @@ allprojects { subprojects { apply plugin: 'java' - sourceCompatibility = 17 - targetCompatibility = 17 + sourceCompatibility = 21 + targetCompatibility = 21 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } diff --git a/cache-generator/src/main/java/io/ballerina/gencache/cmd/GenCacheCmd.java b/cache-generator/src/main/java/io/ballerina/gencache/cmd/GenCacheCmd.java index 41665c8595..c6daed0746 100644 --- a/cache-generator/src/main/java/io/ballerina/gencache/cmd/GenCacheCmd.java +++ b/cache-generator/src/main/java/io/ballerina/gencache/cmd/GenCacheCmd.java @@ -81,7 +81,7 @@ public void execute() { if (diagnosticResult.hasErrors()) { return; } - JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(packageCompilation, JvmTarget.JAVA_17); + JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(packageCompilation, JvmTarget.JAVA_21); diagnosticResult = jBallerinaBackend.diagnosticResult(); for (Diagnostic diagnostic : diagnosticResult.diagnostics()) { outStream.println(diagnostic.toString()); diff --git a/dist-repo-builder/src/main/java/io/ballerina/dist/DistRepoBuilder.java b/dist-repo-builder/src/main/java/io/ballerina/dist/DistRepoBuilder.java index 86e312c7ec..b4a7c9457d 100644 --- a/dist-repo-builder/src/main/java/io/ballerina/dist/DistRepoBuilder.java +++ b/dist-repo-builder/src/main/java/io/ballerina/dist/DistRepoBuilder.java @@ -135,7 +135,7 @@ private static boolean validateCache(Path bala, Path repo) { valid = false; } // Check if module jar exists - Path jar = repo.resolve("cache").resolve(orgName).resolve(moduleName).resolve(version).resolve("java17") + Path jar = repo.resolve("cache").resolve(orgName).resolve(moduleName).resolve(version).resolve("java21") .resolve(getJarName(orgName, moduleName, version)); if (!Files.exists(jar)) { System.out.println("Jar missing for package :" + orgName + "/" + moduleName); diff --git a/docs/build-ballerina-from-source.md b/docs/build-ballerina-from-source.md index e8e37c4ed4..606e9a0897 100644 --- a/docs/build-ballerina-from-source.md +++ b/docs/build-ballerina-from-source.md @@ -11,7 +11,7 @@ Follow the steps below to set up the prerequisites. -1. Download and [set up](https://adoptopenjdk.net/installation.html) OpenJDK 17 ([Adopt OpenJDK](https://adoptopenjdk.net/) or any other OpenJDK distribution). +1. Download and [set up](https://adoptopenjdk.net/installation.html) OpenJDK 21 ([Adopt OpenJDK](https://adoptopenjdk.net/) or any other OpenJDK distribution). >**Info:** You can also use [Oracle JDK](https://www.oracle.com/java/technologies/javase-downloads.html). diff --git a/gradle.properties b/gradle.properties index a853358273..04d565cbc8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,74 +4,74 @@ group=org.ballerinalang version=2201.11.0-SNAPSHOT codeName=swan-lake -ballerinaLangVersion=2201.10.0 +ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77 ballerinaJreVersion=2.0.1 -dependencyJREVersion=jdk-17.0.7+7-jre +dependencyJREVersion=jdk-21.0.5+11-jre specVersion=2024R1 slf4jVersion=1.7.30 balstdlibBranch=master devIdpUrl=https://dev.api.asgardeo.io/oauth2/token/.well-known/openid-configuration # Stdlib Level 01 -stdlibIoVersion=1.6.1 -stdlibJavaArraysVersion=1.4.0 -stdlibTimeVersion=2.5.0 -stdlibUrlVersion=2.4.0 -stdlibXmldataVersion=2.8.0 -observeVersion=1.3.0 -stdlibMathVectorVersion=1.0.2 -stdlibLdapVersion=1.0.1 +stdlibIoVersion=1.6.2-20241112-233100-995cf5f +stdlibJavaArraysVersion=1.4.1-20241112-232800-f3adad7 +stdlibTimeVersion=2.6.0-20241113-073800-201b904 +stdlibUrlVersion=2.4.1-20241113-073900-335ff51 +stdlibXmldataVersion=2.8.1-20241112-235200-752b9bc +observeVersion=1.4.0-20241113-092000-b83ae74 +stdlibMathVectorVersion=1.0.3-20241112-233200-6a39cd1 +stdlibLdapVersion=1.1.0-20241113-084300-d6cc91d # Stdlib Level 02 -stdlibAvroVersion=1.0.2 -stdlibConstraintVersion=1.5.0 -stdlibCryptoVersion=2.7.2 -stdlibDataXmldataVersion=1.0.0 -stdlibLogVersion=2.10.0 -stdlibOsVersion=1.8.0 -stdlibProtobufVersion=1.6.1 -stdlibPersistVersion=1.4.0 -stdlibRandomVersion=1.5.0 -stdlibTaskVersion=2.5.0 -stdlibXsltVersion=2.7.0 -observeInternalVersion=1.3.0 +stdlibAvroVersion=1.0.3-20241113-081200-95b592a +stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5 +stdlibCryptoVersion=2.7.3-20241113-081400-d015a39 +stdlibDataXmldataVersion=1.0.1-20241113-122800-f4e815c +stdlibLogVersion=2.10.1-20241113-120000-4577868 +stdlibOsVersion=1.8.1-20241113-122000-cca973b +stdlibProtobufVersion=1.6.2-20241113-122200-13cac06 +stdlibPersistVersion=1.4.1-20241113-122000-306cc63 +stdlibRandomVersion=1.5.1-20241113-122300-1bc770e +stdlibTaskVersion=2.5.1-20241113-123500-f905281 +stdlibXsltVersion=2.7.1-20241113-123200-11dc649 +observeInternalVersion=1.3.1-20241113-101700-265054d # Stdlib Level 03 -stdlibCacheVersion=3.8.0 -stdlibFileVersion=1.10.0 -stdlibFtpVersion=2.11.0 -stdlibMimeVersion=2.10.0 -stdlibTcpVersion=1.11.0 -stdlibUdpVersion=1.11.0 -stdlibUuidVersion=1.8.0 +stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf +stdlibFileVersion=1.10.1-20241113-151700-e1a2e38 +stdlibFtpVersion=2.11.1-20241113-154100-5317889 +stdlibMimeVersion=2.10.2-20241113-154200-d953747 +stdlibTcpVersion=1.11.1-20241113-154600-cf61b56 +stdlibUdpVersion=1.11.1-20241113-154800-7443083 +stdlibUuidVersion=1.8.1-20241113-154400-443c67b # Stdlib Level 04 -stdlibAuthVersion=2.12.0 -stdlibDataJsondataVersion=0.2.0 -stdlibDataYamlVersion=0.1.0 -stdlibEdiVersion=1.3.0 -stdlibEmailVersion=2.10.0 -stdlibJwtVersion=2.13.0 -stdlibMqttVersion=1.2.0 -stdlibOAuth2Version=2.12.0 -stdlibTomlVersion=0.6.0 -stdlibYamlVersion=0.6.0 +stdlibAuthVersion=2.12.1-20241113-162300-ded40eb +stdlibDataJsondataVersion=0.3.0-20241114-143900-285d739 +stdlibDataYamlVersion=0.1.1-20241113-122600-5fd87f8 +stdlibEdiVersion=1.3.1-20241113-171300-d9e62c8 +stdlibEmailVersion=2.10.1-20241113-171700-4b2c1fd +stdlibJwtVersion=2.13.1-20241113-162400-b59ccfa +stdlibMqttVersion=1.2.1-20241113-190800-260cda7 +stdlibOAuth2Version=2.12.1-20241113-162400-4c6ddfe +stdlibTomlVersion=0.6.1-20241113-170100-f224cf6 +stdlibYamlVersion=0.6.1-20241113-171500-62c6f03 # Stdlib Level 05 -stdlibHttpVersion=2.12.2 +stdlibHttpVersion=2.13.0-20241114-182900-7e9f66a # Stdlib Level 06 -stdlibGrpcVersion=1.12.1 -stdlibSoapVersion=1.1.0 -stdlibTransactionVersion=1.10.0 -stdlibWebsocketVersion=2.12.0 -stdlibWebsubVersion=2.12.0 -stdlibWebsubhubVersion=1.12.0 +stdlibGrpcVersion=1.13.0-20241114-195700-5188f60 +stdlibSoapVersion=2.1.0-20241116-112000-3dd2c94 +stdlibTransactionVersion=1.10.1-20241116-112500-189a4e5 +stdlibWebsocketVersion=2.13.0-20241116-202000-ddd958d +stdlibWebsubVersion=2.13.0-20241114-233100-73205d6 +stdlibWebsubhubVersion=1.13.0-20241116-124900-2bb76a4 # Stdlib Level 07 -stdlibGraphqlVersion=1.14.0 -stdlibSqlVersion=1.14.1 +stdlibGraphqlVersion=1.15.0-20241117-164000-4d95b39 +stdlibSqlVersion=1.15.0-20241116-124800-0bc6a40 # Persist Tool persistToolVersion=1.4.0 @@ -84,7 +84,7 @@ ballerinaCommandVersion=1.4.3 docUiApi=https://api.dev-central.ballerina.io/2.0/docs/doc-ui # GraphQL Tool -graphqlToolVersion=0.11.0 +graphqlToolVersion=0.11.1-20241117-184300-39bc271 # Protoc Tool protocToolVersion=0.3.0 diff --git a/gradle/javaProject.gradle b/gradle/javaProject.gradle index 3b6e27902f..8505c9d0bd 100644 --- a/gradle/javaProject.gradle +++ b/gradle/javaProject.gradle @@ -66,7 +66,7 @@ dependencies { checkstyle "com.puppycrawl.tools:checkstyle:${puppycrawlCheckstyleVersion}" } -sourceCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' diff --git a/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTest.java b/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTest.java index c9bbab97de..44b4d761ae 100644 --- a/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTest.java +++ b/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTest.java @@ -195,7 +195,7 @@ public void testPushPackageA() throws IOException, InterruptedException { } } - @Test(description = "Build package B which has java17 platform dependency") + @Test(description = "Build package B which has java21 platform dependency") public void testBuildPackageB() throws IOException, InterruptedException { Process build = executePackCommand(DISTRIBUTION_FILE_NAME, this.tempWorkspaceDirectory.resolve(PROJECT_B), new LinkedList<>(), this.envVariables); diff --git a/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTestUtils.java b/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTestUtils.java index 434ac85be4..44bb8610a8 100644 --- a/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTestUtils.java +++ b/project-api-tests/src/test/java/org/ballerina/projectapi/CentralTestUtils.java @@ -68,7 +68,7 @@ private CentralTestUtils() { static final String COMMON_VERSION = "1.0.0"; static final String TEST_PREFIX = "test_"; static final String ANY_PLATFORM = "any"; - static final String JAVA_PLATFORM = "java17"; + static final String JAVA_PLATFORM = "java21"; static final String BALLERINA_ARTIFACT_TYPE = "bala"; static final String OUTPUT_NOT_CONTAINS_EXP_MSG = "build output does not contain expected message:"; static final String PULLED_FROM_CENTRAL_MSG = " pulled from central successfully"; diff --git a/project-api-tests/src/test/resources/central/projectB/Ballerina.toml b/project-api-tests/src/test/resources/central/projectB/Ballerina.toml index 29be49ed1b..07d2cb7e09 100644 --- a/project-api-tests/src/test/resources/central/projectB/Ballerina.toml +++ b/project-api-tests/src/test/resources/central/projectB/Ballerina.toml @@ -3,10 +3,10 @@ org = "bctestorg" name = "my_package" version = "1.0.0" -[platform.java17] +[platform.java21] graalvmCompatible=true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.slf4j" artifactId = "slf4j-api" version = "1.7.30" diff --git a/resources/tools/INSTALL.txt b/resources/tools/INSTALL.txt index 99158fd75b..1d9ab61cc2 100644 --- a/resources/tools/INSTALL.txt +++ b/resources/tools/INSTALL.txt @@ -6,7 +6,7 @@ PREREQUISITES ------------- Ballerina requires JRE 17. -Check https://adoptopenjdk.net/releases.html?variant=openjdk17&jvmVariant=hotspot to download the JRE relevant to your system. +Check https://adoptopenjdk.net/releases.html?variant=openjdk21&jvmVariant=hotspot to download the JRE relevant to your system. This is the Java version we have used when testing Ballerina. @@ -20,14 +20,14 @@ INSTALLING BALLERINA - Add the `/bin` path to your system's path variable. -- If you have installed Java 17 already, you are all set! Just make sure that the JAVA_HOME environment variable is set correctly. +- If you have installed Java 21 already, you are all set! Just make sure that the JAVA_HOME environment variable is set correctly. -- If you do not have Java 17 or if you have a different version of Java, download a compatible JRE 17 version as specified in the prerequisites. +- If you do not have Java 21 or if you have a different version of Java, download a compatible JRE 17 version as specified in the prerequisites. - - To set the obtained JRE as the one used by Ballerina, extract the downloaded JRE `zip/tar.gz` to the `/dependencies/jdk-17.0.7+7-jre` directory. + - To set the obtained JRE as the one used by Ballerina, extract the downloaded JRE `zip/tar.gz` to the `/dependencies/jdk-21.0.5+11-jre` directory. - Once you are done, the directory structure should look exactly like the following: /dependencies/ - └── jdk-17.0.7+7-jre + └── jdk-21.0.5+11-jre ├── bin ├── bundle ├── conf @@ -35,7 +35,7 @@ INSTALLING BALLERINA ├── lib ├── man └── release - - Ensure that the directory which contains the JRE is named "jdk-17.0.7+7-jre" + - Ensure that the directory which contains the JRE is named "jdk-21.0.5+11-jre" - Finally, to verify whether Ballerina is installed properly, you can run the `bal version` command. If Ballerina was installed correctly, you should see an output similar to the following: $ bal version From 175e9fa8491b5ffd6d0ce9a1ce02a74d74efd4e9 Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Sun, 17 Nov 2024 20:05:03 +0530 Subject: [PATCH 74/80] Disable soap bbes temporary --- examples/index.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/index.json b/examples/index.json index 6b1d24ccc1..0803cb3775 100644 --- a/examples/index.json +++ b/examples/index.json @@ -3703,7 +3703,7 @@ { "name": "Inbound Security", "url": "soap-client-security-inbound-security-config", - "verifyBuild": true, + "verifyBuild": false, "verifyOutput": false, "disablePlayground": true, "isLearnByExample": false @@ -3711,7 +3711,7 @@ { "name": "Outbound Security", "url": "soap-client-security-outbound-security-config", - "verifyBuild": true, + "verifyBuild": false, "verifyOutput": false, "disablePlayground": true, "isLearnByExample": false From 48c633861907790ba98a7814baea35bddfbbd202 Mon Sep 17 00:00:00 2001 From: anuruddhal Date: Mon, 18 Nov 2024 14:49:13 +0530 Subject: [PATCH 75/80] Add multiple architecture support for Docker images --- .github/workflows/publish-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 90c0a4adff..db513c3acc 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -97,11 +97,12 @@ jobs: password: ${{ secrets.DOCKER_HUB_TOKEN }} - name: Build the docker image id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: module-ballerina-docker/base/docker/ load: true push: false + platforms: linux/amd64,linux/arm64 tags: ballerina/ballerina:release-test build-args: | BALLERINA_DIST=ballerina-${{ steps.version-set.outputs.sversion }}.zip From 8c31c4cda8f0cf28523c656378d5cf4578f551be Mon Sep 17 00:00:00 2001 From: Maryam Ziyad Date: Mon, 18 Nov 2024 18:15:17 +0530 Subject: [PATCH 76/80] Update examples/string-templates/string_templates.bal --- examples/string-templates/string_templates.bal | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/string-templates/string_templates.bal b/examples/string-templates/string_templates.bal index 48517c814c..89a5b38b36 100644 --- a/examples/string-templates/string_templates.bal +++ b/examples/string-templates/string_templates.bal @@ -20,6 +20,7 @@ public function main() { 2} and T_3 is ${1 + 2 + 3 }`; io:println(s3); + // If there are no interpolations to break at a required point, you can introduce an interpolation with an empty // string. string s4 = string `prefix ${ From 37890a48c3067e1c36300c1ed20f5052525944b3 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 18 Nov 2024 20:38:58 +0530 Subject: [PATCH 77/80] Update soap examples to be compatible with new configs --- ...lient_security_inbound_security_config.bal | 16 ++++++---- ...ient_security_outbound_security_config.bal | 29 +++++++++++-------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal b/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal index e41acdf9cc..c54e86c8cf 100644 --- a/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal +++ b/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal @@ -1,17 +1,23 @@ -import ballerina/soap; import ballerina/soap.soap12; public function main() returns error? { + crypto:KeyStore keyStore = { + path: "/path/to/keyStore.p12", + password: "keyStorePassword" + }; + crypto:KeyStore decryptionKeyStore = { + path: "/path/to/keyStore.p12", + password: "keyStorePassword" + }; + soap12:Client soapClient = check new ("http://soap-endpoint.com?wsdl", { inboundSecurity: { - username: "user", - password: "password", - passwordType: soap:TEXT + signatureKeystore: keyStore, + decryptKeystore: decryptionKeyStore } } ); - xml body = xml ` `; diff --git a/examples/soap-client-security-outbound-security-config/soap_client_security_outbound_security_config.bal b/examples/soap-client-security-outbound-security-config/soap_client_security_outbound_security_config.bal index 21607b2975..b17bd9f06b 100644 --- a/examples/soap-client-security-outbound-security-config/soap_client_security_outbound_security_config.bal +++ b/examples/soap-client-security-outbound-security-config/soap_client_security_outbound_security_config.bal @@ -1,26 +1,31 @@ import ballerina/crypto; -import ballerina/soap; import ballerina/soap.soap12; public function main() returns error? { - crypto:PrivateKey verificationKey = check crypto:decodeRsaPrivateKeyFromKeyFile( - "../resource/path/to/private.key" - ); - crypto:PublicKey decryptionKey = check crypto:decodeRsaPublicKeyFromCertFile( - "../resource/path/to/public.crt" - ); + crypto:KeyStore keyStore = { + path: "/path/to/keyStore.p12", + password: "keyStorePassword" + }; + crypto:KeyStore decryptionKeyStore = { + path: "/path/to/decryptionKeyStore.p12", + password: "keyStorePassword" + }; soap12:Client soapClient = check new ("http://soap-endpoint.com?wsdl", { outboundSecurity: { - verificationKey: verificationKey, - signatureAlgorithm: soap:RSA_SHA256, - decryptionKey: decryptionKey, - decryptionAlgorithm: soap:RSA_ECB + signatureConfig: { + keystore: keyStore, + privateKeyAlias: "private-key-alias", + privateKeyPassword: "private-key-password" + }, + encryptionConfig: { + keystore: decryptionKeyStore, + publicKeyAlias: "public-key-alias" + } } } ); - xml body = xml ` `; From f241d38c8ef66e8b83c2ae0323d1bf0bb1dfaaba Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Tue, 19 Nov 2024 20:23:26 +0530 Subject: [PATCH 78/80] Remove java21 branch from github actions --- .github/workflows/pull-request.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3b12567923..f4122af126 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,7 +7,6 @@ on: - ballerina-1.1.x - ballerina-1.2.x - 2201.[0-9]+.x - - java21 jobs: ubuntu-integration-tests: From fc222e13178db97b3f9a35effbb13b91845cad54 Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Tue, 19 Nov 2024 23:26:17 +0530 Subject: [PATCH 79/80] Add suggestions from code review --- examples/index.json | 4 ++-- gradle.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/index.json b/examples/index.json index d051446e0a..aca32d26d7 100644 --- a/examples/index.json +++ b/examples/index.json @@ -3701,7 +3701,7 @@ { "name": "Inbound Security", "url": "soap-client-security-inbound-security-config", - "verifyBuild": false, + "verifyBuild": true, "verifyOutput": false, "disablePlayground": true, "isLearnByExample": false @@ -3709,7 +3709,7 @@ { "name": "Outbound Security", "url": "soap-client-security-outbound-security-config", - "verifyBuild": false, + "verifyBuild": true, "verifyOutput": false, "disablePlayground": true, "isLearnByExample": false diff --git a/gradle.properties b/gradle.properties index 04d565cbc8..473dbdf5ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -47,7 +47,7 @@ stdlibUuidVersion=1.8.1-20241113-154400-443c67b # Stdlib Level 04 stdlibAuthVersion=2.12.1-20241113-162300-ded40eb -stdlibDataJsondataVersion=0.3.0-20241114-143900-285d739 +stdlibDataJsondataVersion=0.3.0-20241119-191600-348e6c9 stdlibDataYamlVersion=0.1.1-20241113-122600-5fd87f8 stdlibEdiVersion=1.3.1-20241113-171300-d9e62c8 stdlibEmailVersion=2.10.1-20241113-171700-4b2c1fd From a3f2d200117953b188c8e71e4b842c73e9c548fb Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Wed, 20 Nov 2024 11:09:48 +0530 Subject: [PATCH 80/80] Add missing import and update tcp timestamp --- .../soap_client_security_inbound_security_config.bal | 1 + gradle.properties | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal b/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal index c54e86c8cf..535ada1d56 100644 --- a/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal +++ b/examples/soap-client-security-inbound-security-config/soap_client_security_inbound_security_config.bal @@ -1,4 +1,5 @@ import ballerina/soap.soap12; +import ballerina/crypto; public function main() returns error? { crypto:KeyStore keyStore = { diff --git a/gradle.properties b/gradle.properties index 473dbdf5ad..bb97cb88ef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -41,7 +41,7 @@ stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf stdlibFileVersion=1.10.1-20241113-151700-e1a2e38 stdlibFtpVersion=2.11.1-20241113-154100-5317889 stdlibMimeVersion=2.10.2-20241113-154200-d953747 -stdlibTcpVersion=1.11.1-20241113-154600-cf61b56 +stdlibTcpVersion=1.12.0-20241120-110300-de99389 stdlibUdpVersion=1.11.1-20241113-154800-7443083 stdlibUuidVersion=1.8.1-20241113-154400-443c67b