Skip to content

Commit 63de6c2

Browse files
authored
Create main.yml
Based on [etils GitHub Action](https://github.com/google/etils/blob/main/.github/workflows/pytest_and_autopublish.yml). References tests that are not currently in the repository.
1 parent 73ba5bd commit 63de6c2

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/main.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Unittests & Auto-publish
2+
3+
# Allow to trigger the workflow manually (e.g. when deps changes)
4+
on: [push, workflow_dispatch]
5+
6+
jobs:
7+
unittest-job:
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
python-version: ['3.10', '3.11', '3.12']
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 30
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}
17+
cancel-in-progress: true
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
# Install deps
23+
- uses: actions/setup-python@v4
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- run: pip --version
27+
- run: pip install -e .
28+
- run: pip freeze
29+
30+
# Run tests
31+
- name: Run core tests
32+
run: python -m unittest
33+
34+
# Auto-publish when version is increased
35+
publish-job:
36+
# Only try to publish if:
37+
# * Repo is self (prevents running from forks)
38+
# * Branch is `main`
39+
if: |
40+
github.repository == 'google/etils'
41+
&& github.ref == 'refs/heads/main'
42+
needs: unittest-job # Only publish after tests are successful
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
timeout-minutes: 30
47+
48+
steps:
49+
# Publish the package (if local `__version__` > pip version)
50+
- uses: etils-actions/pypi-auto-publish@v1
51+
with:
52+
pypi-token: ${{ secrets.PYPI_API_TOKEN }}
53+
gh-token: ${{ secrets.GH_TOKEN }}
54+
parse-changelog: true

0 commit comments

Comments
 (0)