Skip to content

Commit

Permalink
deps(workflows): bump actions/{upload,download}-artifact from 3 to 4 (#…
Browse files Browse the repository at this point in the history
…200)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xuehai Pan <[email protected]>
  • Loading branch information
dependabot[bot] and XuehaiPan authored Dec 19, 2023
1 parent 2769849 commit 6d1191a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 37 deletions.
86 changes: 52 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
TORCHOPT_NO_EXTENSIONS: "true"

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
path: dist/*
Expand All @@ -97,12 +97,13 @@ jobs:
make pytest
build-wheels-py38:
name: Build wheels for Python ${{ matrix.python-version }} on ubuntu-latest
runs-on: ubuntu-latest
name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [build]
if: github.repository == 'metaopt/torchopt' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8"] # sync with requires-python in pyproject.toml
fail-fast: false
timeout-minutes: 60
Expand Down Expand Up @@ -140,19 +141,20 @@ jobs:
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wheels-py38
name: wheels-${{ matrix.python-version }}-${{ matrix.os }}
path: wheelhouse/*.whl
if-no-files-found: error

build-wheels:
name: Build wheels for Python ${{ matrix.python-version }} on ubuntu-latest
runs-on: ubuntu-latest
name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [build, build-wheels-py38]
if: github.repository == 'metaopt/torchopt' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"] # sync with requires-python in pyproject.toml
fail-fast: false
timeout-minutes: 60
Expand Down Expand Up @@ -190,15 +192,47 @@ jobs:
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-${{ matrix.python-version }}-${{ matrix.os }}
path: wheelhouse/*.whl
if-no-files-found: error

publish:
list-artifacts:
name: List artifacts
runs-on: ubuntu-latest
needs: [build, build-wheels-py38, build-wheels]
if: github.repository == 'metaopt/torchopt' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
timeout-minutes: 15
steps:
- name: Download built sdist
uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: build
path: dist

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

- name: List distributions
run: ls -lh dist/*

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: dist/*
if-no-files-found: error

publish:
runs-on: ubuntu-latest
needs: [list-artifacts]
if: |
github.repository == 'metaopt/torchopt' && github.event_name != 'pull_request' &&
(github.event_name != 'workflow_dispatch' || github.event.inputs.task == 'build-and-publish') &&
Expand Down Expand Up @@ -236,28 +270,12 @@ jobs:
exit 1
fi
- name: Download built sdist
uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: build
path: dist

- name: Download built wheels
uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: wheels-py38
path: dist

- name: Download built wheels
uses: actions/download-artifact@v3
- name: Download built artifacts
uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: wheels
name: artifacts
path: dist

- name: List distributions
Expand All @@ -269,10 +287,10 @@ jobs:
with:
user: __token__
password: ${{ secrets.TESTPYPI_UPLOAD_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
verbose: true
print_hash: true
skip_existing: true
print-hash: true
skip-existing: true

- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
Expand All @@ -281,5 +299,5 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_UPLOAD_TOKEN }}
verbose: true
print_hash: true
skip_existing: true
print-hash: true
skip-existing: true
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ repos:
hooks:
- id: clang-format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.1.8
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/PyCQA/isort
rev: 5.13.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 23.12.0
hooks:
- id: black-jupyter
- repo: https://github.com/asottile/pyupgrade
Expand Down

0 comments on commit 6d1191a

Please sign in to comment.