-
Notifications
You must be signed in to change notification settings - Fork 0
275 lines (264 loc) · 8.94 KB
/
build.yml
File metadata and controls
275 lines (264 loc) · 8.94 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
PROJECT_NAME: fragile
PROJECT_DIR: src/fragile
VERSION_FILE: "src/fragile/version.py .bumpversion.cfg docs/_config.yml"
DEFAULT_BRANCH: main
BOT_NAME: fragile-bot
BOT_EMAIL: bot@fragile.tech
DOCKER_ORG: fragiletech
# LOCAL_CACHE: |
# ~/.local/bin
# ~/.local/lib/python3.*/site-packages
# /opt/homebrew
jobs:
# NOTE: Style check and tests temporarily disabled while focusing on documentation
# style-check:
# name: Style check
# if: "!contains(github.event.head_commit.message, 'Bump version')"
# runs-on: ubuntu-latest
# steps:
# - name: actions/checkout
# uses: actions/checkout@v6
# - name: Setup Rye
# id: setup-rye
# uses: eifinger/setup-rye@v4
# with:
# enable-cache: true
# cache-prefix: ubuntu-20.04-rye-check-${{ hashFiles('pyproject.toml') }}
# - name: Run style check and linter
# run: |
# set -x
# rye fmt --check
# rye lint
# pytest-rye:
# name: Run pytest and coverage with Rye
# if: "!contains(github.event.head_commit.message, 'Bump version')"
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: ["ubuntu-latest", "macos-latest"]
# python-version: ['3.10']
#
# steps:
# - uses: actions/checkout@v6
#
# - name: Setup Rye
# id: setup-rye
# uses: eifinger/setup-rye@v4
# with:
# enable-cache: true
# cache-prefix: ${{ matrix.os }}-latest-rye-test-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
#
# - name: Install Ubuntu test and package dependencies
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -x
# sudo apt-get install -y graphviz graphviz-dev
# rye pin --relaxed cpython@${{ matrix.python-version }}
# rye sync --all-features
#
# - name: Install MacOS test and package dependencies
# if: ${{ matrix.os == 'macos-latest' }}
# run: |
# set -x
# rye pin --relaxed cpython@${{ matrix.python-version }}
# rye sync --all-features
#
# - name: Run Pytest on MacOS
# if: ${{ matrix.os == 'macos-latest' }}
# run: |
# set -x
# rye run test
#
# - name: Run code coverage on Ubuntu
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -x
# rye run cov
#
# - name: Upload coverage report
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# if: ${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' && env.CODECOV_TOKEN != '' }}
# uses: codecov/codecov-action@v5
# with:
# fail_ci_if_error: false # optional (default = false)
# files: ./coverage.xml
# flags: unittests # optional
# name: codecov-umbrella # optional
# token: ${{ secrets.CODECOV_TOKEN }} # required
# verbose: true # optional (default = false)
build-test-package:
name: Build and test the package
# needs: style-check # Disabled while style-check is commented out
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'Bump version')"
permissions:
contents: write
id-token: write
steps:
- name: actions/checkout
uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 100
- name: Set Git user
run: |
git config --global user.name "${{ env.BOT_NAME }}"
git config --global user.email "${{ env.BOT_EMAIL }}"
- name: Setup Rye
id: setup-rye
uses: eifinger/setup-rye@v4
with:
enable-cache: true
cache-prefix: ubuntu-latest-rye-build-3.10-${{ hashFiles('pyproject.toml') }}
# - name: actions/cache
# uses: actions/cache@v4
# with:
# path: ${{ env.LOCAL_CACHE }}
# key: ubuntu-latest-system-build-3.10-${{ hashFiles('pyproject.toml') }}
# restore-keys: ubuntu-latest-system-test
- name: Install build dependencies
run: |
set -x
rye pin --relaxed cpython@3.10
rye install bump2version
rye install twine
- name: Create unique version for test.pypi
run: |
set -x
current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2)
ts=$(date +%s)
new_version="$current_version$ts"
bumpversion --current-version $current_version --new-version $new_version patch $VERSION_FILE
- name: Build package
run: |
set -x
rye build --clean
twine check dist/*
# - name: Publish 📦 to Test PyPI
# env:
# TEST_PYPI_PASS: ${{ secrets.TEST_PYPI_PASS }}
# if: "'$TEST_PYPI_PASS' != ''"
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_PASS }}
# repository-url: https://test.pypi.org/legacy/
# skip-existing: true
bump-version:
name: Bump package version
env:
BOT_AUTH_TOKEN: ${{ secrets.BOT_AUTH_TOKEN }}
if: "!contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/main' && '$BOT_AUTH_TOKEN' != ''"
runs-on: ubuntu-latest
needs:
# - pytest-rye # Disabled while tests are commented out
- build-test-package
steps:
- name: actions/checkout
uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 100
- name: current_version
run: |
set -x
echo "current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2)" >> $GITHUB_ENV
echo "version_file=$VERSION_FILE" >> $GITHUB_ENV
echo 'bot_name="${BOT_NAME}"' >> $GITHUB_ENV
echo 'bot_email="${BOT_EMAIL}"' >> $GITHUB_ENV
- name: FragileTech/bump-version
uses: FragileTech/bump-version@main
with:
current_version: "${{ env.current_version }}"
files: "${{ env.version_file }}"
commit_name: "${{ env.bot_name }}"
commit_email: "${{ env.bot_email }}"
login: "${{ env.bot_name }}"
token: "${{ secrets.BOT_AUTH_TOKEN }}"
# release-package:
# name: Release PyPI package
# env:
# PYPI_PASS: ${{ secrets.PYPI_PASS }}
# if: "contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/main' && '$PYPI_PASS' != ''"
# permissions:
# contents: write
# id-token: write
# runs-on: ubuntu-latest
# steps:
# - name: actions/checkout
# uses: actions/checkout@v6
# - name: Setup Rye
# id: setup-rye
# uses: eifinger/setup-rye@v4
# with:
# enable-cache: true
# cache-prefix: ubuntu-latest-rye-release-3.10-${{ hashFiles('pyproject.toml') }}
# - name: Install dependencies
# run: |
# set -x
# rye pin --relaxed cpython@3.10
# rye install twine
#
# - name: Build package
# run: |
# set -x
# rye build --clean
# twine check dist/*
#
# - name: Publish 📦 to PyPI
# env:
# PYPI_PASS: ${{ secrets.PYPI_PASS }}
# if: "'$PYPI_PASS' != ''"
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_PASS }}
# skip-existing: true
##
# release:
# runs-on: ubuntu-latest
# environment: release
# needs: test
# if: startsWith(github.ref, 'refs/tags/')
# permissions:
# contents: write
# id-token: write
#
# steps:
# - uses: actions/checkout@v6
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: '3.10'
# - name: Install dependencies
# shell: bash
# run: |
# python -m pip install --upgrade pip
# pip install hatch pre-commit
# - name: Build
# run: |
# hatch build
# - name: Publish 📦 to Test PyPI
# if: startsWith(github.ref, 'refs/heads/main')
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# skip_existing: true
# user: __token__
# password: ${{ secrets.TEST_PYPI_SECRECT }}
# packages-dir: dist/
# repository-url: https://test.pypi.org/legacy/
# - name: Publish 📦 to PyPI
# if: startsWith(github.ref, 'refs/heads/main')
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_SECRECT }}
# packages-dir: dist/