Publish Release #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Release | |
on: | |
workflow_dispatch: | |
inputs: | |
connector: | |
type: choice | |
description: Select Connector | |
required: true | |
options: | |
- api_salesdistrict_srv | |
- api_salesorganization_srv | |
- api_sales_order_srv | |
- api_sd_sa_soldtopartydetn | |
- salesarea_0001 | |
- api_sd_incoterms_srv | |
- api_sales_inquiry_srv | |
- api_sales_quotation_srv | |
- api_sales_order_simulation_srv | |
- ce_salesorder_0001 | |
jobs: | |
call_workflow: | |
name: Release Package | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'ballerina-platform' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Get Ballerina Version | |
run: | | |
BAL_VERSION=$(grep -w 'ballerinaLangVersion' gradle.properties | cut -d= -f2 | rev | cut --complement -d- -f1 | rev) | |
if [ -z "$BAL_VERSION" ]; then | |
BAL_VERSION="latest" | |
fi | |
echo "BAL_VERSION=$BAL_VERSION" >> $GITHUB_ENV | |
echo "Ballerina Version: $BAL_VERSION" | |
- name: Set Up Ballerina | |
uses: ballerina-platform/[email protected] | |
with: | |
version: ${{ env.BAL_VERSION }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.7 | |
- name: Set ENV Variables | |
run: | | |
echo -e '${{ toJson(secrets) }}' | jq -r 'to_entries[] | .key + "=" + .value' >> $GITHUB_ENV | |
# This step is because this repoistory is a collection of packages | |
- name: Change version in gradle.properties | |
run: | | |
git config --global user.name ${{ secrets.BALLERINA_BOT_USERNAME }} | |
git config --global user.email ${{ secrets.BALLERINA_BOT_EMAIL }} | |
CONNECTOR_VERSION=$((grep -w '${{ inputs.connector }}Version' | cut -d= -f2) < gradle.properties) | |
VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties) | |
if [[ "$VERSION" == "$CONNECTOR_VERSION" ]]; then | |
echo "Version is already up to date" | |
exit 0 | |
fi | |
sed -i "s/version=\(.*\)/version=$CONNECTOR_VERSION/g" gradle.properties | |
git commit -m "[Automated] Update verion to match connector version" gradle.properties | |
- name: Build without Tests | |
env: | |
packageUser: ${{ github.actor }} | |
packagePAT: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
./gradlew build -x test | |
- name: Create lib Directory if not Exists | |
run: mkdir -p ballerina/lib | |
- name: Run Trivy Vulnerability Scanner | |
uses: aquasecurity/trivy-action@master | |
with: | |
scan-type: "rootfs" | |
scan-ref: "/github/workspace/ballerina/lib" | |
format: "table" | |
timeout: "10m0s" | |
exit-code: "1" | |
skip-dirs: "examples" | |
- name: Get Release Version | |
run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut -d- -f2 | rev)" >> $GITHUB_ENV | |
- name: Checkout to Release Branch | |
run: | | |
echo "Version: ${VERSION}" | |
git checkout -b release-${{ inputs.connector }}-${VERSION} | |
- name: Remove Lib Directory | |
run: | | |
sudo rm -rf ballerina/lib | |
- name: Publish Package | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} | |
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} | |
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
publishUser: ${{ secrets.BALLERINA_BOT_USERNAME }} | |
publishPAT: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
run: | | |
./gradlew clean :sales-ballerina:${{ inputs.connector }}:release -x :sales-examples:test -Prelease.useAutomaticVersion=true | |
./gradlew -Pversion=${VERSION} -P${{ inputs.connector }}Version=${VERSION} :sales-ballerina:${{ inputs.connector }}:publish -x test -PpublishToCentral=true | |
- name: GitHub Release and Release Sync PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
run: | | |
git push origin release-${{ inputs.connector }}-${VERSION} | |
gh release create ${{ inputs.connector }}-v$VERSION --title "${{ inputs.connector }}-v$VERSION" | |
gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync ${GITHUB_REF##*/} after ${{ inputs.connector }}-$VERSION release" --body "Sync ${GITHUB_REF##*/} after ${{ inputs.connector }}-$VERSION release" |