Skip to content

add release scripts, actions and documentation #1

add release scripts, actions and documentation

add release scripts, actions and documentation #1

Workflow file for this run

name: Publish
on:
push:
branches:
- main
tags:
- '*'
pull_request:
types:
- closed
release:
types:
- published
workflow_dispatch:
permissions:
contents: read
id-token: write
# 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.repository == 'Diaoul/subliminal'
&& 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:
- name: Fetch version
id: version
run: |
VERSION=${GITHUB_HEAD_REF#release-}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Push tag with version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Tag the commit
run: |
git tag --annotate --message="Release version ${{ VERSION }}" ${{ VERSION }} ${{ github.sha }}
git push origin ${{ VERSION }}
github-release:
name: Make a GitHub Release and upload Python package.
needs: [build-package]
if: github.repository == 'Diaoul/subliminal' && 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 }}