Merge pull request #745 from yarikoptic/enh-release #101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto-release on PR merge | |
on: | |
# ATM, this is the closest trigger to a PR merging | |
push: | |
branches: | |
- master | |
jobs: | |
auto-release: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download auto | |
run: | | |
#curl -vL -o - "$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/latest | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')" | gunzip > ~/auto | |
# Pin to 10.16.1 so we don't break if & when | |
# <https://github.com/intuit/auto/issues/1778> is fixed. | |
wget -O- https://github.com/intuit/auto/releases/download/v10.16.1/auto-linux.gz | gunzip > ~/auto | |
chmod a+x ~/auto | |
- name: Query 'auto' on type of the release | |
id: auto-version | |
run: | | |
# to be able to debug if something goes wrong | |
set -o pipefail | |
~/auto version -vv | tee /tmp/auto-version | |
version="$(sed -ne '/Calculated SEMVER bump:/s,.*: *,,p' /tmp/auto-version)" | |
echo "version=$version" >> "$GITHUB_OUTPUT" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Python | |
if: steps.auto-version.outputs.version != '' | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '^3.8' | |
- name: Install Python dependencies | |
if: steps.auto-version.outputs.version != '' | |
run: python -m pip install build twine | |
- name: Create release | |
if: steps.auto-version.outputs.version != '' | |
run: ~/auto shipit | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build & upload to PyPI | |
if: steps.auto-version.outputs.version != '' | |
run: | | |
python -m build | |
twine upload dist/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
- name: Generate Dockerfile | |
if: steps.auto-version.outputs.version != '' | |
run: bash gen-docker-image.sh | |
working-directory: utils | |
- name: Build Docker images | |
if: steps.auto-version.outputs.version != '' | |
run: | | |
docker build \ | |
-t nipy/heudiconv:master \ | |
-t nipy/heudiconv:unstable \ | |
-t nipy/heudiconv:latest \ | |
-t nipy/heudiconv:"$(git describe | sed -e 's,^v,,g')" \ | |
. | |
- name: Push Docker images | |
if: steps.auto-version.outputs.version != '' | |
run: | | |
docker login -u "$DOCKER_LOGIN" --password-stdin <<<"$DOCKER_TOKEN" | |
docker push --all-tags nipy/heudiconv | |
env: | |
DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }} | |
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} | |
# vim:set sts=2: |