-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 1.88 KB
/
release.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Create Release
on:
push:
branches:
- main # Trigger on push to the main branch
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2 # Checkout the repository
- name: Set up Git
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Create Tag
id: create_tag
run: |
TAG="v$(date +'%Y.%m.%d-%H.%M.%S')"
git tag $TAG
git push origin $TAG
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Generate Release Notes
id: generate_notes
uses: actions/github-script@v6
with:
script: |
const { context, github } = require('@actions/github');
const owner = context.repo.owner;
const repo = context.repo.repo;
const tag = context.ref.replace('refs/tags/', '');
const { data: commits } = await github.repos.listCommits({
owner,
repo,
sha: tag,
per_page: 100
});
let body = 'Changes in this Release\n';
for (const commit of commits) {
body += `- ${commit.commit.message}\n`;
}
return body;
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub token provided by Actions
with:
tag_name: ${{ steps.create_tag.outputs.TAG }} # Use the created tag name
release_name: Release ${{ steps.create_tag.outputs.TAG }} # Name the release
body: ${{ steps.generate_notes.outputs.result }} # Use generated release notes
draft: false
prerelease: false