Publish Release #2
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: | |
ballerina_version: | |
description: 'Ballerina distribution version (e.g.; 2201.8.4)' | |
required: true | |
default: '2201.8.4' | |
jobs: | |
publish-release: | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'ballerina-platform' | |
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: Set up Ballerina | |
uses: ballerina-platform/[email protected] | |
with: | |
version: ${{ github.event.inputs.ballerina_version }} | |
- name: Set version env variable | |
run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV | |
- name: Pre release depenency version update | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
run: | | |
echo "Version: ${VERSION}" | |
git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }} | |
git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }} | |
git checkout -b release-${VERSION} | |
git add gradle.properties | |
git commit -m "Move dependencies to stable version" || echo "No changes to commit" | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Set Docker Host env variable | |
run: echo "DOCKER_HOST=$(docker context ls --format '{{print .DockerEndpoint}}' | tr -d '\n')" >> $GITHUB_ENV | |
- name: Build with Gradle | |
env: | |
packageUser: ${{ github.actor }} | |
packagePAT: ${{ secrets.GITHUB_TOKEN }} | |
run: ./gradlew build -x check -x test | |
- 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' | |
- name: Publish artifact | |
env: | |
DOCKER_HOST: unix:///var/run/docker.sock | |
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 }} | |
packagePublishRepo: ${{ github.repository }} | |
run: | | |
git stash | |
./gradlew release -Prelease.useAutomaticVersion=true | |
./gradlew -Pversion=${VERSION} publish -x test | |
- name: Create Github release from the release tag | |
run: | | |
curl --request POST 'https://api.github.com/repos/${{ github.repository }}/releases' \ | |
--header 'Accept: application/vnd.github.v3+json' \ | |
--header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ | |
--header 'Content-Type: application/json' \ | |
--data-raw '{ | |
"tag_name": "v'"$VERSION"'", | |
"name": "module-ballerinax-newrelic-v'"$VERSION"'" | |
}' | |
- name: Post release PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }} | |
run: | | |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1 | |
bin/hub pull-request --base main -m "[Automated] Sync master after "$VERSION" release" |