-
Notifications
You must be signed in to change notification settings - Fork 11
53 lines (45 loc) · 1.55 KB
/
Copy pathrelease.yml
File metadata and controls
53 lines (45 loc) · 1.55 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
name: Semantic Release
on:
workflow_dispatch:
pull_request:
types: [closed]
branches:
- master
jobs:
release:
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
concurrency:
group: release
cancel-in-progress: true
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Python Semantic Release
# Adjust tag with desired version if applicable. Version shorthand
# is NOT available, e.g. vX or vX.X will not work.
uses: python-semantic-release/python-semantic-release@v10.5.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog: true
- name: Cleanup old pre-release tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch --tags
# 筛选出所有带连字符 '-' 的标签 (通常是 v1.0.0-beta.1 这类)
# 并排除掉最新的 5 个,防止正在发布的被删掉
tags_to_delete=$(git for-each-ref --sort=-taggerdate --format '%(refname:short)' refs/tags | grep "-" | tail -n +6)
for tag in $tags_to_delete; do
echo "Deleting pre-release tag: $tag"
git push origin --delete $tag || true
git tag -d $tag || true
done
- name: Delete Draft Releases
uses: hugo19941994/delete-draft-releases@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}