Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps(workflows): bump actions/{upload,download}-artifact from 3 to 4 #200

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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