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.
In this tutorial, you will learn how to set up tools that do just that. You will walk through the following steps:
- Create a Packagist account and register your
- Store your Packagist username and API token securely in GitHub
- Set up a Github Action to release and publish a new version
Prerequisities
This tutorial assumes that you have already developed a functional SDK and pushed it into a GitHub repository.
Owner: Create a Packagist account and register your SDK
Before publishing your SDK for the first time, you need to create a Packagist account . Then choose a suitable name for your SDK that follows the . Finally, you can to Packagist by entering the URL of your public GitHub repository.
Owner: Set up credentials
In order to automatically publish an SDK to Packagist on your behalf, GitHub needs access to your Packagist username and API token. You can securely store these credentials directly in GitHub.
- Go to the . Locate your username at the top of the page. Then click on the Show API Token button and copy the token.
- Go to the GitHub page of your project. Go to Settings > Security > Secrets and Variables > Actions and click on the New repository secret button.
- Enter `PACKAGIST_USERNAME` in the Name field.
- Enter your Packagist username in the Secret field. Click on the Add secret button to confirm.
- Create another secret (New repository secret). This time, enter the values `PACKAGIST_TOKEN` and the token you copied in Step 1 into the Name and Secret fields, respectively. Add this secret.
Release and publish a new version
Owner + Developer: Set up a Github Action to release a new SDK version
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.
The following workflow will also publish a new version of your SDK into Packagist after you release it.