|
| 1 | +name: Generate Changelog |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write # allow git push / branch creation |
| 5 | + pull-requests: write # allow creating/updating PRs |
| 6 | + issues: write # allow label creation |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Release version (e.g. 4.0.0-rc.1)' |
| 13 | + required: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + changelog: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v3 |
| 21 | + with: |
| 22 | + fetch-depth: 0 # auto-changelog sees full history |
| 23 | + |
| 24 | + - name: Set up Node.js |
| 25 | + uses: actions/setup-node@v3 |
| 26 | + with: |
| 27 | + node-version: '16' # the preferred LTS |
| 28 | + |
| 29 | + - name: Install auto-changelog |
| 30 | + run: npm install auto-changelog --no-save |
| 31 | + |
| 32 | + - name: Update version in package.json |
| 33 | + run: npm version ${{ github.event.inputs.version }} --no-git-tag-version |
| 34 | + |
| 35 | + - name: Generate CHANGELOG.md |
| 36 | + run: npm run version |
| 37 | + # assumes package.json has: |
| 38 | + # "scripts": { "version": "auto-changelog -p && git add CHANGELOG.md" } |
| 39 | + |
| 40 | + - name: Create Pull Request for changelog |
| 41 | + uses: peter-evans/create-pull-request@v4 |
| 42 | + with: |
| 43 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + # head branch to create: |
| 46 | + branch: changelog/${{ github.event.inputs.version }} |
| 47 | + base: main |
| 48 | + |
| 49 | + # changelog commit author |
| 50 | + author: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>" |
| 51 | + |
| 52 | + # only include these two files in the commit |
| 53 | + add-paths: | |
| 54 | + package.json |
| 55 | + CHANGELOG.md |
| 56 | +
|
| 57 | + commit-message: "chore: update changelog for ${{ github.event.inputs.version }}" |
| 58 | + title: "chore: update changelog for ${{ github.event.inputs.version }}" |
| 59 | + body: | |
| 60 | + This PR was generated by GitHub Actions to update the CHANGELOG for release **${{ github.event.inputs.version }}**. |
| 61 | + labels: documentation |
0 commit comments