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.
- Host: GitHub
- URL: https://github.com/ajgranowski/preceding-tag-action
- Owner: AJGranowski
- License: mit
- Created: 2025-08-26T11:02:08.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-11-20T03:08:13.000Z (6 months ago)
- Last Synced: 2026-04-29T16:51:50.823Z (22 days ago)
- Topics: github, github-actions, github-api, typescript
- Language: TypeScript
- Homepage:
- Size: 574 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
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