How do I use semantic-version to create a new release with the correct new tag? #191421
-
🏷️ Discussion TypeQuestion 💬 Feature/Topic AreaActions Runner Discussion DetailsWe're working on changing how we deploy to different Windows servers, from our GitHub Self-hosted Runner Windows server. Recently I came across Paul Hatch's Semantic-version v5.4.0. This is what I believe we need to use; however, I am struggling to make it work. I've search for examples and have come across one on Medium.com which looked promising, but I still don't get it. I'm starting how simple, but still aren't getting it. Here's what I've got so far: name: Semantic Versioning Workflow
on:
workflow_dispatch: # manual
jobs:
Find-Version-Numbers:
runs-on: self-hosted
steps:
- name: Checkout files
uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Determine semantic version
id: tagger
uses: paulhatch/semantic-version@v5.4.0
with:
tag_prefix: 'v'
major_pattern: 'MAJOR'
minor_pattern: 'MINOR'
version_format: 'v${MAJOR}.${MINOR}.${PATCH}'
- name: Print Semantic Version
run: |
echo "Semantic Version: ${{ steps.tagger.outputs.version }}"That last step, Print Semantic Version just prints "v..", which isn't helpful. I could use help, please. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Hi @Rod-at-DOH, you are incredibly close! The issue is simply a case-sensitivity typo in your version_format string. The action expects the template variables to be strictly lowercase (${major}, ${minor}, ${patch}). Because you used uppercase, the action didn't recognize them, replaced them with nothing, and left you with just the literal v and the dots (which is why you see v..). Also, since you have already set tag_prefix: 'v', you don't need to hardcode another v inside the version_format string, otherwise you might end up with double v's (like vv1.0.0) when using tag outputs. Here is the corrected step: YAML (If this fixes your workflow, please Mark as Answer.) |
Beta Was this translation helpful? Give feedback.
-
|
name: Versioning on: jobs: |
Beta Was this translation helpful? Give feedback.
-
|
The problem is case sensitivity in version_format. Use lowercase ${major}.${minor}.${patch} instead of uppercase. Also remove the extra v since tag_prefix: 'v' already adds it. Corrected: |
Beta Was this translation helpful? Give feedback.
Hi @Rod-at-DOH, you are incredibly close! The issue is simply a case-sensitivity typo in your version_format string.
The action expects the template variables to be strictly lowercase (${major}, ${minor}, ${patch}). Because you used uppercase, the action didn't recognize them, replaced them with nothing, and left you with just the literal v and the dots (which is why you see v..).
Also, since you have already set tag_prefix: 'v', you don't need to hardcode another v inside the version_format string, otherwise you might end up with double v's (like vv1.0.0) when using tag outputs.
Here is the corrected step:
YAML
- name: Determine semantic version
id: tagger
uses: paulhatch/semantic-versio…