SOLIDSoftworks / semver-tags

MIT License
4 stars 5 forks source link

Bug: latest (1.5.3) cannot tag when a previous tag does not exist #6

Open asciifaceman opened 8 months ago

asciifaceman commented 8 months ago

It seems if this action has to generate a default tag it fails

Run SOLIDSoftworks/semver-tags@v1.5.3
Generating version regex pattern
Generated pattern: ^hatch-test-suite-v(\d+)\.(\d+)\.(\d+)(-(\w[\w.]*))?(\+(\w[\w\.]*))??$
Getting previous tags
Generating version regex pattern
Generated pattern: ^hatch-test-suite-v?(\d+)\.(\d+)\.(\d+)(-(\w[\w.]*))?(\+(\w[\w\.]*))??$
No previous version tag. Using '0.1.0' as next version.
/runner/_work/_actions/SOLIDSoftworks/semver-tags/v1.5.3/dist/index.js:27572
    major = match[1];
                 ^

TypeError: Cannot read properties of null (reading '1')
    at calculateNextVersion (/runner/_work/_actions/SOLIDSoftworks/semver-tags/v1.5.3/dist/index.js:27572:18)
    at run (/runner/_work/_actions/SOLIDSoftworks/semver-tags/v1.5.3/dist/index.js:27685:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

My guess is that the match is not being populated, possibly because prefix optional=true being ignored:

const versionPattern = generateVersionPattern({ tagPrefix: tagPrefix, tagPrefixOptional: true });

Usage in question:

      - name: Bump version and push tag
        uses: SOLIDSoftworks/semver-tags@v1.5.3
        id: tag_version
        with:
          GITHUB_TOKEN: ${{ steps.secrets.outputs.GITHUB_TOKEN }}
          tag-prefix: ${{ matrix.workflows }}-v
          default-version: '0.1.0'
          incremented-value: ${{ steps.bump_version.outputs.value }}
          dry-run: ${{ github.event_name == 'pull_request' }}
asciifaceman commented 8 months ago

Creating a dummy tag of the expected style is an interim fix - however it cannot seem to handle a prefixed default version at the moment