Skip to content

Release package

Release package #5

Workflow file for this run

name: Publish extension
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment'
type: choice
options:
- development
- production
default: production
permissions:
# for updating tag/release
contents: write
jobs:
main:
name: Configure and create tag/release
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
outputs:
version: ${{ steps.config.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure and verify
id: config
env:
TIMEZONE: ${{ vars.TIMEZONE || 'UTC' }}
run: |
VERSION=$(grep -oP "^__version__\s*=\s*['\"]\K[^'\"]+" webscrapbook/__init__.py)
EXPECTED_LINE="## [$VERSION] - $(TZ="$TIMEZONE" date +%Y-%m-%d)"
if ! grep -Fxq "$EXPECTED_LINE" CHANGELOG.md; then
echo "❌ Missing expected changelog line: $EXPECTED_LINE"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install dependencies
run: pip install .[dev]
- name: Verify no code issue
run: flake8 .
- name: Create Git tag
run: |
git tag --force ${{ steps.config.outputs.version }}
git push origin ${{ steps.config.outputs.version }}
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: PyWebScrapBook ${{ steps.config.outputs.version }}
tag_name: ${{ steps.config.outputs.version }}
draft: true
prerelease: false
generate_release_notes: true
build:
name: Build on ${{ matrix.os }} (${{ matrix.arch }}) with Python ${{ matrix.pyver }}
needs: main
environment: ${{ github.event.inputs.environment }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- pyver: '3.12'
os: windows-latest
arch: x64
- pyver: '3.12'
os: macos-latest
arch: arm64
- pyver: '3.10'
os: windows-latest
arch: x64
- pyver: '3.10'
os: macos-latest
arch: arm64
- pyver: '3.8'
os: windows-latest
arch: x64
- pyver: '3.8'
os: windows-latest
arch: x86
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyver }}
architecture: ${{ matrix.arch }}
- name: Install dependencies
run: pip install .[dev]
- name: Build executables
run: |
python tools/build.py --pack
python tools/build.py --pack --onefile
- name: Add assets to GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.main.outputs.version }}
files: 'dist/*'
fail_on_unmatched_files: true
publish_release:
name: Publish GitHub release
runs-on: ubuntu-latest
needs: [main, build]
environment: ${{ github.event.inputs.environment }}
steps:
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.main.outputs.version }}
draft: false
make_latest: legacy # mark latest for a release with larger version
upload_pypi:
name: Upload to PyPI
runs-on: ubuntu-latest
needs: main
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install .[dev]
python tools/build.py --upload