Skip to content

Publish

Publish #44

Workflow file for this run

name: Publish
on: workflow_dispatch
env:
POETRY_VERSION: 1.8.2
CONVCO_VERSION: v0.4.2
GITCLIFF_VERSION: 2.0.4
CHANGELOG_FILE: CHANGELOG.md
FULL_CHANGELOG_FILE: FULL_CHANGELOG.md
# Do not allow more than one publish job to run at a time
concurrency:
group: "publish"
cancel-in-progress: false
jobs:
publish-python:
runs-on: ubuntu-22.04 # convco needs GLIBC_2.32 which is not in 20.04
environment: publish
# Trusted publishing requires permission: id-token: write
# contents: read to access the repository's contents is set by default,
# however when permissions are explicitly set, the default is overridden.
permissions:
id-token: write
contents: read
outputs:
new_version: ${{ steps.set-vars.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
- name: Install convco
run: |
curl -sSfL "https://github.com/convco/convco/releases/download/${{ env.CONVCO_VERSION }}/convco-ubuntu.zip" | zcat > /usr/local/bin/convco
chmod +x /usr/local/bin/convco
- name: Set variables
id: set-vars
run: |
base_version_command="
convco
version
--prefix=v
"
old_version=$($base_version_command)
new_version=$($base_version_command --bump)
new_tag=v"$new_version"
echo "OLD_VERSION=$old_version" >> $GITHUB_ENV
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "NEW_MAJOR_VERSION=$(echo $new_version | cut -d'.' -f1)" >> $GITHUB_ENV
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
echo "old version: $old_version"
echo "new version: $new_version"
echo "new tag: $new_tag"
- name: Release
# Only run if the version has changed.
# Only start publishing automatically when the major version is 1 or higher.
if: ${{ env.OLD_VERSION != env.NEW_VERSION && env.NEW_MAJOR_VERSION >= 1 }}
env:
GH_TOKEN: ${{ github.token }}
run: |
########################################
# Generate changelogs
########################################
git_cliff_command="npx git-cliff@${{ env.GITCLIFF_VERSION }} --tag=${{ env.NEW_TAG }}"
$git_cliff_command --unreleased > ${{ env.CHANGELOG_FILE }}
$git_cliff_command > ${{ env.FULL_CHANGELOG_FILE }}
########################################
# Create GitHub Release
########################################
gh release create \
${{ env.NEW_TAG }} \
--title ${{ env.NEW_TAG }} \
--notes-file ${{ env.CHANGELOG_FILE }} \
${{ env.FULL_CHANGELOG_FILE }}
########################################
# Build package
########################################
poetry version ${{ env.NEW_VERSION }}
poetry build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
build-docs:
runs-on: ubuntu-22.04
needs: publish-python
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
- uses: actions/cache@v4
with:
path: .venv/
key: ${{ runner.os }}-python-3.11-poetry-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
poetry config --local virtualenvs.in-project true
poetry install -E all
- name: Build docs
run: |
poetry version ${{ needs.publish-python.outputs.new_version }}
poetry run sphinx-apidoc -o docs/source/ edvart
poetry run make -C docs html
- name: Upload HTML
uses: actions/upload-artifact@v4
with:
name: html
path: docs/build/html
retention-days: 1
deploy-pages:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
needs:
- build-docs
runs-on: ubuntu-22.04
steps:
- name: Setup Pages
uses: actions/configure-pages@v4
- uses: actions/download-artifact@v4
with:
name: html
path: docs/build/html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build/html
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4