Skip to content

Commit

Permalink
CI: Add release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jenisys committed Aug 25, 2024
1 parent 2195db8 commit c9a549a
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/manual-release-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# -- WORKFLOW: Publish/release this package on PyPI
# SEE:
# * https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# * https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python#publishing-to-pypi
#
# * https://docs.github.com/en/actions/writing-workflows
# * https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs
# * https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#release
#
# GITHUB ACTIONS:
# * https://github.com/actions/checkout
# * https://github.com/pypa/gh-action-pypi-publish
#
# RELATED:
# * https://github.com/actions/starter-workflows/blob/main/ci/python-publish.yml

# -- STATE: PREPARED_ONLY, NOT_RELEASED_YET
name: manual-release-to-pypi
on:
workflow_dispatch: # -- NOTE: Run it manually and provide the version.
inputs:
VERSION:
description: "Existing version to publish the release (to pypi; EXAMPLE: VERSION=1.2.7)"
required: true
type: string

permissions:
contents: read

jobs:
publish-package:
runs-on: ubuntu-latest
# MAYBE: if: github.event_name == "push" && startsWith(github.ref, "refs/tags/v")
environment:
name: pypi
url: https://pypi.org/project/parse-type
# OR: https://pypi.org/p/<YOURPROJECT>
permissions:
id-token: write # REQUIRED-FOR: Trusted publishing.
steps:
- uses: actions/checkout@v4
with:
ref: "v${{inputs.VERSION}}"
# env:
# VERSION: "${{inputs.VERSION}}"
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: "Install Python package dependencies (with: uv)"
run: |
python -m pip install -U uv
python -m uv pip install -U pip setuptools wheel build twine
- name: Build this package
run: python -m build
- name: Check this package (before upload)
run: twine check dist/* ─╯
- name: Upload this package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
verbose: true
# -- MAYBE:
# with:
# repository-url: https://test.pypi.org/legacy/
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/release-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -- WORKFLOW: Publish/release this package on PyPI
# SEE:
# * https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# * https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python#publishing-to-pypi
#
# * https://docs.github.com/en/actions/writing-workflows
# * https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs
# * https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#release
#
# GITHUB ACTIONS:
# * https://github.com/actions/checkout
# * https://github.com/pypa/gh-action-pypi-publish
#
# RELATED:
# * https://github.com/actions/starter-workflows/blob/main/ci/python-publish.yml

# -- STATE: PREPARED_ONLY, NOT_RELEASED_YET
name: release-to-pypi
on:
release:
types: [published]
# MAYBE: if: github.event_name == "push" && startsWith(github.ref, "refs/tags/v")

permissions:
contents: read

jobs:
publish-package:
runs-on: ubuntu-latest
# MAYBE: if: github.event_name == "push" && startsWith(github.ref, "refs/tags/v")
environment:
name: pypi
url: https://pypi.org/p/parse-type
permissions:
id-token: write # REQUIRED-FOR: Trusted publishing.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: "Install Python package dependencies (with: uv)"
run: |
python -m pip install -U uv
python -m uv pip install -U pip setuptools wheel build twine
- name: Build this package
run: python -m build
- name: Check this package (before upload)
run: twine check dist/* ─╯
- name: Upload this package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
verbose: true
58 changes: 58 additions & 0 deletions .github/workflows/release-to-testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -- WORKFLOW: Publish/release this package on PyPI (testpypi)
# SEE:
# * https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# * https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python#publishing-to-pypi
#
# * https://docs.github.com/en/actions/writing-workflows
# * https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs
# * https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#release
#
# GITHUB ACTIONS:
# * https://github.com/actions/checkout
# * https://github.com/pypa/gh-action-pypi-publish
#
# RELATED:
# * https://github.com/actions/starter-workflows/blob/main/ci/python-publish.yml

# -- STATE: PREPARED_ONLY, NOT_RELEASED_YET
name: release-to-pypi
on:
release:
types: [published]
# MAYBE: if: github.event_name == "push" && startsWith(github.ref, "refs/tags/v")

permissions:
contents: read

jobs:
publish-package:
runs-on: ubuntu-latest
# MAYBE: if: github.event_name == "push" && startsWith(github.ref, "refs/tags/v")
environment:
name: pypi
url: https://test.pypi.org/project/parse-type
# OR: https://test.pypi.org/p/<YOURPROJECT>
permissions:
id-token: write # REQUIRED-FOR: Trusted publishing.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: "Install Python package dependencies (with: uv)"
run: |
python -m pip install -U uv
python -m uv pip install -U pip setuptools wheel build twine
- name: Build this package
run: python -m build
- name: Check this package (before upload)
run: twine check dist/* ─╯
- name: Upload this package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
verbose: true
# -- MAYBE:
# with:
# repository-url: https://test.pypi.org/legacy/
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}

0 comments on commit c9a549a

Please sign in to comment.