Skip to content

Commit

Permalink
Set up GitHub Actions (#42)
Browse files Browse the repository at this point in the history
* add basic ci/cd workflow to test install

* fix location of actions workflow

* fix matrix for os and python version

* print conda python version

* Update build.yml

* python3.8 for ci

* use local pip install for cicd

* add publish workflow
  • Loading branch information
elbeejay authored and g4brielvs committed Feb 2, 2024
1 parent 0d7c458 commit dfbfc36
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow to test installation of the GOSTnets package

name: build-package

# Controls when the action will run.
# Triggers the workflow on push or pull request events as well as on
# a monthly cron schedule. Also allows manual triggering.
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

# Set up jobs to spin up a virtual machine and build the package on each of
# the operating systems we want to test on. We use a matrix to run the same
# job on multiple operating systems and Python versions. At this time our
# 'test' is very simple and consists of installing the package and trying
# to import it.
jobs:
test-os:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} with minconda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
auto-update-conda: true
- name: Print Python Version
run: |
python -V
- name: Install GOSTnets
run: |
pip install .
- name: Test GOSTnets install
run: |
python -c "import GOSTnets"
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on:
release:
types: [published]

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.8"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

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/GOSTnets
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

0 comments on commit dfbfc36

Please sign in to comment.