Skip to content

Commit

Permalink
ci(test): Test build python tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc committed Nov 2, 2024
1 parent d2b4dc0 commit b8f1fd3
Showing 1 changed file with 97 additions and 17 deletions.
114 changes: 97 additions & 17 deletions .github/workflows/release-python-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker/javascript_worker.wasm

build-and-test:
build-wheels:
needs: build-js-worker
runs-on: ubuntu-latest
strategy:
Expand All @@ -58,7 +58,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.10" # 用于安装 rye
python-version: "3.10"

- name: Install Rye
uses: eifinger/setup-rye@v4
Expand Down Expand Up @@ -87,19 +87,18 @@ jobs:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker

- name: Build packages
- name: Build wheel packages
run: |
cd bindings/python
# Sync version(copy version from workspace to all packages)
# Sync version
rye sync
rye run sync-version
# Build lyric-task
# Build lyric-task wheel
cd lyric-task
rye sync --no-dev
rye build
rye build --sdist
# Build lyric-py-worker
cd ../lyric-py-worker
Expand All @@ -117,46 +116,127 @@ jobs:
rye sync --no-dev
rye build
rye build --sdist
# Build lyric-js-worker
# Build lyric-js-worker wheel
cd ../lyric-js-worker
mkdir -p src/lyric_js_worker/
cp ../../javascript/lyric-js-worker/javascript_worker.wasm src/lyric_js_worker/
rye sync --no-dev
rye build
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: dist-wheels-py${{ matrix.python-version }}
path: |
bindings/python/dist/*.whl
build-sdist:
needs: build-js-worker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Remove lyric-py directory
run: rm -rf bindings/python/lyric-py

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install Rye
uses: eifinger/setup-rye@v4
with:
enable-cache: true
working-directory: bindings/python
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build source distributions
run: |
cd bindings/python
# Sync version
rye sync
rye run sync-version
# Build lyric-task sdist
cd lyric-task
rye sync --no-dev
rye build --sdist
# Build lyric-py-worker sdist
cd ../lyric-py-worker
rye sync --no-dev
rye build --sdist
# Build lyric-js-worker sdist
cd ../lyric-js-worker
rye sync --no-dev
rye build --sdist
- name: Upload artifacts
- name: Upload sdist artifacts
uses: actions/upload-artifact@v4
with:
name: dist-py${{ matrix.python-version }}
path: bindings/python/dist
name: dist-sdist
path: |
bindings/python/dist/*.tar.gz
test-packages:
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10.14", "3.11.8", "3.12.2"]

steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
name: dist-wheels-py${{ matrix.python-version }}
path: dist

- name: Test packages
run: |
python -m pip install --find-links=bindings/python/dist lyric-js-worker
python -m pip install --find-links=dist lyric-js-worker
publish:
needs: build-and-test
needs: [test-packages]
runs-on: ubuntu-latest
# if: github.event_name == 'release' && github.event.action == 'published'
environment:
name: pypi
url: https://pypi.org/p/lyric-js-worker
permissions:
id-token: write

steps:
- name: Download all artifacts
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: dist-py*
pattern: dist-wheels-py*
merge-multiple: true
path: dist
path: dist-wheels

- name: Download sdist
uses: actions/download-artifact@v4
with:
name: dist-sdist
path: dist-sdist

- name: Prepare dist directory
run: |
mkdir dist
cp dist-wheels/* dist/
cp dist-sdist/* dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
verbose: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit b8f1fd3

Please sign in to comment.