-
Notifications
You must be signed in to change notification settings - Fork 8
159 lines (138 loc) · 4.98 KB
/
Copy pathpython_release.yaml
File metadata and controls
159 lines (138 loc) · 4.98 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
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/
trigger-python-release-processor:
name: Trigger Python release processor
needs: publish-to-pypi
runs-on: ubuntu-latest
steps:
- name: Dispatch python_release_processor
uses: actions/github-script@v7
with:
github-token: ${{ secrets.AZIMUTH_ACTIONS_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'sift-stack',
repo: 'azimuth',
workflow_id: 'python_release_processor.yml',
ref: 'main'
})
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: Parse version
id: version
uses: ./.github/actions/python-version-info
with:
version: ${{ github.ref_name }}
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
IS_PRERELEASE: ${{ steps.version.outputs.is_prerelease }}
run: |
if [[ "$IS_PRERELEASE" == "true" ]]; then
# Pre-release: mark as pre-release and do not promote to latest.
RELEASE_FLAGS=(--prerelease --latest=false)
else
# Stable release: mark as the latest release.
RELEASE_FLAGS=(--latest)
fi
# 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 \
"${RELEASE_FLAGS[@]}"
# 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: Parse version
id: version
uses: ./.github/actions/python-version-info
with:
version: ${{ github.ref_name }}
- name: Deploy full version (hidden)
uses: ./.github/actions/python-mike-deploy
with:
version: ${{ steps.version.outputs.full_version }}
hidden: 'true'
# Stable releases also get the abbreviated major.minor version with the
# 'latest' alias, visible in the dropdown. Pre-releases stop at the hidden
# full-version deploy above.
- name: Deploy abbreviated version with latest alias
if: steps.version.outputs.is_prerelease == 'false'
uses: ./.github/actions/python-mike-deploy
with:
version: ${{ steps.version.outputs.major_minor }}
aliases: latest
hidden: 'false'