GitHub Actions is GitHub’s continuous integration service
Semantic-release supports many continuous integration tools that allow us to set up changelog and version numbers.
Here we will use GithubAction and Semantic-release to build our Github to automatically create Changelong. GithubAcion can also do more things, which will not be introduced here, you can learn by yourself.
Add GITHUB_TOKEN to the Github project
Refer to this article
Remember your GITHUB_SECRETS name, which will be used later in the script. For example, mine is ACCESS_TOKEN. If you want to publish the NPM package in Action, you will need to configure NPM_TOKEN
Added in the project. / a lot/workflows/the yml
Name: Release on: Push: Branches: -master Jobs: Release: name: Release runs-on: Ubuntu-18.04 Steps: -name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Setup Node uses: actions/setup-node@v1 with: node-version: 16 - name: Install run: yarn - name: Release env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: npx semantic-releaseCopy the code
My project uses YARN, the branch must be master, GITHUB_TOKEN write the TOKEN name you added in the previous step, if you do not understand the parameter, please refer to the link at the beginning of the article
Add the configuration file.releaserc to the project
{
"branch": "master",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
Copy the code
Finally, we can see the workflows process in github’s Actions. Finally, we can check that the Master branch has successfully added Changelog.md and automatically tagged a tag for us
The project address