Debian Codegraph @

.github/workflows/tests.yml

raw symbols SCIP
1 name: tests
2
3 on:
4 push:
5 branches:
6 - main
7 tags:
8 - v*
9 pull_request:
10 workflow_dispatch:
11
12 jobs:
13 run-tests:
14 strategy:
15 matrix:
16 config:
17 # [Python version, tox env, timezone]
18 - ["3.8", "py38", "Australia/Sydney"]
19 - ["3.9", "py39", "UTC"]
20 - ["3.10", "py310", "Asia/Singapore"]
21 - ["3.11", "py311", "Pacific/Bougainville"]
22 - ["3.12", "py312", "Europe/London"]
23 - ["3.12", "build", "Europe/Moscow"]
24 - ["3.13", "py313", "America/Dawson"]
25 - ["3.13", "docs", "Europe/Berlin"]
26
27 runs-on: ubuntu-latest
28 name: ${{ matrix.config[1] }}
29 steps:
30 - uses: actions/checkout@v4
31 - name: Set up Python
32 uses: actions/setup-python@v5
33 with:
34 python-version: ${{ matrix.config[0] }}
35 - name: Pip cache
36 uses: actions/cache@v4
37 with:
38 path: ~/.cache/pip
39 key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
40 restore-keys: |
41 ${{ runner.os }}-pip-${{ matrix.config[0] }}-
42 ${{ runner.os }}-pip-
43 - name: Install dependencies
44 run: |
45 python -m pip install --upgrade pip
46 pip install tox
47 - name: Test
48 run: |
49 export TZ="{{ matrix.config[2] }}"
50 # Debug and check the default time zone
51 python3 -c 'import time; time.tzset(); print(time.strftime("%X %x %Z"))'
52 tox -e ${{ matrix.config[1] }}
53
54 deploy-tag-to-pypi:
55 # only deploy on tags, see https://stackoverflow.com/a/58478262/1320237
56 if: startsWith(github.ref, 'refs/tags/v')
57 needs:
58 - run-tests
59 runs-on: ubuntu-latest
60 # This environment stores the TWINE_USERNAME and TWINE_PASSWORD
61 # see https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
62 environment:
63 name: PyPI
64 url: https://pypi.org/project/recurring-ical-events/
65 # after using the environment, we need to make the secrets available
66 # see https://docs.github.com/en/actions/security-guides/encrypted-secrets#example-using-bash
67 env:
68 TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
69 TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
70 steps:
71 - uses: actions/checkout@v4
72 - name: Set up Python
73 uses: actions/setup-python@v5
74 with:
75 python-version: "3.12"
76 - name: Install dependencies
77 run: |
78 python -m pip install --upgrade pip
79 pip install --upgrade wheel twine build
80 - name: remove old files
81 run: rm -rf dist/*
82 - name: build distribution files
83 run: python -m build
84 - name: deploy to pypi
85 run: |
86 # You will have to set the variables TWINE_USERNAME and TWINE_PASSWORD
87 # You can use a token specific to your project by setting the user name to
88 # __token__ and the password to the token given to you by the PyPI project.
89 # sources:
90 # - https://shambu2k.hashnode.dev/gitlab-to-pypi
91 # - http://blog.octomy.org/2020/11/deploying-python-pacakges-to-pypi-using.html?m=1
92 # Also, set the tags as protected to allow the secrets to be used.
93 # see https://docs.gitlab.com/ee/user/project/protected_tags.html
94 if [ -z "$TWINE_USERNAME" ]; then
95 echo "WARNING: TWINE_USERNAME not set!"
96 fi
97 if [ -z "$TWINE_PASSWORD" ]; then
98 echo "WARNING: TWINE_PASSWORD not set!"
99 fi
100 twine check dist/*
101 twine upload dist/*
102
103 deploy-github-release:
104 # only deploy on tags, see https://stackoverflow.com/a/58478262/1320237
105 if: startsWith(github.ref, 'refs/tags/v')
106 needs:
107 - run-tests
108 - deploy-tag-to-pypi
109 runs-on: ubuntu-latest
110 environment:
111 name: github-release
112 steps:
113 - uses: actions/checkout@v4
114 - name: Create GitHub release from tag
115 uses: ncipollo/release-action@v1
116 with:
117 allowUpdates: true
118 body: "To view the changes, please see the [Changelog](https://recurring-ical-events.readthedocs.io/en/latest/changelog.html). This release can be installed from [PyPI](https://pypi.org/project/recurring-ical-events/#history)."
119 generateReleaseNotes: false