-
-
Notifications
You must be signed in to change notification settings - Fork 3
105 lines (87 loc) · 3.07 KB
/
Copy pathrelease.yml
File metadata and controls
105 lines (87 loc) · 3.07 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Reusable workflow
#
# The release name and version are read from pyproject.toml.
# No project-specific repository variables or additional secrets are required.
name: Release
on:
workflow_dispatch:
push:
paths:
- "pyproject.toml"
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
if: github.ref_name == github.event.repository.default_branch
steps:
- name: Checkout repo
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Read project metadata
id: metadata
run: |
python - <<'PY' >> "$GITHUB_OUTPUT"
import re
import tomllib
with open("pyproject.toml", "rb") as handle:
data = tomllib.load(handle)
project = data.get("project", {})
version = str(project.get("version", "")).strip()
name = str(project.get("name", "")).strip()
display_name = str(
data.get("tool", {}).get("comfy", {}).get("DisplayName") or name
).strip()
if not name:
raise SystemExit("[project].name is missing in pyproject.toml")
if not re.fullmatch(r"\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?", version):
raise SystemExit(f"Invalid semantic version in pyproject.toml: {version}")
print(f"project_name={name}")
print(f"display_name={display_name}")
print(f"version={version}")
print(f"tag=v{version}")
PY
- name: Check if tag for this version already exists
id: tag_check
run: |
TAG="${{ steps.metadata.outputs.tag }}"
git fetch --force --tags
if git rev-parse --verify --quiet "refs/tags/$TAG" >/dev/null; then
echo "Tag $TAG already exists. Skipping release."
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Build release notes
id: notes
if: steps.tag_check.outputs.exists != 'true'
run: |
CURRENT_TAG="${{ steps.metadata.outputs.tag }}"
PREVIOUS_TAG="$(git tag --list 'v[0-9]*' --sort=-v:refname | grep -vx "$CURRENT_TAG" | head -n 1 || true)"
if [ -n "$PREVIOUS_TAG" ]; then
RANGE="$PREVIOUS_TAG..HEAD"
HEADER="Changes since $PREVIOUS_TAG"
else
RANGE="HEAD"
HEADER="Initial release"
fi
{
echo "body<<EOF"
echo "## $HEADER"
echo
git log --pretty=format:"- %s (%h)" "$RANGE"
echo
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
if: steps.tag_check.outputs.exists != 'true'
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.metadata.outputs.tag }}
name: ${{ steps.metadata.outputs.display_name }} ${{ steps.metadata.outputs.tag }}
body: ${{ steps.notes.outputs.body }}
generate_release_notes: true