Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrschu90/gittagsemanticversion
GitHub action to get version information from the Git tag
https://github.com/chrschu90/gittagsemanticversion
action continuous-deployment continuous-integration github-actions mit-license powershell publishing versioning
Last synced: about 1 month ago
JSON representation
GitHub action to get version information from the Git tag
- Host: GitHub
- URL: https://github.com/chrschu90/gittagsemanticversion
- Owner: ChrSchu90
- License: mit
- Created: 2023-05-09T19:43:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-14T21:30:10.000Z (over 1 year ago)
- Last Synced: 2024-11-15T11:08:29.614Z (about 1 month ago)
- Topics: action, continuous-deployment, continuous-integration, github-actions, mit-license, powershell, publishing, versioning
- Language: PowerShell
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Git Tag Semantic Version
GitHub action to get version information from the Git tag.The tag reqires a "v" as prefix followed by a [Semantic Version 2.0.0](https://semver.org/). You can [test your tag](https://regex101.com/r/rEi5ZC/2) for validation.
## Formats:
- *v[Major].[Minor].[Patch]
- *v[Major].[Minor].[Patch]-[pre-release]
- *v[Major].[Minor].[Patch]+[buildmetadata]
- *v[Major].[Minor].[Patch]-[pre-release]+[buildmetadata]## Example
```yml
name: Exampleon:
push:
tags:
- 'v*'jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-restore --no-build
- name: Get Version from Tag
if: startsWith(github.event.ref, 'refs/tags/v')
id: tagver
uses: ChrSchu90/[email protected]
- name: Pack Release NuGets
if: ${{ steps.tagver.outputs.is_release == 'true' }}
run: dotnet pack --no-restore --output ${{ github.workspace }}/packages /p:Version=${{ steps.tagver.outputs.version }}
- name: Pack Prerelease NuGets
if: ${{ steps.tagver.outputs.is_prerelease == 'true' }}
run: dotnet pack --no-restore --output ${{ github.workspace }}/packages /p:VersionPrefix=${{ steps.tagver.outputs.version }} --version-suffix ${{ steps.tagver.outputs.suffix }}
- name: Push NuGets
if: ${{ steps.tagver.outputs.is_valid == 'true' }}
run: dotnet nuget push ${{ github.workspace }}/packages/*.nupkg --source ${{ secrets.NUGET_FEED }} --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}
```## Inputs
| Name | Type | Description |
| ------------ | ------ | ----------------------------------------------------------------------------------- |
| `tag` | String | [optional] Tag where the version info gets extracted from. Default is `github.ref` |## Outputs
The following outputs can be accessed via `${{ steps..outputs }}`.
Note that boolean output variables needs to be handled like strings, otherwise it could lead into unexpected behaviors!| Name | Type | Description |
| --------------- | ------ | ----------------------------------------------------------------------------- |
| `version_tag` | String | The clean version tag (e.g. v1.2.3-beta1+as4at5dd) without the git ref prefix |
| `version` | String | Version without pre-release or build metadata (e.g. 1.2.3) |
| `major` | String | Major version number (e.g. 1) |
| `minor` | String | Minor version number (e.g. 2) |
| `patch` | String | Patch version number (e.g. 3) |
| `suffix` | String | Pre-release tag without `-` (e.g. beta1) |
| `metadata` | String | Metadata tag without `+` (e.g. as4at5dd) |
| `package` | String | Package version for NuGet with suffix if defined (e.g. 1.2.3-beta1) |
| `is_valid` | String | `true` if the version tag was valid and could be processed, otherwise `false` |
| `is_prerelease` | String | `true` if the version is a pre-release (suffix defined), otherwise `false` |
| `is_release` | String | `true` if the version is a release (no suffix defined), otherwise `false` |## Notes
- This action requires `pwsh` to actually be available and on PATH of the runner - which
is the case for all GitHub-provided runner VMs; for your own runners you need to take care of that yourself.
- This action is a [`composite` action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action).## License
This action is licensed under [MIT license](LICENSE).