forked from Proact0/act-operator
-
Notifications
You must be signed in to change notification settings - Fork 5
232 lines (200 loc) · 7.13 KB
/
release.yml
File metadata and controls
232 lines (200 loc) · 7.13 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Release
run-name: Release act-operator v${{ github.run_number }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
dry-run:
description: "Dry run (skip PyPI publish)"
type: boolean
default: false
env:
# Match pyproject.toml: requires-python = ">=3.11"
PYTHON_VERSION: "3.11"
# Directory containing pyproject.toml (act_operator/)
WORKING_DIRECTORY: "act_operator"
# Match pyproject.toml: name = "act-operator"
PKG_NAME: "act-operator"
jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-version.outputs.version }}
tag: ${{ steps.check-version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
- name: Extract version
id: check-version
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
VERSION=$(grep -m 1 '^__version__' act_operator/__init__.py | cut -d '"' -f 2)
TAG="v${VERSION}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "📦 Building ${{ env.PKG_NAME }} v$VERSION"
- name: Check if tag already exists
run: |
TAG="${{ steps.check-version.outputs.tag }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "❌ Tag $TAG already exists!"
echo "Please bump version in act_operator/__init__.py"
exit 1
fi
echo "✅ Tag $TAG is available"
- name: Build distribution
run: uv build
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Verify package
working-directory: ${{ env.WORKING_DIRECTORY }}
run: uvx twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: ${{ env.WORKING_DIRECTORY }}/dist/
retention-days: 7
publish:
name: Publish to PyPI 🚀
needs: build
if: ${{ !inputs.dry-run }}
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/${{ env.PKG_NAME }}
permissions:
id-token: write # Required for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
print-hash: true
github-release:
name: Create GitHub Release 🏷️
needs:
- build
- publish
if: ${{ !inputs.dry-run && !failure() && !cancelled() }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Generate release notes
id: release-notes
env:
TAG: ${{ needs.build.outputs.tag }}
VERSION: ${{ needs.build.outputs.version }}
run: |
# Find previous release tag (exclude current); allow pre-release (a/b/rc) per pyproject dynamic version
PREV_TAG=$(git tag --sort=-v:refname | grep -P "^v[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?$" | grep -v "^$TAG$" | head -1 || echo "")
{
echo 'body<<EOF'
echo "### 📝 Release Note"
echo
# Get commits since last tag
COMMITS=$(git log --format="- %s" "$PREV_TAG"..HEAD -- . 2>/dev/null | grep -vE "^- (Merge|merge)" || true)
# Categorize by conventional commits
FEAT=$(echo "$COMMITS" | grep -E "^- feat" || true)
FIX=$(echo "$COMMITS" | grep -E "^- fix" || true)
DOCS=$(echo "$COMMITS" | grep -E "^- docs" || true)
CHORE=$(echo "$COMMITS" | grep -E "^- (chore|ci|build|refactor)" || true)
OTHER=$(echo "$COMMITS" | grep -vE "^- (feat|fix|docs|chore|ci|build|refactor)" | head -10 || true)
if [ -n "$FEAT" ]; then
echo "#### ✨ New Features"
echo "$FEAT"
echo
fi
if [ -n "$FIX" ]; then
echo "#### 🐛 Bug Fixes"
echo "$FIX"
echo
fi
if [ -n "$DOCS" ]; then
echo "#### 📚 Documentation"
echo "$DOCS"
echo
fi
if [ -n "$CHORE" ]; then
echo "#### 🔧 Maintenance"
echo "$CHORE"
echo
fi
if [ -n "$OTHER" ]; then
echo "#### 📝 Other"
echo "$OTHER"
echo
fi
# If no commits found
if [ -z "$FEAT$FIX$DOCS$CHORE$OTHER" ]; then
echo "- Minor improvements and updates"
echo
fi
echo "---"
echo
echo "### 🔗 Links"
echo
echo "- [📦 PyPI](https://pypi.org/project/${{ env.PKG_NAME }}/$VERSION/)"
echo "- [📖 Repository](https://github.com/${{ github.repository }})"
if [ -n "$PREV_TAG" ]; then
echo "- [📋 Full Changelog](https://github.com/${{ github.repository }}/compare/$PREV_TAG...$TAG)"
fi
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.build.outputs.tag }}
name: v${{ needs.build.outputs.version }}
body: ${{ steps.release-notes.outputs.body }}
draft: false
prerelease: ${{ contains(needs.build.outputs.version, 'a') || contains(needs.build.outputs.version, 'b') || contains(needs.build.outputs.version, 'rc') }}
files: dist/*
fail_on_unmatched_files: true
# Dry run summary (only when dry-run is enabled)
dry-run-summary:
name: Dry Run Summary 🧪
needs: build
if: ${{ inputs.dry-run }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Summary
env:
VERSION: ${{ needs.build.outputs.version }}
TAG: ${{ needs.build.outputs.tag }}
run: |
echo "## 🧪 Dry Run Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Package Info" >> $GITHUB_STEP_SUMMARY
echo "- **Name**: ${{ env.PKG_NAME }}" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: $VERSION" >> $GITHUB_STEP_SUMMARY
echo "- **Tag**: $TAG" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Built Artifacts" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
ls -la dist/ >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ Ready to publish! Run again without dry-run to release." >> $GITHUB_STEP_SUMMARY