Skip to content

Commit

Permalink
Only build package once in GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
JanNiklasWeder committed May 16, 2024
1 parent 58d56a6 commit efbb550
Showing 1 changed file with 48 additions and 29 deletions.
77 changes: 48 additions & 29 deletions .github/workflows/test-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Install dependencies
Expand All @@ -33,24 +33,54 @@ jobs:
python-version: [ "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install tox
- name: Run type-checking
run: python -m tox -e types

build:
needs: [ types ]
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"

- name: Set up JS & build js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine build
yarn install
- name: Build JS
run: yarn run vite build
- name: Build package
run: python -m build
- name: Archive package as artifact
uses: actions/upload-artifact@v4
with:
name: cobramod-dist
path: |
dist
unittest:
needs: [lint-format, types]
needs: [build]
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.10", "3.11", "3.12" ]
runs-on: ${{ matrix.os}}
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand All @@ -60,18 +90,15 @@ jobs:
- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Set up JS & build js
uses: actions/setup-node@v4
- name: Download package as artifact
uses: actions/download-artifact@v4
with:
node-version: 20
name: cobramod-dist
path: |
dist
- name: Install dependencies
run: yarn install
- name: Build JS
run: yarn run vite build

- name: Install dependencies
run: python -m pip install .
- name: Install CobraMod & dependencies from wheel
run: pip install ./dist/cobramod-*.whl

- name: Install tox
run: python -m pip install tox
Expand All @@ -92,30 +119,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"

- name: Set up JS & build js
uses: actions/setup-node@v4
- name: Download package as artifact
uses: actions/download-artifact@v4
with:
node-version: 20

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine build
yarn install
name: cobramod-dist
path: |
dist
- name: Build JS
run: yarn run vite build
- name: Build package
run: python -m build
- name: Check the package
run: twine check dist/*

- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand Down

0 comments on commit efbb550

Please sign in to comment.