Skip to content

Consolidate hexdoc hooks #32

Consolidate hexdoc hooks

Consolidate hexdoc hooks #32

Workflow file for this run

name: Run CI
on:
push:
branches: main
tags: v*
permissions:
contents: read
concurrency:
group: ci
cancel-in-progress: false
env:
PYPI_PACKAGE: hexdoc
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pages: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: pip install . build
- name: Get Pages url
run: |
url=$(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.html_url')
echo "GITHUB_PAGES_URL=$url" >> "$GITHUB_ENV"
- name: Export hexdoc resources
run: hexdoc export
- name: Build package
run: python -m build
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: python-build
path: dist
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Run pre-commit hooks
env:
SKIP: pyright
uses: pre-commit/[email protected]
- name: Install Nox
run: pip install nox
- name: Run Nox
run: nox
publish-pypi:
runs-on: ubuntu-latest
needs: [build, test]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
environment:
name: pypi
url: https://pypi.org/p/${{ env.PYPI_PACKAGE }}
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
# convert v1!0.1.0.dev0 to v0.1.0
- name: Parse version tag
id: parse
run: |
set +H
echo "version=v$(echo "$GITHUB_REF" | grep -Eo '![0-9]+\.[0-9]+\.[0-9]+' | sed 's/!//')" >> "$GITHUB_OUTPUT"
- name: Update release tags
uses: haya14busa/action-update-semver@v1
with:
tag: ${{ steps.parse.outputs.version }}
- name: Download package artifact
uses: actions/download-artifact@v3
with:
name: python-build
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1