Skip to content

v1.0.5

v1.0.5 #25

Workflow file for this run

name: release
on:
release:
types:
- published
jobs:
build:
name: Build and publish new release
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: ""
use-mamba: true
- name: Install nox and uv
run: |
pipx install nox
pipx install uv
- name: Check that versions match
id: version
run: |
nox -s dev
echo "Release tag: [${{ github.event.release.tag_name }}]"
PACKAGE_VERSION=$(.nox/dev/bin/python -c "import erdantic; print(erdantic.__version__)")
echo "Package version: [$PACKAGE_VERSION]"
[ ${{ github.event.release.tag_name }} == "v$PACKAGE_VERSION" ] || { exit 1; }
echo "full_version=v$PACKAGE_VERSION" >> $GITHUB_ENV
MAJOR_MINOR_VERSION=$([[ $PACKAGE_VERSION =~ ^[0-9]+\.[0-9]+ ]] && echo "${BASH_REMATCH[0]}")
echo "major_minor_version=$([[ $PACKAGE_VERSION =~ ^[0-9]+\.[0-9]+ ]] && echo "v${BASH_REMATCH[0]}")" >> $GITHUB_ENV
- name: Build package
run: |
nox -s build --verbose
- name: Build docs
run: |
nox -s docs --verbose
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
user: ${{ secrets.PYPI_TEST_USERNAME }}
password: ${{ secrets.PYPI_TEST_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to Production PyPI
uses: pypa/[email protected]
with:
user: ${{ secrets.PYPI_PROD_USERNAME }}
password: ${{ secrets.PYPI_PROD_PASSWORD }}
skip_existing: false
- name: Stage docs on gh-pages (release candidate)
if: contains(steps.version.outputs.full_version, 'rc')
working-directory: docs
run: |
git fetch origin gh-pages --depth=1
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
RUN_MIKE="conda run -p ../.nox/docs mike"
$RUN_MIKE deploy --push \
${{ steps.version.outputs.major_minor_version }}rc \
--title="${{ steps.version.outputs.major_minor_version }}rc"
- name: Stage docs on gh-pages (stable)
if: ${{ ! contains(steps.version.outputs.full_version, 'rc') }}
working-directory: docs
run: |
git fetch origin gh-pages --depth=1
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
RUN_MIKE="conda run -p ../.nox/docs mike"
# Rename old stable version
$RUN_MIKE list -j | jq
OLD_STABLE=$($RUN_MIKE list -j | jq -r '.[] | select(.aliases | index("stable")) | .title' | awk '{print $1;}')
echo $OLD_STABLE
$RUN_MIKE retitle stable $OLD_STABLE
# Deploy new version as stable
$RUN_MIKE deploy --push --update-aliases \
${{ steps.version.outputs.major_minor_version }} \
stable \
--title="${{ github.event.release.tag_name }} (stable)"
deploy-docs:
name: Deploy docs to Netlify
needs: build
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
with:
ref: gh-pages
- name: Deploy docs to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: "./"
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: false
enable-commit-comment: false
overwrites-pull-request-comment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1