Skip to content

Commit

Permalink
add: gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tanbro committed Apr 8, 2024
1 parent 9ae69d4 commit d5df707
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [master]
tags: ["*"]
pull_request:
branches: [master]

jobs:
get-version-pep440:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Get PEP-440 style version
id: get-version
run: |
PEP440_VERSION=""
VERSION_PREFIX="v"
BRANCH_OR_TAG="$(echo ${{ github.event.ref }} | cut -d / -f 3)"
if [[ "${BRANCH_OR_TAG}" =~ ^v?(([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*(\.?(a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?)$ ]]
then
PEP440_VERSION="${BRANCH_OR_TAG#$VERSION_PREFIX}"
fi
echo "version=${PEP440_VERSION}" | tee -a $GITHUB_OUTPUT
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: pip # caching pip dependencies
- name: Install project and dependent tools
run: |
pip install -r requirements.txt
- name: Check with ruff
run: |
ruff check .
- name: Update docs
run: |
mkdocs gh-deploy
build:
runs-on: ubuntu-latest
needs: [get-version-pep440, check]
if: needs.get-version-pep440.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: "pip" # caching pip dependencies
- name: Install builder
run: pip install build
- name: Build Python distribution
run: pyproject-build
- name: Upload dist to artifact
uses: actions/upload-artifact@v4
with:
name: mkdocs_nbconvert-dist-${{ needs.get-version-pep440.outputs.version }}
path: dist
if-no-files-found: error
retention-days: 1

publish:
runs-on: ubuntu-latest
needs: [get-version-pep440, build]
if: needs.get-version-pep440.outputs.version != ''
steps:
- name: Download dist from artifact
uses: actions/download-artifact@v4
with:
name: mkdocs_nbconvert-dist-${{needs.get-version-pep440.outputs.version}}
path: dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit d5df707

Please sign in to comment.