Skip to content

Commit

Permalink
Merge pull request ballerina-platform#3 from Ajai-Suvendran/main
Browse files Browse the repository at this point in the history
Finalize v1.0.0 Release Preparations for SWIFT MT Library
  • Loading branch information
Ashi1993 authored Nov 1, 2024
2 parents 03b866e + bc6c1d9 commit 494f6c4
Show file tree
Hide file tree
Showing 54 changed files with 358 additions and 19 deletions.
156 changes: 156 additions & 0 deletions .github/workflows/build-executor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: execute-build

on:
workflow_call:
inputs:
working_dir:
required: true
type: string
bal_central_environment:
required: true
type: string
env:
BALLERINA_VERSION: 2201.10.1
jobs:
release:
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xmx4G
steps:
- uses: actions/checkout@v3

- name: Set Up Ballerina
uses: ballerina-platform/[email protected]
with:
version: $BALLERINA_VERSION

- name: Run ballerina build for staging
if: inputs.bal_central_environment == 'STAGE'
env:
BALLERINA_STAGE_CENTRAL: true
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }}
run: |
pushd "${{ inputs.working_dir }}"
bal pack
popd
- name: Run ballerina build for dev
if: inputs.bal_central_environment == 'DEV'
env:
BALLERINA_DEV_CENTRAL: true
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }}
run: |
pushd "${{ inputs.working_dir }}"
bal pack
popd
- name: Run ballerina build for prod
if: inputs.bal_central_environment == 'PROD'
run: |
pushd "${{ inputs.working_dir }}"
bal pack
popd
- name: Push to Staging
if: inputs.bal_central_environment == 'STAGE'
env:
BALLERINA_STAGE_CENTRAL: true
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }}
run: |
pushd "${{ inputs.working_dir }}"
bal push
popd
- name: Push to Dev
if: inputs.bal_central_environment == 'DEV'
env:
BALLERINA_DEV_CENTRAL: true
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }}
run: |
pushd "${{ inputs.working_dir }}"
bal push
popd
- name: Push to Prod
if: inputs.bal_central_environment == 'PROD'
env:
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
run: |
pushd "${{ inputs.working_dir }}"
bal push
popd
- name: Publish Release
if: inputs.bal_central_environment == 'PROD'
id: publish_release
run: |
# Get Branch Name
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
# Release name
RELEASE_NAME=${BRANCH_NAME#release-}
curl \
-s -X POST \
-H "Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{
"tag_name": "'$RELEASE_NAME'",
"name": "'$RELEASE_NAME'",
"body": "[Automated] Creating tag: '$RELEASE_NAME'.",
"draft": false,
"prerelease": false,
"target_commitish": "'$BRANCH_NAME'"
}' \
"https://api.github.com/repos/${{ github.repository }}/releases"
- name: Update version in Ballerina.toml
if: ${{ inputs.bal_central_environment == 'PROD' }}
id: increment_patch_version
run: |
CURRENT_VERSION=$(grep -Po -m 1 '(?<=version = ")[\d.]+' ${{ inputs.working_dir }}/Ballerina.toml)
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
PATCH_VERSION=$((VERSION_PARTS[2] + 1))
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$PATCH_VERSION"
sed -i "0,/version = \"${CURRENT_VERSION}\"/s//version = \"${NEW_VERSION}\"/" ${{ inputs.working_dir }}/Ballerina.toml
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
- name: Ballerina Build after incrementing version
if: ${{ inputs.bal_central_environment == 'PROD' }}
run: |
pushd "${{ inputs.working_dir }}"
bal pack
popd
- name: Commit changes and make a PR
if: ${{ inputs.bal_central_environment == 'PROD' }}
run: |
# Extract the package name from working directory
packageName=$(basename ${{ inputs.working_dir }})
# Commit changes
git config --global user.name ${{ secrets.BALLERINA_BOT_USERNAME }}
git config --global user.email ${{ secrets.BALLERINA_BOT_EMAIL }}
git add ${{ inputs.working_dir }}/Ballerina.toml
git add ${{ inputs.working_dir }}/Dependencies.toml
git commit -m "[Release ${packageName} ${{ steps.increment_patch_version.outputs.CURRENT_VERSION }}] Prepare for next dev cycle"
git push origin ${{ steps.publish_release.outputs.BRANCH_NAME }}
# Set the base and head branches
BASE_BRANCH="main"
HEAD_BRANCH="${{ steps.publish_release.outputs.BRANCH_NAME }}"
# Create the pull request using the GitHub REST API
RESPONSE=$(curl -s -X POST \
-H "Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{
"title": "[Release ${packageName} ${{ steps.increment_patch_version.outputs.CURRENT_VERSION }}] Prepare for next dev cycle",
"body": "",
"head": "'"$HEAD_BRANCH"'",
"base": "'"$BASE_BRANCH"'"
}' \
"https://api.github.com/repos/${{ github.repository }}/pulls")
# Extract the pull request URL from the response
PR_URL=$(echo "$RESPONSE" | jq -r '.html_url')
echo "Pull Request created: $PR_URL"
21 changes: 21 additions & 0 deletions .github/workflows/cd-swiftmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: cd-swiftmt

on:
workflow_dispatch:
inputs:
bal_central_environment:
description: Ballerina Central Environment
type: choice
options:
- STAGE
- DEV
- PROD
required: true

jobs:
build:
uses: ./.github/workflows/build-executor.yml
secrets: inherit
with:
working_dir: ./swiftmt
bal_central_environment: ${{ inputs.bal_central_environment }}
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
pull_request:
types:
- opened
- synchronize

