ci: automatically update version and changelog for Renovate's PRs (#206)
This commit is contained in:
parent
7a7a39c67d
commit
a24affd6bc
5 changed files with 70 additions and 3 deletions
19
.github/scripts/update-changelog.js
vendored
Normal file
19
.github/scripts/update-changelog.js
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
module.exports = (version, prUrl) => {
|
||||||
|
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
|
||||||
|
const changelogLines = changelog.split('\n');
|
||||||
|
const lastChangeIndex = changelogLines.findIndex((line) => line.startsWith('## ['));
|
||||||
|
|
||||||
|
const textToAppend = `
|
||||||
|
## [${version}] - ${new Date().toISOString().split('T')[0]}
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
- chore(deps): update dependencies ([details](${prUrl}))
|
||||||
|
`.trim();
|
||||||
|
|
||||||
|
changelogLines.splice(lastChangeIndex, 0, textToAppend + '\n');
|
||||||
|
|
||||||
|
fs.writeFileSync('CHANGELOG.md', changelogLines.join('\n'));
|
||||||
|
};
|
||||||
38
.github/workflows/dependency-update-changelog.yml
vendored
Normal file
38
.github/workflows/dependency-update-changelog.yml
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
name: Modify changelog for dependency updates
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
if: github.event.label.name == 'dependencies' && github.repository == 'KonradSzwarc/devscard'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Get project information
|
||||||
|
id: projectinfo
|
||||||
|
uses: gregoranders/nodejs-project-info@v0.0.19
|
||||||
|
- name: Get next possible versions
|
||||||
|
id: semvers
|
||||||
|
uses: WyriHaximus/github-action-next-semvers@v1
|
||||||
|
with:
|
||||||
|
version: ${{ steps.projectinfo.outputs.version }}
|
||||||
|
- name: Update package.json version
|
||||||
|
uses: reedyuk/npm-version@1.1.1
|
||||||
|
with:
|
||||||
|
version: ${{ steps.semvers.outputs.patch }}
|
||||||
|
- name: Update CHANGELOG.md
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const script = require('.github/scripts/update-changelog.js');
|
||||||
|
const version = '${{ steps.semvers.outputs.patch }}';
|
||||||
|
const prUrl = '${{ github.event.pull_request.url }}';
|
||||||
|
|
||||||
|
script(version, prUrl);
|
||||||
|
- name: Commit changes
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -2,12 +2,22 @@
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.0.4] - 2023-02-22
|
||||||
|
|
||||||
|
### Workflow
|
||||||
|
|
||||||
|
- ci: automatically update project version and changelog for Renovate's PRs
|
||||||
|
|
||||||
## [0.0.3] - 2023-02-21
|
## [0.0.3] - 2023-02-21
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
- chore(deps): update dependencies ([details](https://github.com/KonradSzwarc/devscard/pull/202))
|
- chore(deps): update dependencies ([details](https://github.com/KonradSzwarc/devscard/pull/202))
|
||||||
|
|
||||||
## [0.0.2] - 2023-02-16
|
## [0.0.2] - 2023-02-16
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
- chore(deps): update dependencies ([details](https://github.com/KonradSzwarc/devscard/pull/201))
|
- chore(deps): update dependencies ([details](https://github.com/KonradSzwarc/devscard/pull/201))
|
||||||
|
|
||||||
## [0.0.1] - 2023-02-08
|
## [0.0.1] - 2023-02-08
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "devscard",
|
"name": "devscard",
|
||||||
"version": "0.0.2",
|
"version": "0.0.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "devscard",
|
"name": "devscard",
|
||||||
"version": "0.0.2",
|
"version": "0.0.4",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@floating-ui/dom": "1.2.1",
|
"@floating-ui/dom": "1.2.1",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "devscard",
|
"name": "devscard",
|
||||||
"description": "Template for creating a comprehensive virtual CV for developers.",
|
"description": "Template for creating a comprehensive virtual CV for developers.",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14",
|
"node": ">=14",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue