Using GitHub actions to release plugins

If you’re like me, and you some times worry whether you have uploaded the right version of the files to a GitHub release, this might help you a little!

I’m using GitHub actions to automate this. My workflow looks like this:

  1. Write code, fix stuff, etc. and commit my changes, pushing them to GitHub as needed.
  2. When I’m ready to release a new version,
    1. Update the manifest.json with the right version, commit and push it.
    2. use git tag <version number>, e.g. <git tag 1.0.0 using semantic versioning.
  3. Push the new tag to GitHub git push origin --tags
  4. GitHub takes care of the rest

I want to use this, what do I do?

Here’s how I’m using it in my nldates-obsidian plugin. To add this to your repository just copy the file and save it in the .github/workflows/ path, i.e. your should have a .github/workflows/releases.yml. file. Note that the .github folder is a hidden one!

Note that if you are using styles.css, you’ll need to add that file in line 29, and uncomment the last few lines.


Building on this base I’ve created my own version.
It doesn’t require you to update your plugin name, as it just uses the name of the repo to create the zip file (I want to do as little work as possible :sweat_smile:).
I eventually want to update it to somehow grab release notes and put them in the release. Still thinking about how I want to manage that…

I’ve also created a second script that you can trigger manually within the github interface to bump the version number (major, minor or patch — you decide) and push the updates to the manifest file and create the git tag for you, which will then trigger the release workflow.

There are two catches:

  1. You have to provide a Personal Access Token in a GitHub Secret called PAT — this is so the push will trigger the second workflow. It doesn’t get triggered when you use secrets.GITHUB_TOKEN
  2. You should probably provide an .npmrc file in the root of your repo which has tag-version-prefix = "" to get rid of the v from the start of the version number
    (I do want to get rid of this requirement now I have half an idea what I’m doing. I shouldn’t need to rely on NPM to do the bumping for me)
1 Like