-
Notifications
You must be signed in to change notification settings - Fork 5
88 lines (77 loc) · 2.66 KB
/
release.yml
File metadata and controls
88 lines (77 loc) · 2.66 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Releases
on:
workflow_call:
outputs:
release_id:
description: "Tag name to use of release, empty if not needed"
value: ${{ jobs.prepare-release.outputs.release_id }}
permissions:
contents: read
jobs:
prepare-release:
runs-on: ubuntu-latest
permissions:
contents: write
security-events: write
outputs:
release_id: ${{ steps.release_info.outputs.tag }}
steps:
- uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.13'
- name: Determine release info
id: release_info
run: |
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
BRANCH="${GITHUB_HEAD_REF}"
else
BRANCH="${GITHUB_REF#refs/heads/}"
fi
if [[ "$BRANCH" == "main" ]]; then
TAG="latest"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
else
TAG=""
fi
echo "tag=$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Update latest tag
if: ${{ steps.release_info.outputs.tag == 'latest' }}
uses: EndBug/latest-tag@2b1b3e384a1ca26a4fb5819f602a1ef51b4968f3
with:
ref: latest
description: Last state in main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate release notes
if: ${{ steps.release_info.outputs.tag }}
id: notes
run: |
python script/create_release_notes.py
- name: Delete existing release
if: ${{ steps.release_info.outputs.tag == 'latest' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.release_info.outputs.tag }}
run: |
if gh release view "$TAG" >/dev/null 2>&1; then
gh release delete "$TAG" --yes
else
echo "No release found for $TAG."
fi
- name: Create release
if: ${{ steps.release_info.outputs.tag }}
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v2.5.0
with:
tag_name: ${{ steps.release_info.outputs.tag }}
name: ${{ steps.release_info.outputs.tag }}
body_path: release_notes.txt
draft: true
files: LICENSE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}