Repository navigation
107 lines (91 loc) · 3.05 KB
/
Copy pathrelease.yml
File metadata and controls
107 lines (91 loc) · 3.05 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
name: Build and Upload Python Package
on:
release:
types: [ published ]
jobs:
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install nox
run: python -m pip install nox
- name: Build sdist
run: nox -s build_sdist
- uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: |
dist/*.tar.gz
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir dist
- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
path: |
dist/*.whl
publish:
name: Publish
needs: [ build_wheels, build_sdist ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Upload wheels to Github release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
// GITHUB_REF would be refs/tags/<tag_name>
const tag = process.env.GITHUB_REF.split("/").pop();
console.log('environment', process.versions);
console.log({ owner, repo, sha });
const release = await github.rest.repos.getReleaseByTag({ owner, repo, tag });
console.log('get release', { release });
for (let file of await fs.readdir('dist')) {
console.log('uploading', file);
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./dist/${file}`)
});
}
- name: Publish package to PyPI
# Upload to PyPI for a stable release
if: ${{ github.event.release.prerelease == false }}
env:
IS_DEV: ${{ github.repository_owner != 'alibaba' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# env is a string
repository_url: ${{ env.IS_DEV == 'true' && 'https://test.pypi.org/legacy/' || '' }}
skip_existing: ${{ env.IS_DEV }}
verbose: ${{ env.IS_DEV }}