-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (96 loc) · 3.26 KB
/
release_github.yml
File metadata and controls
111 lines (96 loc) · 3.26 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
# .github/workflows/release.yml
name: Release on Github
on:
push:
branches:
- main
workflow_dispatch:
env:
PACKAGE_NAME: serger
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # Required to create releases and tags
id-token: write # Required for PyPI publishing (if enabled)
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install Poetry
uses: abatilo/actions-poetry@v4
with:
poetry-version: "latest"
- name: Install dependencies
run: poetry install --no-interaction
- name: Run checks
run: poetry run poe check
- name: Build stitched script
continue-on-error: true
run: poetry run poe build:stitched
- name: Build zipapp
continue-on-error: true
run: poetry run poe build:zipapp
- name: Semantic Release (Version & Tag)
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
output=$(poetry run semantic-release version 2>&1) || true
echo "$output"
# Check if a new version was created (looks for version number pattern)
if echo "$output" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+|next version is"; then
echo "released=true" >> $GITHUB_OUTPUT
else
echo "released=false" >> $GITHUB_OUTPUT
fi
- name: Semantic Release (Publish to GitHub)
if: steps.release.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Run semantic-release publish and capture exit code
if ! poetry run semantic-release publish; then
echo "::error::semantic-release publish failed"
exit 1
fi
- name: Upload custom release assets
if: steps.release.outputs.released == 'true'
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the latest tag created by semantic-release
TAG=$(git describe --tags --abbrev=0)
if [ -z "$TAG" ]; then
echo "::warning::No tag found for release"
exit 0
fi
# Collect available assets
ASSETS=()
if [ -f "dist/${PACKAGE_NAME}.py" ]; then
ASSETS+=("dist/${PACKAGE_NAME}.py")
fi
if [ -f "dist/${PACKAGE_NAME}.pyz" ]; then
ASSETS+=("dist/${PACKAGE_NAME}.pyz")
fi
# Upload assets if any are available
if [ ${#ASSETS[@]} -eq 0 ]; then
echo "::notice::No build artifacts found to upload"
exit 0
fi
echo "Uploading ${#ASSETS[@]} asset(s): ${ASSETS[*]}"
if ! gh release upload "$TAG" "${ASSETS[@]}" --clobber; then
echo "::warning::Failed to upload release assets (non-fatal)"
exit 0
fi