Skip to content

Amend global command example for installs using pip #71

Amend global command example for installs using pip

Amend global command example for installs using pip #71

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
type: string
pull_request_target:
types:
- closed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
default-python: "3.12"
minimum-supported-python: "3.8"
jobs:
create-tag:
name: Create the Git tag
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.pull_request.merged == true
&& contains(github.event.pull_request.labels.*.name, 'release-version')
runs-on: ubuntu-latest
outputs:
release-tag: ${{ steps.get-version.outputs.version }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract version to be released
id: get-version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
TITLE="${{ github.event.pull_request.title }}"
echo "version=${TITLE/: [[:alnum:]]*}" >> "$GITHUB_OUTPUT"
fi
- name: Bump version and push tag
uses: mathieudutour/[email protected]
with:
custom_tag: "${{ steps.get-version.outputs.version }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ""
pypi-publish:
name: Publish pipx to PyPI
needs: create-tag
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/pipx
permissions:
id-token: write
steps:
- name: Checkout ${{ needs.create-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: "${{ needs.create-tag.outputs.release-tag }}"
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Install nox
run: pip install nox
- name: Build sdist and wheel
run: nox --error-on-missing-interpreters --non-interactive --session build
- name: Publish to PyPI
uses: pypa/[email protected]
create-release:
name: Create a release on GitHub's UI
needs: [pypi-publish, create-tag]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
tag_name: "${{ needs.create-tag.outputs.release-tag }}"
upload-zipapp:
name: Upload zipapp to GitHub Release
needs: [create-release, create-tag]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout ${{ needs.create-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: "${{ needs.create-tag.outputs.release-tag }}"
- name: Set up Python ${{ env.minimum-supported-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.minimum-supported-python }}
cache: "pip"
- name: Install nox
run: pip install nox
- name: Build zipapp
run: nox --error-on-missing-interpreters --non-interactive --session zipapp
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: pipx.pyz
tag_name: "${{ needs.create-tag.outputs.release-tag }}"