Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Migrate CI & CD to GitHub Actions #322

Merged
merged 18 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# ref: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows

name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on:
push:
branches:
- main

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
wheel sdist setuptools_scm
--user
- name: Build a binary wheel and a source tarball
run: python3 setup.py sdist bdist_wheel
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/


# This will be triggered everytime when tag is created
publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/stock-indicators
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Tag and draft release note
LeeDongGeon1996 marked this conversation as resolved.
Show resolved Hide resolved
uses: ncipollo/release-action@v1
with:
body: "We’ve released a new Stock Indicators for Python. See [Skender.Stock.Indicators @ PyPI.org](${{ vars.PYPI_DOWNLOAD_PREFIX }}${{ github.ref_name }}) for more information."
DaveSkender marked this conversation as resolved.
Show resolved Hide resolved
generateReleaseNotes: true
draft: true
DaveSkender marked this conversation as resolved.
Show resolved Hide resolved


# This will be triggered everytime when commit is pushed on main branch
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/stock-indicators

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Stock Indicators for Python

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.8", "3.12"]
dotnet-version: ["6.0.x", "8.0.x"]

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt

- name: Run Tests
run: |
pytest -vr A tests