-
Notifications
You must be signed in to change notification settings - Fork 5
182 lines (147 loc) · 5.71 KB
/
Copy pathrelease.yml
File metadata and controls
182 lines (147 loc) · 5.71 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build Release Binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- name: Cache Zig
uses: actions/cache@v4
with:
path: |
~/.cache/zig
zig-cache
key: zig-cache-${{ runner.os }}-${{ hashFiles('build.zig', 'build.zig.zon') }}
restore-keys: |
zig-cache-${{ runner.os }}-
- name: Build all platforms
run: zig build release
- name: Create source tarball
run: |
VERSION=${GITHUB_REF#refs/tags/v}
git archive --format=tar.gz --prefix=PyOZ-${VERSION}/ -o zig-out/release/PyOZ-${VERSION}.tar.gz HEAD
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-binaries
path: zig-out/release/*
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: release-binaries
path: release/
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract changelog for this version
id: changelog
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Extract the section between this version and the next version header (or end of file)
CHANGELOG=$(awk -v ver="$VERSION" '
BEGIN { found=0; output="" }
/^## \[/ {
if (found) exit
if (index($0, ver)) found=1
next
}
found { output = output $0 "\n" }
END { print output }
' CHANGELOG.md)
# Write to file to preserve newlines
echo "$CHANGELOG" > changelog_section.txt
# Also set as output (escaped for GitHub Actions)
{
echo 'NOTES<<EOF'
cat changelog_section.txt
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ steps.version.outputs.VERSION }}
PRERELEASE_FLAG=""
if [[ "$VERSION" == *alpha* ]] || [[ "$VERSION" == *beta* ]] || [[ "$VERSION" == *rc* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
cat > release_notes.md << 'RELEASE_EOF'
## What's New in v${{ steps.version.outputs.VERSION }}
${{ steps.changelog.outputs.NOTES }}
---
## Installation
Download the binary for your platform and add it to your PATH:
| Platform | Binary |
|----------|--------|
| Linux x86_64 | `pyoz-x86_64-linux` |
| Linux ARM64 | `pyoz-aarch64-linux` |
| macOS x86_64 | `pyoz-x86_64-macos` |
| macOS ARM64 (Apple Silicon) | `pyoz-aarch64-macos` |
| Windows x86_64 | `pyoz-x86_64-windows.exe` |
| Windows ARM64 | `pyoz-aarch64-windows.exe` |
## Source
Download `PyOZ-${{ steps.version.outputs.VERSION }}.tar.gz` for the source code.
## Quick Start
```bash
pyoz init mymodule
cd mymodule
pyoz build
pip install dist/*.whl
```
RELEASE_EOF
gh release create "v${VERSION}" \
--title "PyOZ v${VERSION}" \
--notes-file release_notes.md \
$PRERELEASE_FLAG \
release/*
pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Cache Zig
uses: actions/cache@v4
with:
path: |
~/.cache/zig
pypi/zig-cache
key: zig-pypi-cache-${{ runner.os }}-${{ hashFiles('pypi/build.zig', 'pypi/build.zig.zon') }}
restore-keys: |
zig-pypi-cache-${{ runner.os }}-
- name: Build abi3 wheels for all platforms
run: python pypi/build_wheels.py --dist-dir pypi/dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: pypi/dist/
skip-existing: true