env:
FILE_PATTERN: '*/*'
GITHUB_WORKFLOWS_DIR: '.github'
BALLERINA_VERSION: 2201.10.1

jobs:
build:
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xmx4G

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set Up Ballerina
uses: ballerina-platform/[email protected]
with:
version: $BALLERINA_VERSION

- name: Ballerina Build
run: |
pushd swiftmt
bal pack
popd
test:
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xmx4G

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set Up Ballerina
uses: ballerina-platform/[email protected]
with:
version: $BALLERINA_VERSION

- name: Ballerina Test
run: |
pushd swiftmt
bal test --code-coverage
popd
- name: Read Ballerina Test Results
id: test_results
run: |
# echo "TEST_RESULTS_JSON=" >> $GITHUB_OUTPUT
echo "No test results file found."
54 changes: 54 additions & 0 deletions .github/workflows/daily-build-executor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow runs daily to build, test, and upload code coverage reports for Ballerina projects to Codecov.

# Reason for using separate workflows per project/folder: GitHub Actions badges only show the overall status of a workflow. Separate workflows allow for individual build badges, which can be displayed on the ballerina-release-dashboard.

name: daily-build-executor

on:
workflow_call:
inputs:
working_dir:
required: true
type: string

env:
BALLERINA_VERSION: 2201.10.1

jobs:
build:
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xmx4G

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set Up Ballerina
uses: ballerina-platform/[email protected]
with:
version: $BALLERINA_VERSION

- name: Ballerina Build and Test
run: |
pushd "${{ inputs.working_dir }}"
bal build
bal test --test-report --code-coverage --coverage-format=xml
popd
- name: Find Coverage Reports
run: |
FIND_REPORTS=$(find "${{ inputs.working_dir }}" -name 'coverage-report.xml' || true)
if [[ $FIND_REPORTS != '' ]]; then
echo "REPORTS=${FIND_REPORTS}" >> $GITHUB_ENV
else
echo "No coverage reports found."
fi
- name: Upload Coverage Reports to Codecov
if: ${{env.REPORTS}}
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true # Optional: Specify if the CI build should fail when Codecov fails.
flags: ${{ inputs.working_dir }}
13 changes: 13 additions & 0 deletions .github/workflows/daily-build-swiftmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: daily-build-swiftmt

on:
schedule:
- cron: '00 20 * * *' # 01:30 in LK time (GMT+5:30)
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/daily-build-executor.yml
secrets: inherit
with:
working_dir: swiftmt
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The `ballerinax/financial.swift.mt` library provides support for creating, parsi

```ballerina
import ballerina/io;
import ballerinax/financial.swift.mt;
import ballerinax/financial.swift.mt as swiftmt;
public function main() returns error? {
string finMessage = string `{1:F01CHASUS33AXXX0000000000}
Expand All @@ -41,7 +41,7 @@ public function main() returns error? {

```ballerina
import ballerina/io;
import ballerinax/fiancial.swift.mt;
import ballerinax/fiancial.swift.mt as swiftmt;
public function main() returns error? {
swiftmt:MT900Message swiftMessage = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions ballerina/Ballerina.toml → swiftmt/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ org = "ballerinax"
name = "financial.swift.mt"
version = "1.0.0"
distribution = "2201.10.1"
authors=["Ballerina"]
keywords=["Financial", "SWIFT MT"]
repository="https://github.com/ballerina-platform/module-ballerinax-financial.swiftmt"
license = ["Apache-2.0"]

[build-options]
observabilityIncluded = true
Expand Down
File renamed without changes.
13 changes: 11 additions & 2 deletions ballerina/Module.md → swiftmt/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The `ballerinax/financial.swift.mt` library provides support for creating, parsi

```ballerina
import ballerina/io;
import ballerinax/financial.swift.mt;
import ballerinax/financial.swift.mt as swiftmt;
public function main() returns error? {
string finMessage = string `{1:F01CHASUS33AXXX0000000000}
Expand All @@ -41,7 +41,7 @@ public function main() returns error? {

```ballerina
import ballerina/io;
import ballerinax/fiancial.swift.mt;
import ballerinax/fiancial.swift.mt as swiftmt;
public function main() returns error? {
swiftmt:MT900Message swiftMessage = {
Expand All @@ -65,3 +65,12 @@ public function main() returns error? {
io:println(swiftMessage);
}
```

## Report issues

To report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina library parent repository](https://github.com/ballerina-platform/ballerina-library).

## Useful Links

- Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
- Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
13 changes: 11 additions & 2 deletions ballerina/Package.md → swiftmt/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The `ballerinax/financial.swift.mt` library provides support for creating, parsi

```ballerina
import ballerina/io;
import ballerinax/financial.swift.mt;
import ballerinax/financial.swift.mt as swiftmt;
public function main() returns error? {
string finMessage = string `{1:F01CHASUS33AXXX0000000000}
Expand All @@ -41,7 +41,7 @@ public function main() returns error? {

```ballerina
import ballerina/io;
import ballerinax/fiancial.swift.mt;
import ballerinax/fiancial.swift.mt as swiftmt;
public function main() returns error? {
swiftmt:MT900Message swiftMessage = {
Expand All @@ -65,3 +65,12 @@ public function main() returns error? {
io:println(swiftMessage);
}
```

## Report issues

To report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina library parent repository](https://github.com/ballerina-platform/ballerina-library).

## Useful Links

- Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
- Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 494f6c4

Please sign in to comment.