I’ve really fallen in love with github actions. They make allow you to play around with continuos integration and enable so much automation for your personal projects.
If you’ve ever wanted to make automatic releases on github, look no further.
Step 1: Create the workflow file
Create a new file at this path
If you’re using vscode you can simply click new file and paste that path in. If you’re going bare with a terminal have this:
Step 2: The Workflow itself
But first TL;DR: We’re using Zip Release
And heres the code:
The long version. This action will only trigger when we push tags to the repository. Once triggered, it will first checkout the master(or main) branch using the “native” action for checkout. Afterwards it will zip using thedoctor0’s Zip Release to zip up the contents of the repository and use the Release Action to create a new release using the newly created zip file as artifact.
You could conceivably create multiple zips or other types of packages (e.g. jars) to use as artefacts.
An example of artefacts is the releases of my personal minecraft [texture pack](https://github.com/metruzanca/minecraft-xpd-texture-pack
) where the pack is distributed as a .zip file.
In case you’re also wondering what
secrets.GITHUB_TOKEN
is, I’ve asked myself that too. Basically its a token github can use within the action to authenticate as “the repository” in order to perform actions within the repository e.g. creating new releases. You can read more over at the Docs.
Step 3: Creating new releases
With the workflow created, unlike in my other guide for a gh-pages deploy pipeline which was triggered by pushing to master, meanwhile this workflow is triggered by pushing tags.
Whats a tag? Its basically a bookmark to a certain commit. Allowing you to easily say checkout tags/v1 or tags/v1.1
TL;DR
Now, theres a good chance that you’d never touched tags. So heres a quick guide:
To view your tags (q to exit as per usual)
Creating Annotated tags:
Tags come in two flavours, normal tags and annotated tags. Annotated tags are best practice as they contain a lot of information (such as tag author), however you can use normal tags as temporary tags.
This is akin to making a commit, it stays local until explicitly pushing to remote. To do that we simply need to push the tags. git push
will push everything but if you only want to publish tags theres a flag for that.
The —tags flag is also available on fetch
Step 4: Profit
If everything is setup properly, pushing tags should trigger a github action and create your release package.