Skip to content

Commit

Permalink
ci: build and publish at pypi/test-pypi (#95)
Browse files Browse the repository at this point in the history
* ci: build and publish tp pypi and test pypi
* ci: run tests before publishing
* chore: bump to 0.2.1
  • Loading branch information
almutlue authored Aug 8, 2024
1 parent 09d688e commit 7f5a86a
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 3 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/poetry-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Workflow following resources at:
# - https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-pypi
# - https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives
# Jobs are split to prevent unneccessary priviledge elevation through write permissions during building.

name: Build and publish on Pypi

on:
release:
types: [published]

permissions:
contents: read

jobs:
run-tests:
uses: ./.github/workflows/poetry-pytest.yml

release-build:
name: Build python wheels
needs:
- run-tests
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
- name: Set up Python
# https://github.com/actions/setup-python
uses: actions/setup-python@v5.1.1
with:
python-version: "3.10"

- name: Install Poetry
run: |
pip install poetry
- name: Build source and wheel archives
run: poetry build

- name: Upload distributions
# https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

pypi-publish:
name: Upload release to PyPI
needs:
- release-build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/modos
permissions:
id-token: write
# IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Retrieve release distributions
# https://github.com/actions/download-artifact
uses: actions/download-artifact@v4.1.8
with:
name: release-dists
path: dist/
- name: Publish package distributions to PyPI
# https://github.com/pypa/gh-action-pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion .github/workflows/poetry-pytest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tests

on: [push]
on: [push, workflow_call]

jobs:

Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/poetry-test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Workflow following resources at:
# - https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-pypi
# - https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives
# Jobs are split to prevent unneccessary priviledge elevation through write permissions during building.

name: Build and publish on Pypi Test

on:
workflow_dispatch:

permissions:
contents: read

jobs:
run-tests:
uses: ./.github/workflows/poetry-pytest.yml
test-build:
name: Build python wheels
needs:
- run-tests
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
- name: Set up Python
# https://github.com/actions/setup-python
uses: actions/setup-python@v5.1.1
with:
python-version: "3.10"

- name: Install Poetry
run: |
pip install poetry
- name: Build source and wheel archives
run: poetry build

- name: Upload distributions
# https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v4
with:
name: test-dists
path: dist/

pypi-test-publish:
name: Upload release to PyPI Test
needs:
- test-build
runs-on: ubuntu-latest
environment:
name: test-pypi
url: https://test.pypi.org/p/modos
permissions:
id-token: write
# IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Retrieve release distributions
# https://github.com/actions/download-artifact
uses: actions/download-artifact@v4.1.8
with:
name: test-dists
path: dist/
- name: Publish package distributions to TestPyPI
# https://github.com/pypa/gh-action-pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = "modos-api"
copyright = "2024, sdsc-ordes"
author = "sdsc-ordes"
release = "0.2.0"
release = "0.2.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "modos"
version = "0.2.0"
version = "0.2.1"
description = "SMOC Multi-Omics Digital Object System API"
authors = ["SDSC-ORDES"]
license = "Apache-2.0"
Expand Down

0 comments on commit 7f5a86a

Please sign in to comment.