ietf-tools / semver-action

GitHub Action to calculate the next release version based on conventional commits
BSD 3-Clause "New" or "Revised" License
56 stars 22 forks source link

Current version is blank in the output if the action exited silently #26

Closed Forceh91 closed 1 year ago

Forceh91 commented 1 year ago

I like to automatically create a zip file of the build and attach to the workflow on completion using a file name of v{VERSION}-{COMMIT_HASH}.

Previously I'd read the package.json to get the version to use but I want to start automatically updating the semver so I don't have to manually figure it out.

In the workflow I've done the following:

  bump-version:
    name: "Bump Version"
    runs-on: "ubuntu-latest"
    needs: unit-test
    outputs:
      version: ${{ steps.semver.outputs.next || steps.semver.outputs.current }}
    steps:
      - name: Checkout Commit
        uses: actions/checkout@v3

      - name: Generate Version
        id: semver
        uses: ietf-tools/semver-action@v1
        with:
          token: ${{ github.token }}
          branch: ${{ github.head_ref || github.ref_name }}
          noVersionBumpBehavior: silent
          skipInvalidTags: true # because i accidentally did v16.1 at one point

 build:
    name: "Production Build"
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [16.x]
    needs: [bump-version]
    steps:
      ...
      - name: Upload build artifacts
        uses: actions/upload-artifact@v3
        with:
          name: ${{ needs.bump-version.outputs.version }}-${{ env.commit_hash }}

However it seems that both next and current are empty if there was no version change. As the build job has the following in the logs:

Artifact -33336c0 has been successfully uploaded!

NGPixel commented 1 year ago

Added a new current option for the noVersionBumpBehavior parameter in v1.4.0, which will return the current version for both the current and next variables.

Forceh91 commented 1 year ago

Great! Thank you 😊