Skip to content

First release wetting-angle-kit #1

First release wetting-angle-kit

First release wetting-angle-kit #1

Workflow file for this run

name: Publish and Deploy
on:
release:
types:
- published
env:
PUBLISH_UPDATE_BRANCH: main
GIT_USER_NAME: Matgenix
GIT_USER_EMAIL: "dev@matgenix.com"
jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
if: github.repository == 'Matgenix/wetting-angle-kit' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -e .[all]
- name: Set git config
run: |
git config --global user.name "${{ env.GIT_USER_NAME }}"
git config --global user.email "${{ env.GIT_USER_EMAIL }}"
- name: Update changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.RELEASE_PAT_BOT }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
exclude_labels: "duplicate,question,invalid,wontfix,dependency_updates,skip_changelog"
# CharMixer/auto-changelog-action above rewrites the changelog on the
# working tree; this step force-pushes the result back to the protected
# ``main`` branch. ``force: true`` is required because the changelog
# commit is fabricated by the action and would otherwise diverge from
# ``origin/main``; ``unprotect_reviews: true`` lifts branch-protection
# review requirements for the duration of the push so the workflow can
# publish the release autonomously. The push triggers
# ``deploy-docs.yml`` (push-to-main), which rebuilds and redeploys the
# documentation alongside this publish.
- name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_PAT_BOT }}
branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
unprotect_reviews: true
sleep: 15
force: true
tags: true
- name: Get tagged versions
run: echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV
- name: Create release-specific changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.RELEASE_PAT_BOT }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
since_tag: "${{ env.PREVIOUS_VERSION }}"
output: "release_changelog.md"
exclude_labels: "duplicate,question,invalid,wontfix,dependency_updates,skip_changelog"
- name: Append changelog to release body
run: |
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md
cat release_changelog.md >> release_body.md
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md'
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT_BOT }}
- name: Build source distribution
run: python -m build
- name: Publish package to Test PyPI first
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_PASSWORD }}
repository-url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
# Documentation deployment is handled by ``deploy-docs.yml`` on push to
# ``main`` (which the ``Update main`` step above triggers). Keeping the
# build+deploy in a single workflow avoids the race that arises when
# both workflows publish to GitHub Pages simultaneously.