Tag and Version Management in GitHub

Is there a way to automate tags for commits & versions for build artifacts, without hard coding them in GitHub actions? Please help with some documentation & examples.

A thing I have implemented is choosing tags for a container image based on ${{ github.ref }}, by matching branch names and tag patterns (see the README):

Another thing I’ve seen people mention on the forum is extracting a version number from a specific file, and creating a tag/release if it changed. I don’t have an example for that at hand, though.

Thanks a lot once again for the prompt reply. In your case, you are using a Python script and inside that you are github.ref and some regular expressions to manipulate the version. Due to Python script, we need to install python as part of our action and write custom code / maintain it. I am trying to avoid it. In my case, let’s say there is an initial tag v1.0.0. When my action runs, it should set this tag to v1.0.1 or v1.1.0 or v2.0.0 (for example) based on some input parameters like whether it is a major or minor or patch release or read these keywords from the commit preferably.

You can use whichever language you prefer, but yes, if you can’t find a pre-made action that does what you’d like you’ll have to write your own code. Which you could share between repositories as an action of your own (if that’s what you need).

Python is already installed on the GitHub hosted runners so there’s no need to install anything to use a script like mine. And it happens to be my preference. :wink:

1 Like