GitHub Actions provider powerful configurations. You can customize the event triggers to run a job to your own needs.
We use a handy workflow to publish our packages to the GitHub Package Registry in our repositories. The “publish workflow” only runs when creating a new tag in a repository.
GitHub Actions Series Overview
- Getting Started With Node.js
- Create a Testing Matrix
- Using MongoDB
- Using Redis
- Using MongoDB Replica Sets
- Run on Pull Request
- Customize the Job Name
- Run a Workflow When Creating a Tag
- Testing Against an Exact Node.js Version
- Trigger Builds on Schedule (Cron)
- How to Test Lerna Monorepos
- How to Add Comments in YAML Files
- Clone Another Repository
- Run on Push or Pull Request, but Not Both
- Limit Concurrency and Cancel In-Progress Jobs
- Test Against the Latest Node.js Version
Run Workflow for New Tags
GitHub offers a package registry for a variety of modules: NPM, Docker, Gradle, Maven, NuGet, and RubyGems. This registry in the Node.js ecosystem comes with extra effort for package authors because you need to publish to different registries, NPM and GitHub.
You can automate the publishing process on GitHub’s side by using an Actions workflow. Restrict the workflow to only run when a new tag is pushed to the repository. Then, you can run the publishing process of your package to make the new version available in the GitHub Package Registry.
Here’s a workflow configuration that only runs when creating a new tag:
name: Publish in GitHub Package Registry on: push: tags: - '*' jobs: build: …
You can even customize the publishing process with tags to ignore. For example, if you’re preparing the new major release of your project, you may want to skip any public releases. Use the
tags-ignore pattern to not run workflows:
name: Publish in GitHub Package Registry on: push: tags: - '1.*' tags-ignore: - '2.*' jobs: build: …
This workflow configuration publishes new versions for the
1.x release line and skips the package release for
Find an example GitHub Actions workflow in the
supercharge/strings repository on GitHub. The linked workflow only runs when pushing a new tag to the repository.