Skip to content

Added .readthedocs.yaml (#1) #11

Added .readthedocs.yaml (#1)

Added .readthedocs.yaml (#1) #11

Workflow file for this run

name: Release
on:
push:
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
jobs:
build:
name: Build package
runs-on: ubuntu-latest
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install requirements
run: |
python -Im pip install --upgrade pip
python -Im pip install build check-wheel-contents hatch hatch-vcs
- name: Build package
id: build
run: |
python -Im build
echo "version=$(python -m hatchling version)" | tee -a "$GITHUB_OUTPUT"
- name: Check wheel content
run: check-wheel-contents dist/*.whl
- name: Print package contents summary
run: |
echo -e '<details open><summary>SDist Contents</summary>\n' >> $GITHUB_STEP_SUMMARY
tar -tf dist/*.tar.gz | tree -a --fromfile . | sed 's/^/ /' | tee -a $GITHUB_STEP_SUMMARY
echo -e '</details>\n' >> $GITHUB_STEP_SUMMARY
echo -e '<details open><summary>Wheel Contents</summary>\n' >> $GITHUB_STEP_SUMMARY
unzip -Z1 dist/*.whl | tree -a --fromfile . | sed 's/^/ /' | tee -a $GITHUB_STEP_SUMMARY
echo -e '</details>\n' >> $GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist
# Draft a new release on tagged commit on main.
draft-release:
name: Draft release
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [build]
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
- name: Draft a new release
run: >
gh release create --draft --repo ${{ github.repository }}
${{ github.ref_name }}
dist/*
env:
GH_TOKEN: ${{ github.token }}
# Publish to PyPI on tagged commit on main.
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [build]
environment:
name: publish-pypi
url: https://pypi.org/project/pyforce-p4/${{ needs.build.outputs.version }}
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# Publish to Test PyPI on every commit on main.
publish-test-pypi:
name: Publish to Test PyPI
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [build]
environment:
name: publish-test-pypi
url: https://test.pypi.org/project/pyforce-p4/${{ needs.build.outputs.version }}
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/