npm-get-version-action
npm-get-version-action copied to clipboard
Is there a way to get only the major version
Hello! thanks for this project!
I was wondering if there is a way to get only the major version from this?
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.
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}}
.