-
Notifications
You must be signed in to change notification settings - Fork 23
96 lines (79 loc) · 3.49 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: CI
on:
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
test:
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: pip install --upgrade hatch
- name: Run tests and track code coverage
run: hatch run test:cov
# TODO: Enforce quality, security and style checks.
bump_and_build:
needs: test
name: Bump and Build version [${{ github.head_ref || github.ref_name }}]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- run: |
git config user.name github-actions
git config user.email [email protected]
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade hatch
- name: Generate SLUG
id: generate_slug
run: |
if [ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]; then
SLUG="release"
else
SLUG=$(echo "$BRANCH_NAME" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z)
fi
echo "SLUG=$SLUG" >> $GITHUB_OUTPUT
# Bump for PRs with local a PEP440 version
- name: Local bump
if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main'
run: hatch run local-bump $(hatch version)+${{ steps.generate_slug.outputs.SLUG }}
continue-on-error: true
# Bump for PRs with a dev a PEP440 version
- name: Dev bump
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'bump:')
run: hatch run dev-bump $GITHUB_RUN_NUMBER && git push --follow-tags && echo "Bumped to dev version $(hatch version)"
continue-on-error: true
- name: Release bump
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
run: hatch run beta-bump && git push --follow-tags && echo "Bumped versions $(hatch version)"
- name: Build package
run: hatch build
- uses: actions/upload-artifact@v3
with:
name: "dist-${{ steps.generate_slug.outputs.SLUG }}"
path: dist/*
if-no-files-found: error
retention-days: 7