From 6ac34951e86dcfa89439df0e3f6b60720f4a2142 Mon Sep 17 00:00:00 2001 From: Rafal Wojdyla Date: Fri, 3 May 2024 02:53:04 +0900 Subject: [PATCH] Add CD workflow --- .github/workflows/cd.yml | 86 ++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 3 +- .github/workflows/docs.yml | 3 +- 3 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..fff1a61 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,86 @@ +name: CD + +on: + push: + branches: + - main + tags: + - '*' + release: + types: [published] + +jobs: + packaging: + if: github.repository_owner == 'sgkit-dev' + name: Packaging + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.9' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build twine validate-pyproject[all] + - name: Check and install package + run: | + validate-pyproject pyproject.toml + python -m build + python -m twine check --strict dist/* + python -m pip install dist/*.whl + - name: Check vcf2zarr CLI + run: | + vcf2zarr --help + python -m bio2zarr vcf2zarr --help + - name: Check vcfpartition CLI + run: | + vcfpartition --help + python -m bio2zarr vcfpartition --help + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + if: github.repository_owner == 'sgkit-dev' && github.event_name == 'release' + needs: + - packaging + runs-on: ubuntu-latest + + environment: + name: pypi + url: https://pypi.org/p/bio2zarr + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - uses: pypa/gh-action-pypi-publish@release/v1 + + + publish-to-testpypi: + if: github.repository_owner == 'sgkit-dev' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + needs: + - packaging + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/bio2zarr + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 901ac96..a7a9225 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,8 @@ name: CI on: pull_request: push: - branches: [main, test] + branches: + - main jobs: pre-commit: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1686bf3..4c6f279 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,8 @@ name: Build Docs on: pull_request: push: - branches: [main, test] + branches: + - main tags: - '*'