Skip to content

Commit

Permalink
Merge pull request #216 from wouterpeere/issue212-auto-release-pypi-v…
Browse files Browse the repository at this point in the history
…ersion

Issue212 auto release pypi version
  • Loading branch information
wouterpeere authored Jan 26, 2024
2 parents 68cdd41 + ed71ba1 commit 00b9928
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 111 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CD to pypi

on:
push:
branches:
- master

permissions:
contents: write

jobs:
build:
if: "contains(github.event.head_commit.message, 'auto-update version')"
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.12"
- 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-testpypi:
needs: build
if: "contains(github.event.head_commit.message, 'rc') || contains(github.event.head_commit.message, 'dev')"
name: Publish 📦 to TestPyPI
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/ghetool

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TESTPYPI }}

publish-to-pypi:
needs: build
if: "!contains(github.event.head_commit.message, 'rc') && !contains(github.event.head_commit.message, 'dev')"
name: Publish 📦 to PyPI
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/ghetool

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://pypi.org/legacy/
user: __token__
password: ${{ secrets.PYPI }}
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docs
name: Create docs
on: [push, release]

jobs:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: A new release

on:
release:
types: [ published ]

permissions:
contents: write

jobs:
unit-tests:
name: release tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest-cov
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/unit-tests --cov=./ --cov-report=xml

create-tag:
name: Set tag
needs: unit-tests
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ""
STRIPPED_VERSION: ""
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{ secrets.TOKEN }}
persist-credentials: false

- name: Set output
id: vars
run: echo "RELEASE_VERSION=${{ github.event.release.name }}" >> $GITHUB_ENV

- name: Check output
id: split
run: echo "STRIPPED_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV

- name: Set up Git
run: git config --global user.email "${{ secrets.EMAIL }}" && git config --global user.name "GitHub Actions"

- name: Update version in version file and commit
run: |
echo "${STRIPPED_VERSION}" > VERSION.txt
cat VERSION.txt
git add VERSION.txt
git commit -am "Release: auto-update version to ${RELEASE_VERSION}"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.TOKEN }}
80 changes: 5 additions & 75 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
name: Tests
name: Tests Commit

on:
- push
- pull_request

jobs:

test_methods:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
Expand All @@ -27,90 +25,22 @@ jobs:
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

test_general:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/general_tests --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

test_examples:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/test_examples.py --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

test_validation:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/test_validation.py --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

unit-tests:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
pip install pytest-cov
pip install -e .
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Tests PR

on:
- pull_request

jobs:

test_methods:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/methods/test_methods.py --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

test_general:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/general_tests --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

test_examples:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/test_examples.py --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

test_validation:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/test_validation.py --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

unit-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest-cov
pip install -e .
- name: Test with pytest
run: pytest GHEtool/test/unit-tests --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
Loading

0 comments on commit 00b9928

Please sign in to comment.