-
Notifications
You must be signed in to change notification settings - Fork 6
123 lines (118 loc) · 4.2 KB
/
ci.yml
File metadata and controls
123 lines (118 loc) · 4.2 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
if: github.event_name != 'push' || github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: 'false'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install .
- name: Run tests
run: |
pytest --maxfail=1 --disable-warnings
check-bumpver:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- name: Check for bumpver commit
id: check
run: |
if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then
echo "should_run=false" >> $GITHUB_OUTPUT
else
echo "should_run=true" >> $GITHUB_OUTPUT
fi
tag-version:
if: needs.check-bumpver.outputs.should_run == 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: check-bumpver
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: 'false'
- name: Generate GitHub App token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.HAWKY_APP_ID }}
private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }}
- name: Set up git for pushing
run: |
git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git
- name: Set git user for HawkyMcBuilderFace bot
run: |
git config user.name "${{ secrets.HAWKY_APP_USER }}"
git config user.email "${{ secrets.HAWKY_APP_USER_EMAIL }}"
- name: Fetch and checkout latest main
run: |
git fetch origin main
git checkout origin/main
- name: Show current branch and HEAD
run: |
git branch -a
git status
git rev-parse --abbrev-ref HEAD
- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(grep '^version =' pyproject.toml | head -1 | cut -d '"' -f2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create and push tag for current version (with verbose logging)
run: |
git remote -v
git tag v${{ steps.get_version.outputs.version }}
git fetch origin --tags --verbose
git push origin v${{ steps.get_version.outputs.version }}
bump-version:
if: needs.check-bumpver.outputs.should_run == 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: [check-bumpver, tag-version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: 'false'
- name: Generate GitHub App token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.HAWKY_APP_ID }}
private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }}
- name: Set up git for pushing
run: |
git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install .
- name: Set git user for HawkyMcBuilderFace bot
run: |
git config user.name "${{ secrets.HAWKY_APP_USER }}"
git config user.email "${{ secrets.HAWKY_APP_USER_EMAIL }}"
- name: Fetch and checkout latest main
run: |
git fetch origin main
git checkout origin/main
- name: Bump patch version with bumpver
run: bumpver update --patch --commit
- name: Push version bump commit
run: |
git push origin HEAD:main