-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (43 loc) · 1.33 KB
/
Copy pathrelease.yaml
File metadata and controls
52 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Create GitHub Release
on:
release:
types: [created]
workflow_dispatch:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get tag name
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Generate release notes
id: release_notes
uses: actions/github-script@v7
with:
script: |
const tag = process.env.GITHUB_REF_NAME;
const { data: commits } = await github.rest.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 20,
});
const notes = commits.map(c => {
const msg = c.commit.message.split('\n')[0];
const sha = c.sha.substring(0, 7);
const author = c.commit.author.name;
return `- ${msg} (${sha}, by ${author})`;
}).join('\n');
return notes;
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: Release ${{ steps.tag.outputs.tag }}
body: ${{ steps.release_notes.outputs.result }}