https://github.com/barbiecue/git-tags-with-gradle
A minimalistic example on how to create git tags via Gradle in your pipeline
https://github.com/barbiecue/git-tags-with-gradle
git git-tag gradle pipeline
Last synced: 5 months ago
JSON representation
A minimalistic example on how to create git tags via Gradle in your pipeline
- Host: GitHub
- URL: https://github.com/barbiecue/git-tags-with-gradle
- Owner: BarbieCue
- Created: 2024-09-14T11:48:32.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-25T13:47:57.000Z (over 1 year ago)
- Last Synced: 2025-04-07T01:13:53.776Z (about 1 year ago)
- Topics: git, git-tag, gradle, pipeline
- Homepage:
- Size: 143 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git tags with Gradle
People often want to create git tags
out of their pipelines.
For example a git tag with the release version
should be set during the publication of a release.
This is a minimalistic example on how to
create git tags using Gradle.
- **A simple Gradle task**
- **6 lines of code**
- **No external dependencies**
[*build.gradle.kts*](build.gradle.kts)
```kotlin
group = "org.example"
version = "1.0.0"
tasks.register("gitTagVersion") {
doLast {
exec { commandLine("git", "tag", "-a", version, "-m", "Release version $version") }
exec { commandLine("git", "push", "origin", "tag", version) }
}
}
```
*Your pipeline (pseudocode)*
```yml
...
steps:
- name: build, test, other stuff ...
...
# And here we go:
- name: Publish release version
script: ./gradlew publish
- name: Git tag version
script: ./gradlew gitTagVersion
```
That is all you need.
**Thoughts**
Both steps, publishing and git tagging,
can also be executed in parallel.
However, there is a risk that publishing
will fail and the tag will then be
created incorrectly.