Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add previous tag regexp pattern #2093

Closed
2 tasks done
aupisarev opened this issue May 15, 2024 · 3 comments · Fixed by #2098
Closed
2 tasks done

[Feature] add previous tag regexp pattern #2093

aupisarev opened this issue May 15, 2024 · 3 comments · Fixed by #2098
Labels
enhancement New feature or request

Comments

@aupisarev
Copy link

aupisarev commented May 15, 2024

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

I'm triggering the action on the release event. Version tags contain pre-releases, e.g.

1.1.0	//current release
1.1.0-2 //pre-release
1.1.0-1 //pre-release
1.0.1	//previous release
1.0.0

I want to find files between two release - 1.0.1 and 1.1.0.
Similar problem in #1468.

Describe the solution you'd like?

Add input previous_tag_pattern that is an regexp.
And change method getPreviousGitTag of utils.ts:

export const getPreviousGitTag = async ({
  cwd,
  pattern
}: {
  cwd: string
  pattern: string
}): Promise<{tag: string; sha: string}> => {

  ...

  const tags = stdout.trim().split('\n')
  tags.shift()
  let previousTag = ''

  if (pattern) {
    previousTag = tags.find(value => value.match(pattern)) || ''
  } else if (tags.length > 0) {
    previousTag = tags[0]
  }

  if (!previousTag) {
    core.warning('No previous tag found')
    return {tag: '', sha: ''}
  }

  ...

  return {tag: previousTag, sha}
}

I can use it like this

        uses: tj-actions/changed-files@v44
        with:
          previous_tag_pattern: ^v[0-9]+.[0-9]+.[0-9]+$

Describe alternatives you've considered?

I can get a similar solution to the problem in the following way, but it's inconvenient and regexp is a more flexible solution

- name: Get sha of previous release version
        run: |
          VER=$(git describe --tags --abbrev=0 --match v*.*.* --exclude v*.*.*-* --exclude ${{ github.ref_name }})
          echo "SHA=$(git rev-list --max-count=1 $VER)" >> $GITHUB_ENV

- name: Get changed files by sha
        uses: tj-actions/changed-files@v44
        with:
          base_sha: ${{ env.SHA }}

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@aupisarev aupisarev added the enhancement New feature or request label May 15, 2024
@tj-actions-bot
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented May 21, 2024

Hi @aupisarev, this should be available in the latest release you can now specify a pattern using either the tags_pattern or the tags_ignore_pattern inputs

@aupisarev
Copy link
Author

Hi @jackton1! This works fine, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants