Skip to content

Commit c9ef5ec

Browse files
Update release-binaries.yml
1 parent c165ecc commit c9ef5ec

1 file changed

Lines changed: 21 additions & 142 deletions

File tree

.github/workflows/release-binaries.yml

Lines changed: 21 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ jobs:
1919
outputs:
2020
version: ${{ steps.extract.outputs.version }}
2121
tag: ${{ steps.extract.outputs.tag }}
22+
exists: ${{ steps.check.outputs.exists }}
2223

2324
steps:
2425
- uses: actions/checkout@v4
2526
with:
2627
fetch-depth: 0
2728

28-
- name: Extract version from pyproject.toml
29-
id: extract
29+
- id: extract
3030
run: |
3131
VERSION=$(python3 - <<'EOF'
3232
import tomllib
@@ -35,18 +35,19 @@ jobs:
3535
EOF
3636
)
3737
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
38-
echo "tag=$VERSION" >> "$GITHUB_OUTPUT"
38+
echo "tag=$VERSION" >> "$GITHUB_OUTPUT"
3939
40-
- name: Abort if tag already exists
40+
- id: check
4141
run: |
42-
if git rev-parse "refs/tags/${{ steps.extract.outputs.tag }}" &>/dev/null; then
43-
echo "Tag ${{ steps.extract.outputs.tag }} already exists — skipping release."
44-
exit 1
42+
if git rev-parse "refs/tags/${{ steps.extract.outputs.tag }}" >/dev/null 2>&1; then
43+
echo "exists=true" >> "$GITHUB_OUTPUT"
44+
else
45+
echo "exists=false" >> "$GITHUB_OUTPUT"
4546
fi
4647
47-
- name: Create and push tag
48+
- if: steps.check.outputs.exists == 'false'
4849
run: |
49-
git config user.name "github-actions[bot]"
50+
git config user.name "github-actions[bot]"
5051
git config user.email "github-actions[bot]@users.noreply.github.com"
5152
git tag "${{ steps.extract.outputs.tag }}"
5253
git push origin "${{ steps.extract.outputs.tag }}"
@@ -59,13 +60,14 @@ jobs:
5960
steps:
6061
- uses: actions/checkout@v4
6162

62-
- name: Build inside manylinux2014 + shared Python (glibc 2.17)
63+
- name: Build inside manylinux2014 (glibc 2.17)
6364
env:
6465
VERSION: ${{ needs.tag.outputs.version }}
6566
run: |
6667
printf 'from bangen.app import main\nif __name__ == "__main__":\n main()\n' > _entry.py
6768
6869
docker run --rm \
70+
-u $(id -u):$(id -g) \
6971
-v "${{ github.workspace }}:/workspace" \
7072
-w /workspace \
7173
-e VERSION="$VERSION" \
@@ -100,16 +102,18 @@ jobs:
100102
--exclude-module xmlrpc \
101103
--optimize 2 \
102104
_entry.py
105+
103106
echo "=== GLIBC symbols ==="
104107
strings dist/bangen | grep "GLIBC_" | sort -V | uniq
108+
105109
if strings dist/bangen | grep -E "GLIBC_2\.(1[89]|[2-9][0-9])"; then
106110
echo "ERROR: Binary requires glibc newer than 2.17!"
107111
exit 1
108112
fi
113+
109114
echo "✅ glibc 2.17 compatible"
110-
sudo chown -R "$(id -u):$(id -g)" dist/
111115
'
112-
116+
113117
- name: Package artifact
114118
env:
115119
VERSION: ${{ needs.tag.outputs.version }}
@@ -148,24 +152,19 @@ jobs:
148152
with:
149153
python-version: "3.11"
150154

151-
- name: Cache pip
152-
uses: actions/cache@v4
155+
- uses: actions/cache@v4
153156
with:
154157
path: |
155158
~/.cache/pip
156159
~/AppData/Local/pip/Cache
157160
key: pip-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}
158161
restore-keys: pip-${{ runner.os }}-
159162

160-
- name: Install Python deps
161-
shell: bash
162-
run: |
163+
- run: |
163164
python -m pip install -U pip wheel pyinstaller
164165
pip install ".[all]"
165166
166-
- name: Build with PyInstaller
167-
shell: bash
168-
env:
167+
- env:
169168
VERSION: ${{ needs.tag.outputs.version }}
170169
run: |
171170
printf 'from bangen.app import main\nif __name__ == "__main__":\n main()\n' > _entry.py
@@ -196,7 +195,6 @@ jobs:
196195
_entry.py
197196
198197
- name: Package artifact
199-
shell: bash
200198
env:
201199
VERSION: ${{ needs.tag.outputs.version }}
202200
BINARY: ${{ matrix.binary }}
@@ -221,142 +219,23 @@ jobs:
221219
release:
222220
name: Publish Release
223221
needs: [tag, build-linux, build-windows-macos]
222+
if: needs.tag.outputs.exists == 'false'
224223
runs-on: ubuntu-latest
225224
permissions:
226225
contents: write
227226

228227
steps:
229-
- uses: actions/checkout@v4
230-
with:
231-
fetch-depth: 0
232-
233228
- uses: actions/download-artifact@v4
234229
with:
235230
path: artifacts
236231
merge-multiple: true
237232

