npm-get-version-action icon indicating copy to clipboard operation
npm-get-version-action copied to clipboard

Is there a way to get only the major version

Open MurrayJack opened this issue 3 years ago • 2 comments

Hello! thanks for this project!

I was wondering if there is a way to get only the major version from this?

MurrayJack avatar Jun 28 '21 06:06 MurrayJack

Currently, no. But with some regular expressions this is certainly possible. You can an step in your workflow with a little bit of shell script to get the major version and return that as output of that step.

martinbeentjes avatar Aug 19 '21 11:08 martinbeentjes

I'm currently using this step to generate my versions based on this action:

      - name: Generate addition version tags
        id: versions
        run: |
          echo "major=$(cut -d '.' -f 1 <<< ${{ steps.package-json-version.outputs.current-version}})" >> $GITHUB_OUTPUT
          echo "minor=$(cut -d '.' -f 1,2 <<< ${{ steps.package-json-version.outputs.current-version}})" >> $GITHUB_OUTPUT
          echo "full=${{ steps.package-json-version.outputs.current-version}}" >> $GITHUB_OUTPUT

To be accessed with ${{ steps.versions.outputs.major}}.

karlludwigweise avatar Jun 09 '23 09:06 karlludwigweise