Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace poetry by hatch #3

Merged
merged 17 commits into from
Jun 7, 2024
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
27 changes: 0 additions & 27 deletions .github/release.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/1-prepare-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Prepare a Release

on:
workflow_dispatch:
inputs:
version:
description: "New version to be released"
required: true

jobs:
prepare-for-release:
runs-on: ubuntu-latest
env:
VERSION: ${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install Hatch
run: python -m pip install hatch

- name: Update Changelog
run: hatch run changelog:build --yes --version --version "$VERSION"

- uses: peter-evans/create-pull-request@v6
name: Create Pull Request
id: cpr
with:
commit-message: "Prepared release ${{ github.event.inputs.version }}"
branch: "prepare-release/${{ github.event.inputs.version }}"
title: "Release ${{ github.event.inputs.version }}"
draft: false
delete-branch: true
body: "Automated changes by [prepare_release](.github/workflows/1-prepare-release.yaml) GitHub action."

- name: Show Pull Request info
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
30 changes: 30 additions & 0 deletions .github/workflows/2-tag-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Create tag when PR is accepted

on:
pull_request:
branches:
- main
- release/**
types: [closed]

jobs:
create-tag:
if: (github.event.pull_request.merged && startsWith( github.head_ref, 'prepare-release/' ))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: bluwy/substitute-string-action@v3
name: Get Tag
id: get-tag
with:
_input-text: ${{ github.head_ref }}
prepare-release/: ""

- name: Show tag name
run: echo ${{ steps.get-tag.outputs.result }}

- uses: rickstaa/action-create-tag@v1
name: Create and Push Tag
with:
tag: ${{ steps.get-tag.outputs.result }}
2 changes: 2 additions & 0 deletions .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ jobs:
with:
use-quiet-mode: "yes"
use-verbose-mode: "yes"
folder-path: "docs/"
file-path: "README.md"
108 changes: 108 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: ci

on:
push:
tags:
- "[0-9].[0-9].[0-9]*"
branches:
- "main"
- "release/**"
pull_request:
paths:
- .github/workflows/ci.yaml
- hatch.toml
- pyproject.toml
- tests/**
- wizard_template/**
schedule:
- cron: "0 0 * * 1" # midnight every Monday

concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true

jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- uses: pre-commit/[email protected]

test:
needs: qa
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install Hatch
run: python -m pip install hatch

- name: Run tests
run: |
hatch run +py=${{ matrix.python-version }} test:extended --cov-report=xml:coverage.${{ matrix.os }}.${{ matrix.python-version }}.xml

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: coverage.*.xml

build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install Hatch
run: python -m pip install hatch
- name: Build package
run: hatch build
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: built-sdist
- uses: actions/upload-artifact@v4
with:
path: dist/*.whl
name: built-bdist

release:
needs: build
# upload to PyPI on every tag
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/wizard_template'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/wizard_template
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
name: built-sdist
path: dist
- uses: actions/download-artifact@v4
with:
name: built-bdist
path: dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
60 changes: 60 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Docs

# See:
# https://jupyterbook.org/en/stable/publish/gh-pages.html
on:
push:
tags:
- "[0-9].[0-9].[0-9]*"
branches:
- main
- release/**
pull_request:
paths:
- .github/workflows/docs.yaml
- docs/**
- wizard_template/**
- hatch.toml
- pyproject.toml

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install Hatch
run: python -m pip install hatch

- name: Build the book
run: hatch run docs:build

- uses: actions/upload-artifact@v4
with:
path: build/
name: documentation

deploy:
needs: build
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/wizard_template'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: build/
name: documentation

# Push the book's HTML to github-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/_build/html
50 changes: 0 additions & 50 deletions .github/workflows/publish-docs.yaml

This file was deleted.

Loading
Loading