-
Notifications
You must be signed in to change notification settings - Fork 8
179 lines (153 loc) · 5.97 KB
/
python_release.yaml
File metadata and controls
179 lines (153 loc) · 5.97 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
name: PyPI Publish
on:
workflow_dispatch:
jobs:
python-ci:
if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags')
uses: ./.github/workflows/python_ci.yaml
secrets: inherit
build-offline-archives:
if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags')
needs: python-ci
uses: ./.github/workflows/python_build.yaml
secrets: inherit
publish-to-pypi:
name: Upload release to PyPI
needs: [ python-ci, build-offline-archives ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sift_py
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: sift-stack-py-dist
path: python/dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist/
create-github-release:
name: Create GitHub Release
needs: [ build-offline-archives ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: sift-stack-py-dist
path: python/dist/
- name: Download all platform archives
uses: actions/download-artifact@v4
with:
pattern: sift-py-dist-*-py3-*
path: platform_archives
merge-multiple: false
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
run: |
# Create release notes
cat > release_notes.md << 'EOL'
See [CHANGELOG.md](https://github.com/sift-stack/sift/blob/main/python/CHANGELOG.md) for details.
Offline archives are available for download for multiple platforms. Offline archives include wheels for all dependencies including build extras, e.g. openssl, development, and build.
Use `pip install sift-stack-py --find-links={path/to/archive} --no-index` to install.
EOL
# Create the release
gh release create "$TAG_NAME" \
--title "sift-stack-py $TAG_NAME" \
--notes-file release_notes.md
# Upload Python package distributions
for dist in python/dist/*; do
echo "Uploading distribution: $dist"
gh release upload "$TAG_NAME" "$dist" --clobber
done
# Upload platform archives (both .zip and .tar.gz)
for archive in platform_archives/*/sift-py-dist-*-py3-*.{zip,tar.gz}; do
echo "Uploading archive: $archive"
gh release upload "$TAG_NAME" "$archive" --clobber
done
deploy-docs:
name: Deploy Documentation
needs: publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
cd python
pip install -e .[docs-build]
- name: Extract version and check if stable
id: version
run: |
# Extract version from tag (everything after 'python/')
FULL_VERSION=${GITHUB_REF#refs/tags/python/}
echo "Full version from tag: $FULL_VERSION"
# Extract major.minor from version (drop patch)
if [[ "$FULL_VERSION" =~ ^v?([0-9]+)\.([0-9]+)\.[0-9]+(.*)?$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
SUFFIX=${BASH_REMATCH[3]}
VERSION="v${MAJOR}.${MINOR}"
# Check if this is a stable release (no suffix like -alpha, -beta, -rc)
if [[ -z "$SUFFIX" ]]; then
# Stable release - use 'latest' alias and make visible
ALIAS="latest"
HIDDEN="false"
echo "Stable release detected: $FULL_VERSION -> $VERSION"
else
# Pre-release (alpha, beta, rc) - no 'latest' alias and hide from dropdown
VERSION="${VERSION}${SUFFIX}"
ALIAS=""
HIDDEN="true"
echo "Pre-release detected: $FULL_VERSION -> $VERSION"
fi
else
echo "Error: Could not parse version format: $FULL_VERSION"
exit 1
fi
echo "full_version=$FULL_VERSION" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "alias=$ALIAS" >> $GITHUB_OUTPUT
echo "hidden=$HIDDEN" >> $GITHUB_OUTPUT
echo "Final - Version: $VERSION, Alias: $ALIAS, Hidden: $HIDDEN"
- name: Fetch gh-pages branch
run: git fetch origin gh-pages --depth=1
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Deploy docs with mike
run: |
cd python
FULL_VERSION="${{ steps.version.outputs.full_version }}"
VERSION="${{ steps.version.outputs.version }}"
ALIAS="${{ steps.version.outputs.alias }}"
HIDDEN="${{ steps.version.outputs.hidden }}"
# Always deploy the full version first, but hide it
echo "Deploying full version $FULL_VERSION (hidden)"
mike deploy "$FULL_VERSION" --push --prop-set hidden=true
if [[ "$HIDDEN" == "false" ]]; then
# Stable release: deploy abbreviated version with latest alias, visible in dropdown
echo "Deploying stable release $VERSION with $ALIAS alias"
mike deploy "$VERSION" "$ALIAS" --push --update-aliases
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}