An open API service indexing awesome lists of open source software.

https://github.com/ajgranowski/preceding-tag-action

Find the most recent tag that is reachable from a commit.
https://github.com/ajgranowski/preceding-tag-action

github github-actions github-api typescript

Last synced: 19 days ago
JSON representation

Find the most recent tag that is reachable from a commit.

Awesome Lists containing this project

README

          

[![CICD][cicd-badge]][cicd-link]
[![Coverage Status][coverage-badge]][coverage-link]
[![OpenSSF Scorecard][ossf-scorecard-badge]][ossf-scorecard-link]
[![OpenSSF Best Practices][ossf-best-practices-badge]][ossf-best-practices-link]

   

Preceding Tag Action


   

Find the most recent tag that is reachable from a commit.

## About
This action functions similar to [`git describe`][git-describe-link] by finding the most recent tag that is reachable from a commit. Since this action uses the GitHub API instead of a local Git database, you can use this action without `actions/checkout`!

## Usage
```yml
- uses: AJGranowski/preceding-tag-action@▒▒▒▒▒▒▒▒▒▒▒▒▒ COMMIT SHA ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ # vX.Y.Z
id: preceding-tag

- env:
PRECEDING_TAG: ${{ steps.preceding-tag.outputs.tag }}
run: |
echo "Preceding tag: $PRECEDING_TAG"
```

```yml
- uses: AJGranowski/preceding-tag-action@▒▒▒▒▒▒▒▒▒▒▒▒▒ COMMIT SHA ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ # vX.Y.Z
id: preceding-release-tag
with:
regex: ^release-.+$

- env:
PRECEDING_RELEASE_TAG: ${{ steps.preceding-release-tag.outputs.tag }}
run: |
echo "Preceding release tag: $PRECEDING_RELEASE_TAG"
```

Although this project publishes version tags, I strongly recommend [pinning this action to a full-length commit SHA][security-sha-pinning-link]. You can get the SHA of the latest release from the [latest release page][latest-release-link] by clicking the commit link, then and copying the SHA from the URL.

## Inputs
| Name | Type | Default | Description |
|---------------|---------|----------------------------|-----------------------------------------------------------------------------|
| `repository` | String | `${{ github.repository }}` | Repository name with owner. For example, `AJGranowski/preceding-tag-action` |
| `ref` | String | `${{ github.sha }}` | The branch, tag, or SHA to find the preceding tag from. |
| `regex` | String | `^.+$` | A regular expression used to filter candidate tag names. |
| `default-tag` | String | `​` | The default tag to return if no preceding tag was found. |
| `include-ref` | Boolean | `false` | If true, include tags pointing to `ref` as candidates. |
| `token` | String | `${{ github.token }}` | Personal access token (PAT) used to fetch the tags. |

## Outputs
| Name | Type | Description |
|-------------|---------|----------------------------------------------------------------------------------------|
| `tag` | String | The preceding tag, or `default-tag` if no preceding tag matching the filter was found. |
| `tag-found` | Boolean | True if the preceding tag was found. False if the `default-tag` fallback was used. |

[cicd-badge]: https://github.com/AJGranowski/preceding-tag-action/actions/workflows/cicd.yml/badge.svg?branch=main
[cicd-link]: https://github.com/AJGranowski/preceding-tag-action/actions/workflows/cicd.yml
[coverage-badge]: https://coveralls.io/repos/github/AJGranowski/preceding-tag-action/badge.svg?branch=main
[coverage-link]: https://coveralls.io/github/AJGranowski/preceding-tag-action?branch=main
[git-describe-link]: https://git-scm.com/docs/git-describe
[latest-release-link]: https://github.com/AJGranowski/preceding-tag-action/releases/latest
[ossf-best-practices-badge]: https://www.bestpractices.dev/projects/11154/badge
[ossf-best-practices-link]: https://www.bestpractices.dev/projects/11154
[ossf-scorecard-badge]: https://api.securityscorecards.dev/projects/github.com/AJGranowski/preceding-tag-action/badge
[ossf-scorecard-link]: https://securityscorecards.dev/viewer/?uri=github.com/AJGranowski/preceding-tag-action
[security-sha-pinning-link]: https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions