Skip to content

chore: add Python 3.10-3.13 (#40) #49

chore: add Python 3.10-3.13 (#40)

chore: add Python 3.10-3.13 (#40) #49

Workflow file for this run

name: Publish Python Package
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
inputs:
publish:
description: 'Create Production Release'
required: true
type: boolean
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Next Version
if: ${{ github.event.inputs.publish }}
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: main
- name: Set Next Version Env Var
if: ${{ github.event.inputs.publish }}
env:
NEXT_VERSION: ${{ steps.semver.outputs.next }}
run: |
echo "NEXT_VERSION=$next" >> $GITHUB_ENV
- name: Create Draft Release
uses: ncipollo/release-action@v1
if: ${{ github.event.inputs.publish }}
with:
prerelease: true
draft: false
commit: ${{ github.sha }}
tag: ${{ env.NEXT_VERSION }}
name: ${{ env.NEXT_VERSION }}
body: '*pending*'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Build Variables
run: |
if [[ $NEXT_VERSION ]]; then
echo "Using AUTO SEMVER mode: $NEXT_VERSION"
echo "SHOULD_DEPLOY=true" >> $GITHUB_ENV
echo "PKG_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
echo "PKG_VERSION_STRICT=${NEXT_VERSION#?}" >> $GITHUB_ENV
elif [[ "$GITHUB_REF" =~ ^refs/tags/v* ]]; then
echo "Using TAG mode: $GITHUB_REF_NAME"
echo "SHOULD_DEPLOY=true" >> $GITHUB_ENV
echo "PKG_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV
echo "PKG_VERSION_STRICT=${GITHUB_REF_NAME#?}" >> $GITHUB_ENV
else
echo "Using TEST mode: v2.0.0-dev.$GITHUB_RUN_NUMBER"
echo "SHOULD_DEPLOY=false" >> $GITHUB_ENV
echo "PKG_VERSION=v2.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
echo "PKG_VERSION_STRICT=2.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
fi
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Python dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip setuptools wheel twine
pip install build
sudo apt update
sudo apt install -y twine
- name: Build Python package
run: |
echo "Using version $PKG_VERSION_STRICT"
sed -i -r -e "s/^__version__ = '.*'$/__version__ = '$PKG_VERSION_STRICT'/" rfc2html.py
python ./setup.py setopt --command=metadata --option=version --set-value=$PKG_VERSION_STRICT
python ./setup.py sdist --dist-dir dist
- name: Import Test GPG Key
uses: crazy-max/ghaction-import-gpg@cb4264d3319acaa2bea23d51ef67f80b4f775013
if: startsWith(github.ref, 'refs/tags/v') != true
with:
gpg_private_key: ${{ secrets.TEST_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.TEST_GPG_PASSPHRASE }}
- name: Publish to Test PyPI
if: env.SHOULD_DEPLOY != 'true'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
run: |
echo "Using repository $TWINE_REPOSITORY_URL"
twine check dist/*
twine upload --verbose --sign dist/*
- name: Update CHANGELOG
id: changelog
uses: Requarks/changelog-action@v1
if: env.SHOULD_DEPLOY == 'true'
with:
token: ${{ github.token }}
tag: ${{ env.PKG_VERSION }}
- name: Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v4
if: env.SHOULD_DEPLOY == 'true'
with:
branch: main
commit_message: 'docs: update CHANGELOG.md + py files for ${{ env.PKG_VERSION }} [skip ci]'
file_pattern: CHANGELOG.md setup.cfg rfc2html.py
- name: Create Release
uses: ncipollo/release-action@v1
if: env.SHOULD_DEPLOY == 'true'
with:
allowUpdates: true
draft: false
tag: ${{ env.PKG_VERSION }}
name: ${{ env.PKG_VERSION }}
body: ${{ steps.changelog.outputs.changes }}
artifacts: "dist/**"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Build Artifacts
uses: actions/[email protected]
with:
name: artifacts
path: |
CHANGELOG.md
rfc2html.py
setup.cfg