Publish Release #4
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: | |
jobs: | |
publish-release: | |
name: Release Package | |
runs-on: ubuntu-latest | |
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/setup-ballerina@v1.1.0 | |
with: | |
version: ${{ env.BAL_VERSION }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.7 | |
- name: Build without Tests | |
env: | |
packageUser: ${{ github.actor }} | |
packagePAT: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name ${{ secrets.USERNAME }} | |
git config --global user.email ${{ secrets.EMAIL }} | |
./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-${VERSION} | |
- name: Remove Target Directory | |
run: | | |
sudo rm -rf ballerina/target | |
sudo rm -rf ballerina/build | |
- name: Publish Package | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} | |
packageUser: ${{ secrets.USERNAME }} | |
packagePAT: ${{ secrets.GITHUB_TOKEN }} | |
publishUser: ${{ secrets.USERNAME }} | |
publishPAT: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
./gradlew clean release -Prelease.useAutomaticVersion=true | |
./gradlew -Pversion=${VERSION} publish -x test -PpublishToCentral=true | |
- name: GitHub Release and Release Sync PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create v$VERSION --title "module-niveathika-pluralize-v$VERSION" | |
gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync ${GITHUB_REF##*/} after $VERSION release" --body "Sync ${GITHUB_REF##*/} after $VERSION release" |