| 
 | 1 | +name: Publish Release  | 
 | 2 | + | 
 | 3 | +on:  | 
 | 4 | +  workflow_dispatch:  | 
 | 5 | +    inputs:  | 
 | 6 | +      distribution_version:  | 
 | 7 | +        description: 'Ballerina distribution version (e.g.; 2201.9.0)'  | 
 | 8 | +        required: true  | 
 | 9 | +        default: '2201.11.0'  | 
 | 10 | + | 
 | 11 | +jobs:  | 
 | 12 | +  publish-release:  | 
 | 13 | +    runs-on: ubuntu-latest  | 
 | 14 | +    if: github.repository_owner == 'ballerina-platform'  | 
 | 15 | +    steps:  | 
 | 16 | +      - name: Checkout Repository  | 
 | 17 | +        uses: actions/checkout@v3  | 
 | 18 | +      - name: Set up JDK 21  | 
 | 19 | +        uses: actions/setup-java@v3  | 
 | 20 | +        with:  | 
 | 21 | +          distribution: 'temurin'  | 
 | 22 | +          java-version: 21.0.3  | 
 | 23 | +      - name: Set up Ballerina  | 
 | 24 | +        uses: ballerina-platform/setup-ballerina@v1.1.3  | 
 | 25 | +        with:  | 
 | 26 | +          version: ${{ github.event.inputs.distribution_version }}  | 
 | 27 | +      - name: Set version env variable  | 
 | 28 | +        run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV  | 
 | 29 | +      - name: Pre release depenency version update  | 
 | 30 | +        env:  | 
 | 31 | +          GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}  | 
 | 32 | +        run: |  | 
 | 33 | +          echo "Version: ${VERSION}"  | 
 | 34 | +          git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }}  | 
 | 35 | +          git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }}  | 
 | 36 | +          git checkout -b release-${VERSION}  | 
 | 37 | +          git add gradle.properties  | 
 | 38 | +          git commit -m "Move dependencies to stable version" || echo "No changes to commit"  | 
 | 39 | +      - name: Grant execute permission for gradlew  | 
 | 40 | +        run: chmod +x gradlew  | 
 | 41 | +      - name: Set Docker Host env variable  | 
 | 42 | +        run: echo "DOCKER_HOST=$(docker context ls --format '{{print .DockerEndpoint}}' | tr -d '\n')" >> $GITHUB_ENV  | 
 | 43 | +      - name: Build with Gradle  | 
 | 44 | +        env:  | 
 | 45 | +          packageUser: ${{ github.actor }}  | 
 | 46 | +          packagePAT: ${{ secrets.GITHUB_TOKEN }}  | 
 | 47 | +        run: ./gradlew build -x check -x test  | 
 | 48 | +      - name: Run Trivy vulnerability scanner  | 
 | 49 | +        uses: aquasecurity/trivy-action@master  | 
 | 50 | +        with:  | 
 | 51 | +          scan-type: 'fs'  | 
 | 52 | +          scan-ref: '.'  | 
 | 53 | +          format: 'table'  | 
 | 54 | +          timeout: '10m0s'  | 
 | 55 | +          exit-code: '1'  | 
 | 56 | +      - name: Publish artifact  | 
 | 57 | +        env:  | 
 | 58 | +          DOCKER_HOST: unix:///var/run/docker.sock  | 
 | 59 | +          GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}  | 
 | 60 | +          BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}  | 
 | 61 | +          packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}  | 
 | 62 | +          packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}  | 
 | 63 | +          packagePublishRepo: ${{ github.repository }}  | 
 | 64 | +        run: |  | 
 | 65 | +          rm -rf .cache  | 
 | 66 | +          rm -rf trivy  | 
 | 67 | +          git stash  | 
 | 68 | +          ./gradlew release -Prelease.useAutomaticVersion=true  | 
 | 69 | +          ./gradlew -Pversion=${VERSION} publish -x test  | 
 | 70 | +      - name: Create Github release from the release tag  | 
 | 71 | +        run: |  | 
 | 72 | +          curl --request POST 'https://api.github.com/repos/${{ github.repository }}/releases' \  | 
 | 73 | +          --header 'Accept: application/vnd.github.v3+json' \  | 
 | 74 | +          --header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \  | 
 | 75 | +          --header 'Content-Type: application/json' \  | 
 | 76 | +          --data-raw '{  | 
 | 77 | +             "tag_name": "v'"$VERSION"'",  | 
 | 78 | +             "name": "module-ballerinax-moesif-v'"$VERSION"'"  | 
 | 79 | +          }'  | 
 | 80 | +      - name: Post release PR  | 
 | 81 | +        env:  | 
 | 82 | +          GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}  | 
 | 83 | +        run: |  | 
 | 84 | +          curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1  | 
 | 85 | +          bin/hub pull-request --base main -m "[Automated] Sync master after "$VERSION" release"  | 
0 commit comments