Skip to content

Commit

Permalink
CICD through GitHub Actions (#31)
Browse files Browse the repository at this point in the history
* Publish coverage to codacy

* Remove distribution files

* Publish to PyPI, TestPyPI

* Bump version to 2024.12.1
  • Loading branch information
KiranReddy0808 authored Dec 21, 2024
1 parent c3a4776 commit a7b356f
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 4 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Publish to PyPI and TestPyPI

on: push

jobs:
build:
name: Build Distribution Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.12
- name: Install dependencies and build package
run: |
python3 -m pip install --upgrade pip
python3 -m pip install poetry
python3 -m poetry install
python3 -m poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-distribution-packages
path: dist/*
publish-testpypi:
name: Publish to TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/torchvinecopulib/
permissions:
id-token: write
# contents: write

steps:
- name: Download the distribution packages
uses: actions/download-artifact@v4
with:
name: python-distribution-packages
path: dist/
- name: Publish distribution
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
skip-existing: true
repository-url: https://test.pypi.org/legacy/

publish-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs: publish-testpypi
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/torchvinecopulib/
permissions:
id-token: write
# contents: write

steps:
- name: Download the distribution packages
uses: actions/download-artifact@v4
with:
name: python-distribution-packages
path: dist/
- name: Publish distribution
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
skip-existing: true

github-release:
name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
needs: publish-testpypi
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write

steps:
- name: Download the distribution packages
uses: actions/download-artifact@v4
with:
name: python-distribution-packages
path: dist/
- name: Sign the distribution packages
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Github Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
16 changes: 14 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
pull_request:
branches: ["main"]

workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
Expand All @@ -29,7 +31,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install "pyvinecopulib==0.6.6"
python -m pip install flake8 pytest numpy scipy torch pot matplotlib scikit-learn pandas
python -m pip install flake8 pytest numpy scipy torch pot matplotlib scikit-learn pandas coverage
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
Expand All @@ -41,4 +43,14 @@ jobs:
run: |
python -c "import sys; print(sys.version)"
python -c "import torch; print(torch.cuda.is_available())"
pytest ./tests --verbose
coverage run -m pytest ./tests
coverage xml
coverage report
coverage html
- name: Upload test coverage to Codacy
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' }}
run: |
export CODACY_API_BASE_URL=${{ secrets.CODACY_API_BASE_URL }}
export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }}
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ./coverage.xml
Binary file removed dist/torchvinecopulib-2024.10.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/torchvinecopulib-2024.10.1.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package-mode = true
license = "GNU GPLv3"
name = "torchvinecopulib"
version = "2024.10.1"
version = "2024.12.1"
description = "yet another vine copula library for PyTorch."
authors = ["Tuoyuan Cheng <[email protected]>"]
maintainers = ["Xiaosheng You <[email protected]>"]
Expand Down
1 change: 0 additions & 1 deletion torchvinecopulib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
"util",
"vinecop",
]
__version__ = "2024.10.1"

0 comments on commit a7b356f

Please sign in to comment.