forked from Aakvatech-Limited/HMS_TZ
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (43 loc) · 1.27 KB
/
release.yml
File metadata and controls
54 lines (43 loc) · 1.27 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
53
54
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Generate Changelog
run: |
python - <<'PY'
import subprocess
def sh(*args):
return subprocess.check_output(list(args), text=True).strip()
try:
prev_tag = sh('git', 'describe', '--tags', '--abbrev=0', 'HEAD^')
rev_range = f"{prev_tag}..HEAD"
except Exception:
rev_range = 'HEAD'
commits = sh('git', 'log', '--pretty=format:%s', rev_range).splitlines()
changelog = '## Changes\n\n' + ''.join(f'- {c}\n' for c in commits if c)
with open('CHANGELOG_RELEASE.md', 'w', encoding='utf-8') as f:
f.write(changelog)
PY
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG_RELEASE.md
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}