Generate Changelog #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate Changelog | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version (e.g. 4.0.0-rc.1)' | |
required: true | |
jobs: | |
changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # so auto-changelog sees full history | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' # or your preferred LTS | |
- name: Install auto-changelog | |
run: npm install auto-changelog --no-save | |
- name: Create changelog branch | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b changelog/${{ github.event.inputs.version }} | |
- name: Update version in package.json | |
run: npm pkg set version "${{ github.event.inputs.version }}" | |
- name: Generate CHANGELOG.md | |
run: npm run version | |
# assumes your package.json has: | |
# "scripts": { "version": "auto-changelog -p && git add CHANGELOG.md" } | |
- name: Commit version & changelog | |
run: | | |
git add package.json CHANGELOG.md | |
git commit -m "chore: update changelog for ${{ github.event.inputs.version }}" | |
- name: Push branch and create PR | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "chore: update changelog for ${{ github.event.inputs.version }}" | |
title: "chore: update changelog for ${{ github.event.inputs.version }}" | |
body: | | |
This PR was generated by GitHub Actions to update the CHANGELOG for release \ | |
**${{ github.event.inputs.version }}**. | |
head: changelog/${{ github.event.inputs.version }} | |
base: main | |
labels: changelog |