-
Notifications
You must be signed in to change notification settings - Fork 25
140 lines (133 loc) · 4.97 KB
/
publish-to-pypi.yml
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
name: Release
on:
schedule:
# run every day at 5am UTC
- cron: '0 5 * * *'
workflow_dispatch:
release:
types: [released]
pull_request:
# We also want this workflow triggered if the 'Build wheels'
# label is added or present when PR is updated
types:
- synchronize
- labeled
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_wheels:
permissions:
contents: none
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: (github.repository == 'spacetelescope/synphot_refactor' && ( github.event_name == 'release' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Build wheels')))
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install pip "twine>=3.3" -U
- name: Build wheels
uses: pypa/cibuildwheel@ee63bf16da6cddfb925f542f2c7b59ad50e93969 # v2.22.0
env:
CIBW_BUILD: 'cp310-* cp311-* cp312-* cp313-*'
CIBW_SKIP: '*-musllinux_*'
CIBW_ARCHS_LINUX: 'x86_64'
CIBW_ARCHS_WINDOWS: 'AMD64'
CIBW_ARCHS_MACOS: 'arm64'
CIBW_TEST_SKIP: '*-macosx_arm64'
CIBW_TEST_REQUIRES: 'pytest pytest-astropy'
CIBW_TEST_COMMAND: 'python -c "import synphot; synphot.test()"'
- name: Check wheels
run: python -m twine check --strict wheelhouse/*
# Upload artifacts because gh-action-pypi-publish Docker is only on Linux
- name: Upload wheels
if: (github.event_name == 'release' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: additional-pylons-${{ matrix.os }}
path: ./wheelhouse/*.whl
build_dist:
permissions:
contents: none
name: Source dist
runs-on: ubuntu-latest
if: (github.repository == 'spacetelescope/synphot_refactor' && ( github.event_name == 'release' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Build wheels')))
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.x'
- name: Install dependencies
run: python -m pip install pip build "twine>=3.3" -U
- name: Build package
run: python -m build --sdist .
- name: Check dist
run: python -m twine check --strict dist/*
- name: Test package
run: |
cd ..
python -m venv testenv
testenv/bin/pip install -U pip
testenv/bin/pip install pytest pytest-astropy
testenv/bin/pip install synphot_refactor/dist/*.tar.gz
testenv/bin/python -c "import synphot; synphot.test()"
- name: Upload dist
if: github.event_name == 'release'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: additional-pylons-dist
path: ./dist/*.tar.gz
publish:
name: Publish to PyPI
needs: [build_wheels, build_dist]
if: github.repository == 'spacetelescope/synphot_refactor' && github.event_name == 'release'
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/synphot
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download wheels
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: dist
pattern: additional-pylons-*
merge-multiple: true
- name: Pylons inspection
run: ls dist/*
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2
anaconda:
name: Publish nightly wheel to Anaconda
needs: [build_wheels]
if: github.repository == 'spacetelescope/synphot_refactor' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
steps:
- name: Download wheels
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: dist
pattern: additional-pylons-*
merge-multiple: true
- name: Pylons inspection
run: ls dist/*
- uses: OpenAstronomy/publish-wheels-anaconda@eae491141709933a7636af70b070e4a92d1a45be # main
with:
anaconda_user: STScI
anaconda_package: synphot
anaconda_token: ${{ secrets.anaconda_token }}
keep_n_latest: 5