ballerina-platform / setup-ballerina

Set up your GitHub Actions workflow with a specific Ballerina version
Apache License 2.0
107 stars 3 forks source link

Action leaves installation artifact file causing un-versioned file errors during workflows #8

Open Xenowa opened 1 month ago

Xenowa commented 1 month ago

Description:

Using the setup-ballerina action in a GitHub workflow that publishes packages to the GitHub Package Registry results in un-versioned file errors. This is because the setup-ballerina action fails to clean up the downloaded Ballerina installation artifact file after installing Ballerina. This un-versioned artifact(i.e: .msi, .pkg, .deb) file causes build failures during the publishing process, as publishing requires all files to be versioned.

Suggested Labels: Bug

Steps to reproduce:

  1. Create a repository with a workflow file containing setup-ballerina action configured with steps to build and release a Gradle package to GitHub package registry.
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: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '17.0.7'

      - name: Set Up Ballerina
        uses: ballerina-platform/setup-ballerina@v1.1.0
        with:
          version: latest

      - 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 dependency version update
        env:
          GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
        run: |
          echo "Version: ${VERSION}"
          git config --global user.name ${{ secrets.BALLERINA_BOT_USERNAME }}
          git config --global user.email ${{ secrets.BALLERINA_BOT_EMAIL }}
          git checkout -b release-${VERSION}
          sed -i 's/ballerinaLangVersion=\(.*\)-SNAPSHOT/ballerinaLangVersion=\1/g' gradle.properties
          sed -i 's/ballerinaLangVersion=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/ballerinaLangVersion=\1/g' gradle.properties
          git add gradle.properties
          git commit -m "Move dependencies to stable version" || echo "No changes to commit"

      - name: Publish artifact
        env:
          GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
          BALLERINA_DEV_CENTRAL: true
          BALLERINA_STAGE_CENTRAL: false
          BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_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 release -Prelease.useAutomaticVersion=true
          ./gradlew publish -Pversion=${VERSION}

      - name: GitHub Release and Release Sync PR
        env:
          GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
        run: |
          gh release create v$VERSION --title "scan-tool-v$VERSION"
          gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync ${GITHUB_REF##*/} after $VERSION release" --body "Sync ${GITHUB_REF##*/} after $VERSION release"
  1. Trigger the workflow.

Here is the build stacktrace:

Run ./gradlew clean release -Prelease.useAutomaticVersion=true
Downloading https://services.gradle.org/distributions/gradle-8.2.1-bin.zip
............10%............20%............30%.............40%............50%............60%............70%.............80%............90%............100%

Welcome to Gradle 8.2.1!

Here are the highlights of this release:
 - Kotlin DSL: new reference documentation, assignment syntax by default
 - Kotlin DSL is now the default with Gradle init
 - Improved suggestions to resolve errors in console output
 - Reduced sync memory consumption

For more details see https://docs.gradle.org/8.2.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)
> Task :scan-command:clean UP-TO-DATE
Release process failed, reverting back any changes made by Release Plugin.
> Task :static-code-analysis-tool:createScmAdapter
> Task :static-code-analysis-tool:initScmAdapter

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':static-code-analysis-tool:checkCommitNeeded'.
> You have unversioned files:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ?? ballerina-2[20](https://github.com/Xenowa/static-code-analysis-tool/actions/runs/9380877419/job/25828864897#step:7:21)1.9.0-swan-lake-linux-x64.deb
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Try:
> Task :static-code-analysis-tool:checkCommitNeeded FAILED

> Task :release FAILED
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 12s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.2.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
2 actionable tasks: 1 executed, 1 up-to-date
Error: Process completed with exit code 1.
anupama-pathirage commented 3 weeks ago

@keizer619 Please check on this.