Introduction
Maintaining a well-organized changelog, releasing a new version of an , then publishing it into a package repository. All these are tedious, repetitive chores that can be automated to save valuable developer time.
This tutorial will teach you how to set up tools that do just that. You will walk through the following steps:
- Set up a Github Action to release a new version
- Publish new SDK versions:
- Create an npm account
- Store an npm API token securely in GitHub
- Set up a GitHub Action to auto-publish new SDK versions
Prerequisites
This tutorial assumes that you have already developed and pushed a functional SDK into a GitHub repository.
Release a new version
Owner + Developer: Set up a Github Action to release new SDK versions
To avoid the tedious task of updating the changelog and releasing new versions manually, we recommend using the Github Action . This Action keeps track of code changes since the last release and maintains a pull request with changelog and version changes based on your commit messages. When the time is right to release a new SDK version, all you need to do is merge the pull request.
Follow these steps to set up the Action:
Owner
- In your GitHub repository, go to Settings > Actions > General and check the option âAllow GitHub Actions to create and approve pull requestsâ is checked.
Developer
- In the root folder of your project, create a directory .github/workflows/. This is where GitHub Action configuration files should always be stored.
- In this directory, create a new configuration YAML file. Name it release-please.yml.
- Copy the following code into your configuration file: Â
# This workflow opens and updates a pull request with a new package version
# based on code changes.
# The pull request updates the version in package.json, updates the changelog# and creates release tags.on: push: branches: - masterpermissions: contents: write pull-requests: writename: release-pleasejobs: release-please: runs-on: ubuntu-22.04 steps: - uses: google-github-actions/release-please-action@v3.7.10 with: release-type: node package-name: release-please-action pull-request-title-pattern: "chore(release): ${version}"