Skip to content

Commit 30288dd

Browse files
authored
Merge pull request #69 from AllenNeuralDynamics/cicd-automatic-releases
Refactor CICD and package metadata to use uv
2 parents 87f740f + e0ee0af commit 30288dd

File tree

8 files changed

+601
-482
lines changed

8 files changed

+601
-482
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/contraqctor.yml

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: contraqctor test suite
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- dev*
10+
- release*
11+
release:
12+
types: [published]
13+
14+
jobs:
15+
# ╔──────────────────────────╗
16+
# │ _____ _ │
17+
# │ |_ _|__ ___| |_ ___ │
18+
# │ | |/ _ \/ __| __/ __| │
19+
# │ | | __/\__ \ |_\__ \ │
20+
# │ |_|\___||___/\__|___/ │
21+
# │ │
22+
# ╚──────────────────────────╝
23+
tests:
24+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
os: [ubuntu-latest, windows-latest]
29+
python-version: [3.11, 3.12, 3.13]
30+
fail-fast: false
31+
steps:
32+
- uses: actions/checkout@v5
33+
34+
- uses: astral-sh/setup-uv@v6
35+
with:
36+
enable-cache: true
37+
38+
- name: Install python dependencies
39+
run: uv sync
40+
41+
- name: Run ruff format
42+
run: uv run ruff format
43+
44+
- name: Run ruff check
45+
run: uv run ruff check
46+
47+
- name: Run interrogate
48+
run: uv run interrogate
49+
50+
- name: Run codespell
51+
run: uv run codespell --check-filenames
52+
53+
- name: Run pytest
54+
run: uv run pytest --cov contraqctor
55+
56+
- name: Build
57+
run: uv build
58+
59+
# ╔───────────────────────────────────────────────────────────╗
60+
# │ ____ ___ ____ ____ ____ _ │
61+
# │ / ___|_ _/ ___| _ \ | _ \ ___| | ___ __ _ ___ ___ │
62+
# │ | | | | | | | | | | |_) / _ \ |/ _ \/ _` / __|/ _ \ │
63+
# │ | |___ | | |___| |_| | | _ < __/ | __/ (_| \__ \ __/ │
64+
# │ \____|___\____|____/ |_| \_\___|_|\___|\__,_|___/\___| │
65+
# │ │
66+
# ╚───────────────────────────────────────────────────────────╝
67+
github-rc-release:
68+
needs: tests
69+
runs-on: ubuntu-latest
70+
if: >
71+
github.ref == 'refs/heads/main' &&
72+
github.event_name == 'push' &&
73+
github.event.head_commit.author.email != 'github-actions[bot]@users.noreply.github.com'
74+
name: Create GitHub pre-release
75+
steps:
76+
- uses: actions/checkout@v5
77+
with:
78+
fetch-depth: 0
79+
ref: main
80+
81+
- uses: astral-sh/setup-uv@v6
82+
with:
83+
enable-cache: true
84+
85+
- name: Bump pre-release by default
86+
# Note: Bumping the rc will fail if the version is not currently an rc
87+
# To solve it, we bump the patch and rc atomically
88+
run: |
89+
if uv version --bump rc --dry-run; then
90+
uv version --bump rc
91+
else
92+
uv version --bump rc --bump patch
93+
fi
94+
95+
- name: Commit version
96+
run: |
97+
git config --global user.name "github-actions[bot]"
98+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
99+
git add .
100+
git commit -m "Bump version [skip ci]" || echo "No changes to commit"
101+
git push origin main
102+
103+
- name: Get version
104+
id: get_version
105+
shell: bash # interop with win/linux for if statement
106+
run: |
107+
version=$(uv version --output-format json | jq -r '.version')
108+
echo "version=$version" >> $GITHUB_OUTPUT
109+
110+
- name: Create GitHub Release
111+
uses: softprops/action-gh-release@v2
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
with:
115+
tag_name: v${{ steps.get_version.outputs.version }}
116+
name: v${{ steps.get_version.outputs.version }}
117+
generate_release_notes: true
118+
prerelease: true
119+
body: |
120+
Automated pre-release v${{ steps.get_version.outputs.version }}
121+
122+
# ╔─────────────────────────────────────────────────────────────────╗
123+
# │ ____ _ _ _ ____ _ │
124+
# │ | _ \ _ _| |__ | (_) ___ | _ \ ___| | ___ __ _ ___ ___ │
125+
# │ | |_) | | | | '_ \| | |/ __| | |_) / _ \ |/ _ \/ _` / __|/ _ \ │
126+
# │ | __/| |_| | |_) | | | (__ | _ < __/ | __/ (_| \__ \ __/ │
127+
# │ |_| \__,_|_.__/|_|_|\___| |_| \_\___|_|\___|\__,_|___/\___| │
128+
# │ │
129+
# ╚─────────────────────────────────────────────────────────────────╝
130+
131+
github-public-release:
132+
runs-on: ubuntu-latest
133+
name: Create GitHub public release
134+
needs: tests
135+
if: github.event_name == 'release' &&
136+
github.event.action == 'published' &&
137+
!github.event.release.prerelease
138+
steps:
139+
- uses: actions/checkout@v5
140+
with:
141+
fetch-depth: 0
142+
ref: main
143+
144+
- uses: astral-sh/setup-uv@v6
145+
with:
146+
enable-cache: true
147+
148+
- name: Get release version from tag
149+
id: get_version
150+
run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
151+
152+
- name: Validate version tag format
153+
run: uv version ${{ steps.get_version.outputs.version }} --dry-run
154+
155+
- name: Update package version
156+
run: uv version ${{ steps.get_version.outputs.version }}
157+
158+
- name: Commit version
159+
run: |
160+
git config --global user.name "github-actions[bot]"
161+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
162+
git add .
163+
git commit -m "Set version [skip ci]" || echo "No changes to commit"
164+
git push origin main
165+
166+
- name: Build
167+
run: uv build
168+
169+
- name: Publish
170+
run: uv publish --token ${{ secrets.AIND_PYPI_TOKEN }}
171+
172+
# ╔─────────────────────────╗
173+
# │ ____ │
174+
# │ | _ \ ___ ___ ___ │
175+
# │ | | | |/ _ \ / __/ __| │
176+
# │ | |_| | (_) | (__\__ \ │
177+
# │ |____/ \___/ \___|___/ │
178+
# │ │
179+
# ╚─────────────────────────╝
180+
build-docs:
181+
name: Build and deploy documentation to GitHub Pages
182+
runs-on: ubuntu-latest
183+
needs: github-public-release
184+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
185+
steps:
186+
- name: Checkout
187+
uses: actions/checkout@v5
188+
189+
- name: Install uv
190+
uses: astral-sh/setup-uv@v6
191+
with:
192+
enable-cache: true
193+
194+
- name: Install dependencies
195+
run: uv sync --group docs
196+
197+
- name: Configure Git user
198+
run: |
199+
git config user.name "github-actions[bot]"
200+
git config user.email "github-actions[bot]@users.noreply.github.com"
201+
202+
- name: Build & Deploy docs
203+
run: uv run mkdocs gh-deploy --force

.github/workflows/deploy-docs.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/tag_and_publish.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)