Skip to content

Merge pull request #222 from dandi/dependabot/github_actions/codecov/… #115

Merge pull request #222 from dandi/dependabot/github_actions/codecov/…

Merge pull request #222 from dandi/dependabot/github_actions/codecov/… #115

Workflow file for this run

name: Auto-release on PR merge
on:
# ATM, this is the closest trigger to a PR merging
push:
branches:
- master
env:
# Pin to v10.28.0, which (as of 2021-05-25) is the latest version with assets
AUTO_VERSION: v10.28.0
jobs:
release-check:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
outputs:
auto-version: ${{ steps.auto-version.outputs.version }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
# A full checkout is required so that auto will have access to tag
# information.
fetch-depth: 0
- name: Download auto
run: |
auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/tags/$AUTO_VERSION | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')"
wget -O- "$auto_download_url" | gunzip > ~/auto
chmod a+x ~/auto
- name: Check whether a release is due
id: auto-version
run: |
version="$(~/auto version)"
echo "version=$version" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
runs-on: ubuntu-latest
needs: release-check
if: needs.release-check.outputs.auto-version != ''
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
path: dandischema
token: ${{ secrets.DANDI_GITHUB_TOKEN }}
- name: Delete schema-* tags so as not to confuse auto
run: |
git tag -l "schema-*" | xargs git tag -d
working-directory: dandischema
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dandischema
run: python -m pip install .
working-directory: dandischema
- name: Get schema version
run: |
SCHEMA_VERSION="$(python -c 'from dandischema.consts import DANDI_SCHEMA_VERSION; print(DANDI_SCHEMA_VERSION)')"
if ! echo "$SCHEMA_VERSION" | grep -qP '^\d+\.\d+\.\d+$'
then printf "[ERROR] Invalid schema version: '%s'\n" "$SCHEMA_VERSION"
exit 1
fi
echo "SCHEMA_VERSION=$SCHEMA_VERSION" >> "$GITHUB_ENV"
- name: Checkout dandi/schema
uses: actions/checkout@v4
with:
repository: dandi/schema
path: schema
token: ${{ secrets.DANDI_GITHUB_TOKEN }}
- name: Test for unversioned changes
run: |
dirs="$(echo releases/*)"
echo "Following directories will be checked for differences: $dirs"
python ../dandischema/tools/pubschemata.py releases
git status
git add -A releases
if ! git diff --cached --exit-code $dirs
then echo "[ERROR] Existing schema files modified instead of creating a new version"
exit 1
fi
working-directory: schema
- name: Install build & twine
run: python -m pip install build twine
- name: Download auto
run: |
auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/tags/$AUTO_VERSION | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')"
wget -O- "$auto_download_url" | gunzip > ~/auto
chmod a+x ~/auto
- name: Create release
run: |
~/auto shipit -vv
python -m build
twine upload dist/*
env:
GH_TOKEN: ${{ secrets.DANDI_GITHUB_TOKEN }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
working-directory: dandischema
- name: Commit schema changes and create new tag
run: |
LIBRARY_VERSION="$(git -C ../dandischema describe --tags --exact-match)"
git config --global user.email "[email protected]"
git config --global user.name "DANDI Bot"
git add releases
if ! git diff --quiet --cached
then git commit -m "Publish model schema v$SCHEMA_VERSION as of dandischema v$LIBRARY_VERSION"
git push
git -C ../dandischema tag -m "Schema v$SCHEMA_VERSION, released in dandischema v$LIBRARY_VERSION" schema-$SCHEMA_VERSION
git -C ../dandischema push --tags
else echo "No changes to commit"
fi
working-directory: schema
# vim:set sts=2: