Skip to content

Commit efed1b1

Browse files
authored
Merge pull request #13 from nipype/develop
fixed up tagging of versions
2 parents ef63ea0 + 7d1f7f4 commit efed1b1

File tree

1 file changed

+115
-14
lines changed

1 file changed

+115
-14
lines changed

.github/workflows/ci-cd.yaml

Lines changed: 115 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ jobs:
7676
with:
7777
name: converted-nipype
7878
path: pydra/tasks/afni/auto
79+
7980
- name: Strip auto package from gitignore so it is included in package
8081
run: |
8182
sed -i '/\/pydra\/tasks\/afni\/auto/d' .gitignore
82-
sed -i '/^_version.py/d' .gitignore
83+
sed -i '/^_version.py/d' .gitignore
84+
8385
- name: Set up Python ${{ matrix.python-version }}
8486
uses: actions/setup-python@v5
8587
with:
@@ -251,53 +253,152 @@ jobs:
251253
needs: [deploy-fileformats-extras]
252254
runs-on: ubuntu-latest
253255
steps:
254-
- uses: actions/checkout@v3
256+
257+
- name: Checkout repository
258+
uses: actions/checkout@v4
255259
with:
256260
submodules: recursive
257261
fetch-depth: 0
258-
- name: Download tasks converted from Nipype
262+
263+
- name: Set up Git user
264+
run: |
265+
git config --local user.email "[email protected]"
266+
git config --local user.name "GitHub Action"
267+
268+
- name: Get latest version tag
269+
id: latest_tag
270+
run: |
271+
git fetch --tags
272+
echo "TAG=$(git tag -l | grep 'v.*' | tail -n 1 | awk -F post '{print $1}')" >> $GITHUB_OUTPUT
273+
274+
- name: Revert to latest tag
275+
if: github.event_name == 'repository_dispatch'
276+
run: git checkout ${{ steps.latest_tag.outputs.TAG }}
277+
278+
- name: Download tasks converted from Nipype
259279
uses: actions/download-artifact@v4
260280
with:
261281
name: converted-nipype
262282
path: pydra/tasks/afni/auto
263-
- name: Tag release with a post-release based on Nipype and Nipype2Pydra versions
264-
if: github.event_name == 'repository_dispatch'
265-
run: |
266-
TAG=$(git tag -l | tail -n 1 | awk -F post '{print $1}')
267-
POST=$(python -c "from pydra.tasks.afni.auto._post_release import *; print(post_release)")
268-
git checkout $TAG
269-
git add -f pydra/tasks/afni/auto/_version.py
270-
git commit -am"added auto-generated version to make new tag for package version"
271-
git tag ${TAG}post${POST}
283+
284+
- name: Show the contents of the auto-generated tasks
285+
run: tree pydra
272286
- name: Set up Python
273-
uses: actions/setup-python@v4
287+
uses: actions/setup-python@v5
274288
with:
275289
python-version: '3.11'
290+
276291
- name: Install build tools
277292
run: python -m pip install build twine
293+
278294
- name: Strip auto package from gitignore so it is included in package
279295
run: |
280296
sed -i '/\/pydra\/tasks\/afni\/auto/d' .gitignore
297+
cat .gitignore
298+
299+
- name: Install task package to calculate post-release tag
300+
run: |
301+
pip install ".[test]"
302+
303+
- name: Generate post-release tag based on Nipype and Nipype2Pydra versions
304+
id: post_release_tag
305+
run: |
306+
POST=$(python -c "from pydra.tasks.afni.auto._post_release import *; print(post_release)")
307+
echo "TAG=${{ steps.latest_tag.outputs.TAG }}post${POST}" >> $GITHUB_OUTPUT
308+
309+
- name: Add auto directory to git repo
310+
if: github.event_name == 'release' || github.event_name == 'repository_dispatch'
311+
run: |
312+
git add pydra/tasks/afni/auto
313+
git commit -am"added auto-generated version to make new tag for package version"
314+
git status
315+
316+
- name: Overwrite the tag of release event with latest commit (i.e. including the auto directory)
317+
if: github.event_name == 'release'
318+
run: |
319+
git tag -d ${{ steps.latest_tag.outputs.TAG }};
320+
git tag ${{ steps.latest_tag.outputs.TAG }};
321+
322+
- name: Tag repo with the post-release
323+
if: github.event_name == 'repository_dispatch'
324+
run: git tag ${{ steps.post_release_tag.outputs.TAG }}
325+
281326
- name: Build source and wheel distributions
282327
run: python -m build .
328+
283329
- name: Check distributions
284330
run: twine check dist/*
331+
285332
- uses: actions/upload-artifact@v4
286333
with:
287334
name: distributions
288335
path: dist/
336+
289337
- name: Check for PyPI token on tag
290338
id: deployable
291339
if: github.event_name == 'release'
292340
env:
293341
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
294342
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
343+
295344
- name: Upload to PyPI
296345
if: steps.deployable.outputs.DEPLOY
297346
uses: pypa/gh-action-pypi-publish@release/v1
298347
with:
299348
user: __token__
300-
password: ${{ secrets.PYPI_API_TOKEN }}
349+
password: ${{ secrets.PYPI_API_TOKEN }}
350+
351+
- name: Create post-release release for releases triggered by nipype2pydra dispatches
352+
if: steps.deployable.outputs.DEPLOY && github.event_name == 'repository_dispatch'
353+
uses: actions/create-release@v1
354+
env:
355+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
356+
with:
357+
tag_name: ${{ steps.post_release_tag.outputs.TAG }}
358+
release_name: Release ${{ steps.post_release_tag.outputs.TAG }}
359+
draft: false
360+
prerelease: false
361+
362+
# docs:
363+
# needs: deploy
364+
# environment:
365+
# name: github-pages
366+
# url: ${{ steps.deployment.outputs.page_url }}
367+
# runs-on: ubuntu-latest
368+
# steps:
369+
# - uses: actions/checkout@v4
370+
# - uses: actions/setup-python@v5
371+
# with:
372+
# python-version: '3.x'
373+
374+
# - name: Download tasks converted from Nipype
375+
# uses: actions/download-artifact@v4
376+
# with:
377+
# name: converted-nipype
378+
# path: pydra/tasks/freesurfer/auto
379+
380+
# - name: Install dependencies
381+
# run: python -m pip install related-packages/fileformats .[doc]
382+
383+
# - name: Build docs
384+
# run: |
385+
# pushd docs
386+
# make html
387+
# popd
388+
389+
# - name: Upload artifact
390+
# uses: actions/upload-pages-artifact@v3
391+
# with:
392+
# path: 'docs/build/html'
393+
394+
# - name: Setup GitHub Pages
395+
# if: github.event_name == 'release' || github.event_name == 'repository_dispatch'
396+
# uses: actions/configure-pages@v4
397+
398+
# - name: Deploy to GitHub Pages
399+
# if: github.event_name == 'release' || github.event_name == 'repository_dispatch'
400+
# id: deployment
401+
# uses: actions/deploy-pages@v4
301402

302403
# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
303404
# Secrets are not accessible in the if: condition [0], so set an output variable [1]

0 commit comments

Comments
 (0)