question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove `v` from tags

See original GitHub issue

I think the action should have the option to remove the v from git tags that are semver. And I think it should be the default behavior.

Git tag: v1.1.1 -> Docker tag: 1.1.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

8reactions
vandmocommented, Sep 8, 2021

Posting a complete solution for any Googlers that end up here. I think this is a little less magic than other solutions that I have found.

name: Release
on:
  push:
    tags:
    - 'v*'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v1

    - name: Login to Docker Hub
      uses: docker/login-action@v1
      with:
        username: ${{secrets.DOCKERHUB_USERNAME}}
        password: ${{secrets.DOCKERHUB_TOKEN}}

    - name: Set Versions
      uses: actions/github-script@v4
      id: set_version
      with:
        script: |
          const tag = context.ref.substring(10)
          const no_v = tag.replace('v', '')
          const dash_index = no_v.lastIndexOf('-')
          const no_dash = (dash_index > -1) ?  no_v.substring(0, dash_index) : no_v
          core.setOutput('tag', tag)
          core.setOutput('no-v', no_v)
          core.setOutput('no-dash', no_dash)

    - name: Build and Push
      uses: docker/build-push-action@v2
      with:
        push: true
        tags: |
          ${{secrets.DOCKERHUB_USERNAME}}/google-java-format:latest
          ${{secrets.DOCKERHUB_USERNAME}}/google-java-format:${{steps.set_version.outputs.no-dash}}
1reaction
SuperSandro2000commented, May 13, 2020

I was mistakenly thinking about tagging releases on got. NVM.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Github action how to remove starting 'v' from variable
I have an workflow to publish nuget package on a release event, but i'm not able to strip the 'v' char from tagname....
Read more >
How To Delete Local and Remote Tags on Git - devconnected
In order to delete a remote Git tag, use the “git push” command with the “–delete” option and specify the tag name. $...
Read more >
For version as git tag: use annotated tag, not 'v' prefix
A common practice is to prefix tags for version with 'v' like v1.0.0 , but I don't understand why? It is not to...
Read more >
How to delete a git tag - CodeX Team
So you need to use console git tool to delete local and remote tags. # Define tag name variable TAG=v0.0.2 # Delete local...
Read more >
Can't delete a git TAG | Sourcetree For Mac - Jira
git -c core.quotepath=false push -v --tags origin master:master Pushing to https://ajaynz@github.com/ajaynz/TEST.git POST git-receive-pack (287 bytes) To ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found