Publish specified tags of Spine packages #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish specified tags of Spine packages | |
on: | |
workflow_dispatch: | |
inputs: | |
Spine-Toolbox: | |
description: Git tag to use for 'Spine-Toolbox' | |
required: true | |
type: string | |
spine-items: | |
description: Git tag to use for 'spine-items' | |
required: true | |
type: string | |
spine-engine: | |
description: Git tag to use for 'spine-engine' | |
required: true | |
type: string | |
Spine-Database-API: | |
description: Git tag to use for 'Spine-Database-API' | |
required: true | |
type: string | |
jobs: | |
build: | |
strategy: | |
matrix: | |
pkg: ['Spine-Toolbox', 'spine-items', 'spine-engine', 'Spine-Database-API'] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ matrix.pkg }} | |
uses: actions/checkout@v3 | |
with: | |
repository: 'spine-tools/${{ matrix.pkg }}' | |
path: ${{ matrix.pkg }} | |
ref: ${{ inputs[matrix.pkg] }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build | |
run: | | |
python -m build ${{ matrix.pkg }} | |
- name: Save ${{ matrix.pkg }} wheel | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.pkg }} | |
path: ${{ matrix.pkg }}/dist/* | |
retention-days: 7 | |
test: | |
needs: build | |
strategy: | |
matrix: | |
pkg: ['Spine-Toolbox', 'spine-items', 'spine-engine', 'Spine-Database-API'] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Make dist directory | |
# FIXME: does this work on Windows? | |
run: mkdir -p dist | |
- name: Download all wheels | |
uses: actions/download-artifact@v3 | |
with: | |
path: dist | |
- name: Checkout ${{ matrix.pkg }} | |
uses: actions/checkout@v3 | |
with: | |
repository: 'spine-tools/${{ matrix.pkg }}' | |
path: ${{ matrix.pkg }} | |
ref: ${{ inputs[matrix.pkg] }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install pytest and built wheels | |
run: | | |
python -m pip install --upgrade pip | |
pip install dist/*/*.whl | |
pip install pytest | |
- name: Install additional packages for Linux | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y libegl1 | |
- name: Remove source from checkouts for *Nix | |
if: runner.os != 'Windows' | |
run: | | |
rm -rf Spine-Toolbox/spinetoolbox* spine-items/spine_items \ | |
spine-engine/spine_engine Spine-Database-API/spinedb_api | |
- name: Remove source from checkouts for Windows | |
if: runner.os == 'Windows' | |
run: | | |
Remove-Item -Recurse -Force Spine-Toolbox\spinetoolbox | |
Remove-Item -Recurse -Force spine-items\spine_items | |
Remove-Item -Recurse -Force spine-engine\spine_engine | |
Remove-Item -Recurse -Force Spine-Database-API\spinedb_api | |
- name: Test wheels | |
# FIXME: how to run execution tests for Spine-Toolbox | |
run: | | |
python -m unittest discover -s ${{ matrix.pkg }} | |
publish: | |
# isolate from test, to prevent partial uploads | |
needs: test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
pkg: ['Spine-Toolbox', 'spine-items', 'spine-engine', 'Spine-Database-API'] | |
permissions: | |
id-token: write | |
steps: | |
- name: Make dist directory | |
run: mkdir -p dist | |
- name: Download all wheels | |
uses: actions/download-artifact@v3 | |
with: | |
path: dist | |
- name: Publish to PyPI using trusted publishing | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
# repository-url: https://test.pypi.org/legacy/ | |
packages-dir: dist/${{ matrix.pkg}} | |
# skip-existing: true | |
# verify-metadata: false |