chore: automate tag on release (#8366)
This commit is contained in:
parent
b2e82eece6
commit
f5f8d16947
6
.github/workflows/publish-on-tag.yml
vendored
6
.github/workflows/publish-on-tag.yml
vendored
@ -8,7 +8,8 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions: read-all
|
permissions:
|
||||||
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -40,8 +41,7 @@ jobs:
|
|||||||
needs: publish
|
needs: publish
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
actions: read|write
|
contents: write
|
||||||
contents: read|write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -6,7 +6,7 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read|write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
30
.github/workflows/tag-on-release.yml
vendored
Normal file
30
.github/workflows/tag-on-release.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
name: tag-on-release
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
branches:
|
||||||
|
- 'releases/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tag:
|
||||||
|
if: github.event.pull_request.merged == true
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Get version
|
||||||
|
id: get-version
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=VERSION::$(jq -r .version ./package.json)
|
||||||
|
- name: Generate latest changelog
|
||||||
|
run: node utils/get_latest_changelog.js > ${{ steps.get-version.outputs.VERSION }}-CHANGELOG.txt
|
||||||
|
- name: Tag and release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
name: ${{ steps.get-version.outputs.VERSION }}
|
||||||
|
tag_name: v${{ steps.get-version.outputs.VERSION }}
|
||||||
|
body_path: ${{ steps.get-version.outputs.VERSION }}-CHANGELOG.txt
|
34
utils/get_latest_changelog.js
Executable file
34
utils/get_latest_changelog.js
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const { createReadStream } = require('fs');
|
||||||
|
const { join } = require('path');
|
||||||
|
const { createInterface } = require('readline');
|
||||||
|
|
||||||
|
const lines = [];
|
||||||
|
let isRecording = false;
|
||||||
|
|
||||||
|
for await (const line of createInterface({
|
||||||
|
input: createReadStream(join(__dirname, '../CHANGELOG.md'), {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
}),
|
||||||
|
})) {
|
||||||
|
if (line.startsWith('## ')) {
|
||||||
|
if (!isRecording) {
|
||||||
|
isRecording = true;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isRecording) {
|
||||||
|
lines.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lines.length === 0) {
|
||||||
|
throw new Error('Latest changelog should be non-empty.');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(lines.join('\n').trim());
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user