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

Updating CI/CD #10

Merged
merged 9 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions .circleci/config.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/buildandpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Publish

on:
push:
tags:
- "v*"
branches:
- main

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry requests packaging

- name: Check and Publish to PyPI
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
CURRENT_VERSION=$(poetry version -s)
PACKAGE_NAME="ctdfjorder"
PYPI_URL="https://pypi.org/pypi/${PACKAGE_NAME}/json"
EXISTING_VERSION=$(curl -s $PYPI_URL | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")

if [ "$(python -c "from packaging.version import parse; print(parse('$CURRENT_VERSION') > parse('$EXISTING_VERSION'))")" == "True" ]; then
poetry config pypi-token.pypi "$PYPI_API_TOKEN"
poetry publish --build
else
echo "Current version ($CURRENT_VERSION) is not greater than existing version ($EXISTING_VERSION). Skipping publish."
fi
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test

on:
pull_request:
branches:
- "**"

jobs:
test-python:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry

- name: Install dependencies
run: poetry install

- name: Run tests
run: |
poetry run pytest --junitxml=junit.xml || {
if [ $? -eq 5 ]; then
echo 'Did not find any tests to run.';
else
exit 1;
fi
}

- name: Store test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: junit-results
path: junit.xml
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = ["poetry-core>=1.9.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
package-mode = true
Expand Down
Loading