Skip to content

Publish

Publish #23

Workflow file for this run

name: Publish
on:
workflow_run:
workflows: ["Test"]
branches: [main]
types: [completed]
env:
POETRY_VERSION: 1.5.1
CONVCO_VERSION: v0.4.1
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
outputs:
new_version: ${{ steps.set-vars.outputs.new_version }}
steps:
- uses: actions/checkout@v3
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 and publish
# 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
########################################
base_changelog_command="
convco
changelog
--unreleased=${{ env.NEW_VERSION }}
"
$base_changelog_command --max-versions=1 > ${{ env.CHANGELOG_FILE }}
$base_changelog_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 }}
########################################
# Publish to PyPI
########################################
poetry config http-basic.pypi ${{ secrets.PYPI_USERNAME}} ${{ secrets.PYPI_PASSWORD }}
poetry version ${{ env.NEW_VERSION }}
poetry publish --build
build-docs:
runs-on: ubuntu-22.04
needs: publish-python
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
- uses: actions/cache@v3
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@v3
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@v3
- uses: actions/download-artifact@v3
with:
name: html
path: docs/build/html
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: docs/build/html
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2