Build and publish Python package #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish Python package | |
on: | |
workflow_call: | |
inputs: | |
node_version: | |
default: '22' | |
description: 'Node version to use' | |
required: false | |
type: string | |
python_version: | |
default: '3.12' | |
description: 'Python version to use' | |
required: false | |
type: string | |
workflow_dispatch: | |
inputs: | |
node_version: | |
default: '22' | |
description: 'Node version to use' | |
required: true | |
type: string | |
python_version: | |
default: '3.12' | |
description: 'Python version to use' | |
required: true | |
type: string | |
permissions: {} | |
jobs: | |
build-package: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Install twine | |
run: pipx run twine --help | |
- name: Checkout ixbrl-viewer | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Install Node.js | |
uses: actions/[email protected] | |
with: | |
cache: 'npm' | |
check-latest: true | |
node-version: ${{ inputs.node_version }} | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Build ixbrlviewer.js | |
run: make prod | |
- name: Install Python | |
uses: actions/[email protected] | |
with: | |
cache: 'pip' | |
cache-dependency-path: '**/pyproject.toml' | |
check-latest: true | |
python-version: ${{ inputs.python_version }} | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install build | |
- name: Build Python package | |
run: python -m build | |
- name: Upload source distribution artifact | |
uses: actions/[email protected] | |
with: | |
name: source distribution | |
if-no-files-found: error | |
path: dist/*.tar.gz | |
- name: Upload wheel artifact | |
uses: actions/[email protected] | |
with: | |
name: wheel | |
if-no-files-found: error | |
path: dist/*.whl | |
publish-package: | |
needs: build-package | |
environment: release | |
permissions: | |
contents: write | |
runs-on: ubuntu-24.04 | |
if: startsWith(github.ref, 'refs/tags') | |
steps: | |
- name: Install twine | |
run: pip install -U twine | |
- name: Download source distribution artifact | |
uses: actions/[email protected] | |
with: | |
name: source distribution | |
- name: Download wheel artifact | |
uses: actions/[email protected] | |
with: | |
name: wheel | |
- name: Publish package on release | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
TWINE_REPOSITORY: ${{ github.repository == 'Arelle/ixbrl-viewer' && 'pypi' || 'testpypi' }} | |
run: twine upload ./* | |
- name: Upload release artifacts | |
uses: softprops/[email protected] | |
with: | |
fail_on_unmatched_files: true | |
files: './*' |