Prepare release 2.2.2dev5 #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
types: | |
- closed | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
permissions: | |
contents: read | |
id-token: write | |
env: | |
FORCE_COLOR: "1" | |
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
jobs: | |
# Always build & lint package. | |
build-package: | |
name: Build & verify package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: hynek/build-and-inspect-python-package@v2 | |
tag: | |
if: | | |
github.event_name == 'pull_request' | |
&& github.event.action == 'closed' | |
&& github.event.pull_request.merged == true | |
&& startsWith(github.head_ref, 'release-') | |
needs: [build-package] | |
env: | |
GITHUB_HEAD_REF: ${{ github.head_ref }} | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Tag the commit | |
run: | | |
RELEASE_VERSION=${GITHUB_HEAD_REF#release-} | |
echo Release version: $RELEASE_VERSION | |
git config user.name 'subliminal bot' | |
git config user.email [email protected] | |
git tag --annotate --message="Release version $RELEASE_VERSION" $RELEASE_VERSION ${{ github.sha }} | |
git push origin $RELEASE_VERSION | |
github-release: | |
name: Make a GitHub Release and upload Python package. | |
needs: [build-package] | |
if: startsWith(github.ref, 'refs/tags/') # only publish a Github release on push tag | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # IMPORTANT: mandatory for making GitHub Releases | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download packages built by build-and-inspect-python-package | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: dist | |
- name: Publish GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: dist/* | |
tag_name: ${{ github.event.inputs.version }} | |
generate_release_notes: true | |
draft: true | |
publish-to-pypi: | |
needs: [build-package] | |
environment: | |
name: pypi | |
url: https://pypi.org/p/subliminal | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
if: github.repository == 'Diaoul/subliminal' && github.event.action == 'published' # only publish to PyPI on Github release published | |
steps: | |
- name: Download packages built by build-and-inspect-python-package | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: dist | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |