2021-11-22 21:17:53 +00:00
|
|
|
name: tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-10-12 02:19:57 +00:00
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
tags:
|
|
|
|
- v*
|
2021-11-22 21:17:53 +00:00
|
|
|
pull_request:
|
|
|
|
schedule:
|
|
|
|
- cron: '14 7 * * 0' # run once a week on Sunday
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
2022-10-12 02:19:57 +00:00
|
|
|
run-tests:
|
2021-11-22 21:17:53 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
config:
|
|
|
|
# [Python version, tox env]
|
2022-08-19 13:47:43 +00:00
|
|
|
- ["3.7", "py37"]
|
2021-11-22 21:17:53 +00:00
|
|
|
- ["3.8", "py38"]
|
|
|
|
- ["3.9", "py39"]
|
|
|
|
- ["3.10", "py310"]
|
2022-08-14 10:40:39 +00:00
|
|
|
- ["pypy-3.9", "pypy3"]
|
2022-08-13 09:19:33 +00:00
|
|
|
- ["3.10", "docs"]
|
2023-08-28 09:53:33 +00:00
|
|
|
- ["3.11", "py311"]
|
2021-11-22 21:17:53 +00:00
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: ${{ matrix.config[1] }}
|
|
|
|
steps:
|
2023-11-20 16:39:06 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-11-22 21:17:53 +00:00
|
|
|
- name: Set up Python
|
2023-08-30 06:36:47 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-11-22 21:17:53 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.config[0] }}
|
2023-11-20 16:39:06 +00:00
|
|
|
# for caching, see
|
2023-08-30 06:48:55 +00:00
|
|
|
# https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages
|
2023-08-30 06:36:47 +00:00
|
|
|
cache: 'pip'
|
2023-08-30 06:48:55 +00:00
|
|
|
cache-dependency-path: |
|
|
|
|
setup.*
|
|
|
|
tox.ini
|
|
|
|
requirements*.txt
|
2021-11-22 21:17:53 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
|
|
|
pip install tox
|
|
|
|
- name: Test
|
|
|
|
run: tox -e ${{ matrix.config[1] }}
|
|
|
|
- name: Coverage
|
|
|
|
run: |
|
|
|
|
pip install coveralls coverage-python-version
|
|
|
|
coveralls --service=github
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2022-10-12 02:19:57 +00:00
|
|
|
|
|
|
|
deploy-tag-to-pypi:
|
|
|
|
# only deploy on tags, see https://stackoverflow.com/a/58478262/1320237
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
needs:
|
|
|
|
- run-tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
# This environment stores the TWINE_USERNAME and TWINE_PASSWORD
|
|
|
|
# see https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
|
|
|
|
environment:
|
|
|
|
name: PyPI
|
|
|
|
url: https://pypi.org/project/icalendar/
|
|
|
|
# after using the environment, we need to make the secrets available
|
|
|
|
# see https://docs.github.com/en/actions/security-guides/encrypted-secrets#example-using-bash
|
|
|
|
env:
|
|
|
|
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
|
|
|
|
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
|
|
|
|
steps:
|
2023-11-20 16:39:06 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-10-12 02:19:57 +00:00
|
|
|
- name: Set up Python
|
2023-11-20 16:39:06 +00:00
|
|
|
uses: actions/setup-python@v4
|
2022-10-12 02:19:57 +00:00
|
|
|
with:
|
|
|
|
python-version: "3.9"
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
|
|
|
pip install wheel twine
|
|
|
|
- name: Check the tag
|
|
|
|
run: |
|
|
|
|
PACKAGE_VERSION=`python setup.py --version`
|
|
|
|
TAG_NAME=v$PACKAGE_VERSION
|
|
|
|
echo "Package version $PACKAGE_VERSION with possible tag name $TAG_NAME on $GITHUB_REF_NAME"
|
|
|
|
# test that the tag represents the version
|
|
|
|
# see https://docs.github.com/en/actions/learn-github-actions/environment-variables
|
|
|
|
if [ "$TAG_NAME" != "$GITHUB_REF_NAME" ]; then
|
|
|
|
echo "ERROR: This tag is for the wrong version. Got \"$GITHUB_REF_NAME\" expected \"$TAG_NAME\"."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
- name: remove old files
|
|
|
|
run: rm -rf dist/*
|
|
|
|
- name: build distribution files
|
|
|
|
run: python setup.py bdist_wheel sdist
|
|
|
|
- name: deploy to pypi
|
|
|
|
run: |
|
|
|
|
# You will have to set the variables TWINE_USERNAME and TWINE_PASSWORD
|
|
|
|
# You can use a token specific to your project by setting the user name to
|
|
|
|
# __token__ and the password to the token given to you by the PyPI project.
|
|
|
|
# sources:
|
|
|
|
# - https://shambu2k.hashnode.dev/gitlab-to-pypi
|
|
|
|
# - http://blog.octomy.org/2020/11/deploying-python-pacakges-to-pypi-using.html?m=1
|
|
|
|
if [ -z "$TWINE_USERNAME" ]; then
|
|
|
|
echo "WARNING: TWINE_USERNAME not set!"
|
|
|
|
fi
|
|
|
|
if [ -z "$TWINE_PASSWORD" ]; then
|
|
|
|
echo "WARNING: TWINE_PASSWORD not set!"
|
|
|
|
fi
|
|
|
|
twine check dist/*
|
|
|
|
twine upload dist/*
|
2023-09-30 09:25:21 +00:00
|
|
|
|
2023-10-25 09:35:58 +00:00
|
|
|
deploy-github-release:
|
|
|
|
# only deploy on tags, see https://stackoverflow.com/a/58478262/1320237
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
needs:
|
|
|
|
- run-tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment:
|
|
|
|
name: github-release
|
|
|
|
steps:
|
2023-11-20 16:39:06 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-10-25 09:35:58 +00:00
|
|
|
- name: create release
|
|
|
|
uses: elgohr/Github-Release-Action@v4
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
|
|
with:
|
|
|
|
title: ${{ github.ref_name }}
|