238-
- name: Generate checksums
239-
run: |
233+
- run: |
240234
cd artifacts
241235
sha256sum * > SHA256SUMS.txt
242236
243-
- name: Build release notes
244-
id: notes
245-
env:
246-
VERSION: ${{ needs.tag.outputs.version }}
247-
run: |
248-
PREV_TAG=$(git tag --sort=-version:refname | grep -v "^$VERSION$" | head -1)
249-
250-
if [[ -n "$PREV_TAG" ]]; then
251-
COMMITS=$(git log "$PREV_TAG"..HEAD --pretty=format:"- %s (%h)" --no-merges)
252-
COMPARE_URL="https://github.com/${{ github.repository }}/compare/$PREV_TAG...$VERSION"
253-
SINCE_LINE="> Changes since \`$PREV_TAG\` · [Full diff]($COMPARE_URL)"
254-
else
255-
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges)
256-
SINCE_LINE="> Initial release"
257-
fi
258-
259-
FEATS=$(echo "$COMMITS" | grep -E "^- feat" | sed 's/^- feat[^:]*: /- /' || true)
260-
FIXES=$(echo "$COMMITS" | grep -E "^- fix" | sed 's/^- fix[^:]*: /- /' || true)
261-
CHORES=$(echo "$COMMITS" | grep -E "^- (chore|refactor|perf|build|ci)" | sed 's/^- [^:]*: /- /' || true)
262-
OTHER=$(echo "$COMMITS" | grep -vE "^- (feat|fix|chore|refactor|perf|build|ci)" || true)
263-
264-
LINUX_SHA=$(grep "bangen-linux-$VERSION.tar.gz" artifacts/SHA256SUMS.txt | awk '{print $1}' || true)
265-
WINDOWS_SHA=$(grep "bangen-windows-$VERSION.zip" artifacts/SHA256SUMS.txt | awk '{print $1}' || true)
266-
MACOS_SHA=$(grep "bangen-macos-$VERSION.tar.gz" artifacts/SHA256SUMS.txt | awk '{print $1}' || true)
267-
268-
{
269-
echo "body<<NOTES_EOF"
270-
echo "# ✨ Bangen $VERSION"
271-
echo ""
272-
echo "$SINCE_LINE"
273-
echo ""
274-
echo "---"
275-
echo ""
276-
if [[ -n "$FEATS" ]]; then
277-
echo "## 🚀 What's New"
278-
echo "$FEATS"
279-
echo ""
280-
fi
281-
if [[ -n "$FIXES" ]]; then
282-
echo "## 🐛 Bug Fixes"
283-
echo "$FIXES"
284-
echo ""
285-
fi
286-
if [[ -n "$CHORES" ]]; then
287-
echo "## 🔧 Maintenance"
288-
echo "$CHORES"
289-
echo ""
290-
fi
291-
if [[ -n "$OTHER" ]]; then
292-
echo "## 📝 Other Changes"
293-
echo "$OTHER"
294-
echo ""
295-
fi
296-
echo "---"
297-
echo ""
298-
echo "## 📦 Downloads"
299-
echo ""
300-
echo "Pre-built native binaries — **no Python installation required.**"
301-
echo ""
302-
echo "| Platform | Architecture | File | SHA-256 |"
303-
echo "|----------|-------------|------|---------|"
304-
echo "| 🐧 Linux | x86_64 | \`bangen-linux-$VERSION.tar.gz\` | \`$LINUX_SHA\` |"
305-
echo "| 🪟 Windows | x86_64 | \`bangen-windows-$VERSION.zip\` | \`$WINDOWS_SHA\` |"
306-
echo "| 🍎 macOS | arm64 | \`bangen-macos-$VERSION.tar.gz\` | \`$MACOS_SHA\` |"
307-
echo ""
308-
echo "### 🐧 Linux compatibility"
309-
echo ""
310-
echo "The Linux binary is built inside a \`manylinux2014\` (CentOS 7) container against **glibc 2.17**,"
311-
echo "making it compatible with virtually any Linux system from 2014 onwards — including:"
312-
echo ""
313-
echo "| Environment | Compatible |"
314-
echo "|-------------|-----------|"
315-
echo "| Google Colab | ✅ |"
316-
echo "| Ubuntu 16.04+ | ✅ |"
317-
echo "| Debian 8+ | ✅ |"
318-
echo "| RHEL / CentOS 7+ | ✅ |"
319-
echo "| Fedora 20+ | ✅ |"
320-
echo "| Old VPS / servers | ✅ |"
321-
echo "| GitHub Actions runners | ✅ |"
322-
echo ""
323-
echo "### 🚀 Quick Install"
324-
echo ""
325-
echo "\`\`\`bash"
326-
echo "# Linux"
327-
echo "tar -xzf bangen-linux-$VERSION.tar.gz"
328-
echo "chmod +x bangen-linux-$VERSION"
329-
echo "sudo mv bangen-linux-$VERSION /usr/local/bin/bangen"
330-
echo ""
331-
echo "# macOS"
332-
echo "tar -xzf bangen-macos-$VERSION.tar.gz"
333-
echo "chmod +x bangen-macos-$VERSION"
334-
echo "sudo mv bangen-macos-$VERSION /usr/local/bin/bangen"
335-
echo ""
336-
echo "# Windows (PowerShell)"
337-
echo "Expand-Archive bangen-windows-$VERSION.zip ."
338-
echo "# Move bangen.exe somewhere on your PATH"
339-
echo ""
340-
echo "# Google Colab"
341-
echo "!wget -q https://github.com/${{ github.repository }}/releases/download/$VERSION/bangen-linux-$VERSION.tar.gz"
342-
echo "!tar -xzf bangen-linux-$VERSION.tar.gz"
343-
echo "!chmod +x bangen-linux-$VERSION && mv bangen-linux-$VERSION /usr/local/bin/bangen"
344-
echo "!bangen --help"
345-
echo "\`\`\`"
346-
echo ""
347-
echo "### 🔒 Verify Your Download"
348-
echo ""
349-
echo "\`\`\`bash"
350-
echo "sha256sum -c SHA256SUMS.txt"
351-
echo "\`\`\`"
352-
echo ""
353-
echo "> Full checksums for all artifacts are in \`SHA256SUMS.txt\`, included in the release assets below."
354-
echo "NOTES_EOF"
355-
} >> "$GITHUB_OUTPUT"
356-
357237
- uses: softprops/action-gh-release@v2
358238
with:
359239
tag_name: ${{ needs.tag.outputs.tag }}
360240
name: "✨ Bangen ${{ needs.tag.outputs.version }}"
361-
body: ${{ steps.notes.outputs.body }}
362241
files: artifacts/*

0 commit comments

Comments
 (0)