Skip to content

Commit ddca1f5

Browse files
committed
Test uploading versioned wheels to PyPI
1 parent 320b5f4 commit ddca1f5

File tree

2 files changed

+63
-18
lines changed

2 files changed

+63
-18
lines changed

.github/workflows/make_wheel.yml

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,86 @@ jobs:
4141
strategy:
4242
matrix:
4343
cfg:
44-
- { name: 'Linux LLVM+libstdc++', os: 'ubuntu-22.04', platform: 'manylinux_2_35_x86_64', cc: clang, cxx: clang++, config: --linkopt=-fuse-ld=lld }
45-
- { name: 'MacOS 11 x86_64 LLVM+libc++', os: 'macos-11', platform: 'macosx_11_0_x86_64', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
46-
- { name: 'MacOS 12 x86_64 LLVM+libc++', os: 'macos-12', platform: 'macosx_12_0_x86_64', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
47-
- { name: 'MacOS 13 x86_64 LLVM+libc++', os: 'macos-13', platform: 'macosx_13_0_x86_64', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
48-
- { name: 'MacOS 12 ARM64 LLVM+libc++', os: 'macos-12', platform: 'macosx_12_0_arm64', cc: clang, cxx: clang++,
49-
config: --config=libc++ --config=macos_arm64 --repo_env=PY_PLATFORM_OVERRIDE=macosx_12_0_arm64 }
50-
- { name: 'MacOS 13 ARM64 LLVM+libc++', os: 'macos-13', platform: 'macosx_13_0_arm64', cc: clang, cxx: clang++,
44+
- { name: 'Linux LLVM+libstdc++', os: 'ubuntu-22.04', cc: clang, cxx: clang++, config: --linkopt=-fuse-ld=lld }
45+
# - { name: 'MacOS 11 x86_64 LLVM+libc++', os: 'macos-11', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
46+
# - { name: 'MacOS 12 x86_64 LLVM+libc++', os: 'macos-12', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
47+
# - { name: 'MacOS 13 x86_64 LLVM+libc++', os: 'macos-13', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
48+
# - { name: 'MacOS 12 ARM64 LLVM+libc++', os: 'macos-12', cc: clang, cxx: clang++,
49+
# config: --config=libc++ --config=macos_arm64 --repo_env=PY_PLATFORM_OVERRIDE=macosx_12_0_arm64 }
50+
- { name: 'MacOS 13 ARM64 LLVM+libc++', os: 'macos-13', cc: clang, cxx: clang++,
5151
config: --config=libc++ --config=macos_arm64 --repo_env=PY_PLATFORM_OVERRIDE=macosx_13_0_arm64 }
52-
py:
53-
- { version: '3.8', interp: 'cp38', abi: 'cp38' }
54-
- { version: '3.9', interp: 'cp39', abi: 'cp39' }
55-
- { version: '3.10', interp: 'cp310', abi: 'cp310' }
56-
- { version: '3.11', interp: 'cp311', abi: 'cp311' }
52+
python-version:
53+
# - '3.8'
54+
- '3.9'
55+
- '3.10'
56+
# - '3.11'
5757

5858
env:
5959
CC: ${{ matrix.cfg.cc }}
6060
CXX: ${{ matrix.cfg.cxx }}
61+
WHEEL_NAME: ''
6162

6263
steps:
6364
- uses: actions/checkout@v3
6465

6566
- uses: actions/setup-python@v3
6667
with:
67-
python-version: ${{ matrix.py.version }}
68+
python-version: ${{ matrix.python-version }}
6869

6970
- name: Install Python Dependencies
7071
run: pip3 install --upgrade pip packaging
7172

72-
- name: Build for Python ${{ matrix.py.version }}
73+
- name: Build for Python ${{ matrix.python-version }}
7374
run: bazel --bazelrc=.bazelrc build --compilation_mode=opt --dynamic_mode=off --config=luajit ${{ matrix.cfg.config }} //dmlab2d:dmlab2d_wheel
7475

76+
- name: Get built wheel name
77+
working-directory: bazel-bin/dmlab2d
78+
run: |
79+
WHEEL_NAME="$(ls *.whl)"
80+
echo WHEEL_NAME="${WHEEL_NAME}" >> "${GITHUB_ENV}"
81+
7582
- name: Upload Release Asset
7683
uses: actions/upload-release-asset@v1
7784
env:
7885
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7986
with:
8087
upload_url: ${{ needs.create-release.outputs.upload-url }}
81-
asset_path: bazel-bin/dmlab2d/dmlab2d-1.0-${{ matrix.py.interp }}-${{ matrix.py.abi }}-${{ matrix.cfg.platform }}.whl
82-
asset_name: dmlab2d-1.0-${{ matrix.py.interp }}-${{ matrix.py.abi }}-${{ matrix.cfg.platform }}.whl
88+
asset_path: bazel-bin/dmlab2d/${{ env.WHEEL_NAME }}
89+
asset_name: ${{ env.WHEEL_NAME }}
8390
asset_content_type: application/zip
91+
92+
- name: Check wheel contents
93+
run: |
94+
pip install --upgrade check-wheel-contents
95+
check-wheel-contents bazel-bin/dmlab2d/${{ env.WHEEL_NAME }}
96+
97+
- name: Upload wheel as artifact
98+
uses: actions/upload-artifact@v3
99+
with:
100+
name: dist
101+
path: bazel-bin/dmlab2d/${{ env.WHEEL_NAME }}
102+
retention-days: 1
103+
104+
upload-wheel-to-pypi:
105+
name: Upload wheel to Pypi
106+
runs-on: ubuntu-latest
107+
needs: build-wheel
108+
timeout-minutes: 30
109+
110+
steps:
111+
- name: Download all wheels
112+
uses: actions/download-artifact@v3
113+
114+
- name: Publish package to TestPyPI
115+
uses: pypa/gh-action-pypi-publish@release/v1
116+
with:
117+
password: ${{ secrets.TESTPYPI_API_TOKEN }}
118+
packages-dir: dist
119+
repository-url: https://test.pypi.org/legacy/
120+
121+
- name: Publish package to PyPI
122+
if: startsWith(github.ref, 'refs/tags')
123+
uses: pypa/gh-action-pypi-publish@release/v1
124+
with:
125+
password: ${{ secrets.PYPI_API_TOKEN }}
126+
packages-dir: dist

dmlab2d/BUILD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ py_package(
113113
],
114114
)
115115

116+
VERSION = "1.0.0-dev.8" # http://semver.org
117+
116118
py_wheel(
117119
name = "dmlab2d_wheel",
118120
abi = PY_TAGS.abi,
@@ -130,7 +132,7 @@ py_wheel(
130132
"dm_env",
131133
"numpy",
132134
],
133-
version = "1.0",
135+
version = VERSION,
134136
deps = [":dmlab2d_pkg"],
135137
)
136138

@@ -153,7 +155,7 @@ py_wheel(
153155
"dm_env",
154156
"numpy",
155157
],
156-
version = "1.0",
158+
version = VERSION,
157159
deps = [":dmlab2d_pkg"],
158160
)
159161

0 commit comments

Comments
 (0)