11name : release
22
3- # Automate deployment to PyPI when creating a release tag vX.Y.Z
4- # will only be published to PyPI if the git tag matches the release version
5- # and the pre-commit and tests pass
3+ # Automate plubishing to PyPI and TestPyPI. When pushing a release tag vX.Y.Z,
4+ # the workflow will publish to PyPI. When the 'test-release' label is active on
5+ # a PR, the workflow will publish to TestPyPI on each update. In both cases it
6+ # is checked if pre-commit and the tests pass. When a release tag is pushed it
7+ # will in addition check if the tag and aiida-core version and tag match.
68
79on :
10+ # pull request event we use for test releases
11+ pull_request :
12+ branches-ignore : [gh-pages]
13+ paths-ignore : [docs/**]
14+ # tag push event we use for the official release
815 push :
916 tags :
1017 - v[0-9]+.[0-9]+.[0-9]+*
@@ -16,21 +23,24 @@ jobs:
1623
1724 check-release-tag :
1825
19- # Only run this job on the main repository and not on forks
20- if : github.repository == 'aiidateam/aiida-core'
26+ if : github.repository == 'aiidateam/aiida-core' && startsWith(github.ref, 'refs/tags/')
2127 runs-on : ubuntu-24.04
2228
2329 steps :
24- - uses : actions/checkout@v4
30+ - name : Checkout repo
31+ uses : actions/checkout@v4
32+
2533 - name : Set up Python 3.9
2634 uses : actions/setup-python@v5
2735 with :
2836 python-version : ' 3.9'
29- - run : python .github/workflows/check_release_tag.py $GITHUB_REF
37+
38+ - name : Check tag
39+ run : python .github/workflows/check_release_tag.py $GITHUB_REF
3040
3141 pre-commit :
42+ if : startsWith(github.ref, 'refs/tags/') || (github.event_name == 'pull_request' && contains(fromJson(toJson(github.event.pull_request.labels)).*.name, 'test-release'))
3243
33- needs : [check-release-tag]
3444 runs-on : ubuntu-24.04
3545 timeout-minutes : 30
3646
4858 run : pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
4959
5060 tests :
61+ if : startsWith(github.ref, 'refs/tags/') || (github.event_name == 'pull_request' && contains(fromJson(toJson(github.event.pull_request.labels)).*.name, 'test-release'))
5162
52- needs : [check-release-tag]
5363 runs-on : ubuntu-24.04
5464 timeout-minutes : 30
5565
6979 - name : Run sub-set of test suite
7080 run : pytest -s -m requires_rmq --db-backend=sqlite tests/
7181
72- publish :
82+ publish-pypi :
83+ if : startsWith(github.ref, 'refs/tags/')
7384
7485 name : Publish to PyPI
7586
@@ -93,3 +104,31 @@ jobs:
93104 env :
94105 FLIT_USERNAME : __token__
95106 FLIT_PASSWORD : ${{ secrets.PYPI_KEY }}
107+ FLIT_INDEX_URL : https://pypi.org/
108+
109+ publish-testpypi :
110+ if : github.event_name == 'pull_request' && contains(fromJson(toJson(github.event.pull_request.labels)).*.name, 'test-release')
111+
112+ name : Publish to test PyPI
113+
114+ needs : [pre-commit, tests]
115+
116+ runs-on : ubuntu-24.04
117+
118+ steps :
119+ - name : Checkout source
120+ uses : actions/checkout@v4
121+ - name : Set up Python 3.9
122+ uses : actions/setup-python@v5
123+ with :
124+ python-version : ' 3.9'
125+ - name : install flit
126+ run : |
127+ pip install flit~=3.4
128+ - name : Build and publish
129+ run : |
130+ flit publish
131+ env :
132+ FLIT_USERNAME : __token__
133+ FLIT_PASSWORD : ${{ secrets.TEST_PYPI_KEY }}
134+ FLIT_INDEX_URL : https://test.pypi.org/legacy/
0 commit comments