8000 CI: Add workflow to publish on release · nipype/pydra-nipype1@3fd542a · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fd542a

Browse files
committed
CI: Add workflow to publish on release
1 parent 0b5142a commit 3fd542a

File tree

2 files changed

+98
-83
lines changed

2 files changed

+98
-83
lines changed

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: publish
2+
3+
on:
4+
# Trigger this workflow when a release is created.
5+
release:
6+
types:
7+
- published
8+
9+
permission:
10+
# Allow checkout of the project.
11+
contents: read
12+
13+
env:
14+
# Default Python version on which jobs are run.
15+
DEFAULT_PYTHON_VERSION: '3.9'
16+
17+
jobs:
18+
publish:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
25+
- name: Install build frontend
26+
run: python -m pip install build
27+
- name: Build distribution package
28+
run: python -m build
29+
- name: Publish to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/pythonpackage.yml

Lines changed: 66 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ env:
1010
on:
1111
push:
1212
branches: [ main ]
13-
tags: [ '*' ]
1413
pull_request:
1514
branches: [ main ]
1615

@@ -19,101 +18,85 @@ jobs:
1918
runs-on: ubuntu-latest
2019
strategy:
2120
matrix:
22-
python-version: ['3.7', '3.11'] # Check oldest and newest versions
23-
pip-flags: ['', '--editable']
21+
python-version: [ '3.7', '3.11' ] # Check oldest and newest versions
22+
pip-flags: [ '', '--editable' ]
2423
pydra:
25-
- 'pydra'
26-
- '--editable git+https://github.com/nipype/pydra.git#egg=pydra'
24+
- 'pydra'
25+
- '--editable git+https://github.com/nipype/pydra.git#egg=pydra'
2726

2827
steps:
29-
- uses: actions/checkout@v2
30-
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v2
32-
with:
33-
python-version: ${{ matrix.python-version }}
34-
- name: Install build dependencies
35-
run: |
36-
python -m pip install --upgrade pip
37-
- name: Install Pydra
38-
run: |
39-
pip install ${{ matrix.pydra }}
40-
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
41-
- name: Install task package
42-
run: |
43-
pip install ${{ matrix.pip-flags }} ".[dev]"
44-
python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
45-
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
28+
- uses: actions/checkout@v2
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Install build dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
- name: Install Pydra
37+
run: |
38+
pip install ${{ matrix.pydra }}
39+
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
40+
- name: Install task package
41+
run: |
42+
pip install ${{ matrix.pip-flags }} ".[dev]"
43+
python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
44+
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
4645
4746
test:
4847
runs-on: ubuntu-latest
4948
strategy:
5049
matrix:
51-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
50+
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
5251

5352
steps:
54-
- uses: actions/checkout@v2
55-
- name: Set up Python ${{ matrix.python-version }}
56-
uses: actions/setup-python@v2
57-
with:
58-
python-version: ${{ matrix.python-version }}
59-
- name: Set up NeuroDebian
60-
run: bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh)
61-
- name: Install FSL
62-
run: sudo apt-get install -y fsl
63-
- name: Install build dependencies
64-
run: |
65-
python -m pip install --upgrade pip
66-
- name: Install task package
67-
run: |
68-
pip install ".[test]"
69-
python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
70-
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
71-
- name: Test with pytest
72-
run: |
73-
source /etc/fsl/fsl.sh
74-
pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE \
75-
--cov pydra.tasks.$SUBPACKAGE --cov-report xml
76-
- uses: codecov/codecov-action@v1
77-
if: ${{ always() }}
53+
- uses: actions/checkout@v2
54+
- name: Set up Python ${{ matrix.python-version }}
55+
uses: actions/setup-python@v2
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
- name: Set up NeuroDebian
59+
run: bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh)
60+
- name: Install FSL
61+
run: sudo apt-get install -y fsl
62+
- name: Install build dependencies
63+
run: |
64+
python -m pip install --upgrade pip
65+
- name: Install task package
66+
run: |
67+
pip install ".[test]"
68+
python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
69+
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
70+
- name: Test with pytest
71+
run: |
72+
source /etc/fsl/fsl.sh
73+
pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE \
74+
--cov pydra.tasks.$SUBPACKAGE --cov-report xml
75+
- uses: codecov/codecov-action@v1
76+
if: ${{ always() }}
7877

7978
deploy:
80-
needs: [devcheck, test]
79+
needs: [ devcheck, test ]
8180
runs-on: ubuntu-latest
8281
strategy:
8382
matrix:
84-
python-version: [3.9]
83+
python-version: [ '3.9' ]
8584
steps:
86-
- uses: actions/checkout@v2
87-
with:
88-
submodules: recursive
89-
fetch-depth: 0
90-
- name: Set up Python ${{ matrix.python-version }}
91-
uses: actions/setup-python@v2
92-
with:
93-
python-version: ${{ matrix.python-version }}
94-
- name: Install build tools
95-
run: python -m pip install build twine
96-
- name: Build source and wheel distributions
97-
run: python -m build
98-
- name: Check distributions
99-
run: twine check dist/*
100-
- uses: actions/upload-artifact@v2
101-
with:
102-
name: distributions
103-
path: dist/
104-
# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
105-
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
106-
# [0] https://github.community/t/16928
107-
# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
108-
- name: Check for PyPI token on tag
109-
id: deployable
110-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
111-
env:
112-
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
113-
run: if [ -n "$PYPI_API_TOKEN" ]; then echo ::set-output name=DEPLOY::true; fi
114-
- name: Upload to PyPI
115-
if: steps.deployable.outputs.DEPLOY
116-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 # v1.4.2
117-
with:
118-
user: __token__
119-
password: ${{ secrets.PYPI_API_TOKEN }}
85+
- uses: actions/checkout@v2
86+
with:
87+
submodules: recursive
88+
fetch-depth: 0
89+
- name: Set up Python ${{ matrix.python-version }}
90+
uses: actions/setup-python@v2
91+
with:
92+
python-version: ${{ matrix.python-version }}
93+
- name: Install build tools
94+
run: python -m pip install build twine
95+
- name: Build source and wheel distributions
96+
run: python -m build
97+
- name: Check distributions
98+
run: twine check dist/*
99+
- uses: actions/upload-artifact@v2
100+
with:
101+
name: distributions
102+
path: dist/

0 commit comments

Comments
 (0)
0