Skip to content

Commit 2c3b0fe

Browse files
authored
Merge pull request #76 from KumarLabJax/task/add-release-pipeline-on-main-branch
Task/add release pipeline on main branch
2 parents e2ff6ef + c2b382f commit 2c3b0fe

6 files changed

Lines changed: 156 additions & 4 deletions

File tree

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
docs/
2+
.claude
3+
.benchmarks
4+
.venv
5+
.nf-test
6+
mouse-tracking-runtime
7+
nextflow
8+
support_code
9+
vm
10+
*.h5
11+
*.sh
12+
tests

.github/workflows/_build-docker-action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
tags: ${{ steps.meta.outputs.tags }}
4848
labels: ${{ steps.meta.outputs.labels }}
4949
cache-from: type=gha
50-
cache-to: type=gha,mode=max
50+
cache-to: type=gha,mode=max

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Pull Request Checks
22

33
on:
44
pull_request:
5-
branches: [ main, repository-reorganization ]
5+
branches: [ main ]
66

77
jobs:
88
format-lint:

.github/workflows/release.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
paths:
7+
- 'pyproject.toml'
8+
9+
permissions:
10+
contents: write
11+
id-token: write
12+
packages: write
13+
14+
jobs:
15+
format-lint:
16+
name: "Format and Lint"
17+
uses: ./.github/workflows/_format-lint-action.yml
18+
19+
test:
20+
name: "Run Tests"
21+
needs: format-lint
22+
uses: ./.github/workflows/_run-tests-action.yml
23+
24+
build:
25+
name: "Build Docker Image"
26+
needs: [format-lint, test]
27+
secrets: inherit
28+
uses: ./.github/workflows/_build-docker-action.yml
29+
30+
check-version-changed:
31+
name: "Check if version changed"
32+
runs-on: ubuntu-latest
33+
outputs:
34+
version: ${{ steps.version.outputs.version }}
35+
version-changed: ${{ steps.check.outputs.changed }}
36+
is-prerelease: ${{ steps.version.outputs.is-prerelease }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 2
41+
42+
- name: Get current version
43+
id: version
44+
run: |
45+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
46+
echo "version=$VERSION" >> $GITHUB_OUTPUT
47+
48+
# Check if version contains letters (indicating pre-release)
49+
if echo "$VERSION" | grep -q '[a-zA-Z]'; then
50+
echo "is-prerelease=true" >> $GITHUB_OUTPUT
51+
echo "Detected pre-release version: $VERSION"
52+
else
53+
echo "is-prerelease=false" >> $GITHUB_OUTPUT
54+
echo "Detected stable release version: $VERSION"
55+
fi
56+
57+
- name: Check if version changed
58+
id: check
59+
run: |
60+
if git diff HEAD~1 HEAD --name-only | grep -q pyproject.toml; then
61+
if git diff HEAD~1 HEAD pyproject.toml | grep -q '^+version = '; then
62+
echo "changed=true" >> $GITHUB_OUTPUT
63+
echo "Version changed in pyproject.toml"
64+
else
65+
echo "changed=false" >> $GITHUB_OUTPUT
66+
echo "pyproject.toml changed but version did not change"
67+
fi
68+
else
69+
echo "changed=false" >> $GITHUB_OUTPUT
70+
echo "pyproject.toml was not changed"
71+
fi
72+
73+
build-package:
74+
name: "Build Python Package"
75+
runs-on: ubuntu-latest
76+
needs: [build, check-version-changed]
77+
if: needs.check-version-changed.outputs.version-changed == 'true'
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Install uv
82+
uses: astral-sh/setup-uv@v4
83+
with:
84+
enable-cache: true
85+
86+
- name: Set up Python
87+
run: uv python install 3.10
88+
89+
- name: Build package
90+
run: uv build
91+
92+
- name: Upload build artifacts
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: dist
96+
path: dist/
97+
98+
publish-pypi:
99+
name: "Publish to PyPI"
100+
runs-on: ubuntu-latest
101+
needs: [build-package, check-version-changed]
102+
if: needs.check-version-changed.outputs.version-changed == 'true'
103+
environment: release
104+
steps:
105+
- name: Download build artifacts
106+
uses: actions/download-artifact@v4
107+
with:
108+
name: dist
109+
path: dist/
110+
111+
- name: Install uv
112+
uses: astral-sh/setup-uv@v4
113+
114+
- name: Publish to PyPI
115+
run: uv publish --token ${{ secrets.PYPI_API_TOKEN }}
116+
working-directory: .
117+
118+
create-release:
119+
name: "Create GitHub Release"
120+
runs-on: ubuntu-latest
121+
needs: [publish-pypi, check-version-changed]
122+
if: needs.check-version-changed.outputs.version-changed == 'true'
123+
steps:
124+
- uses: actions/checkout@v4
125+
126+
- name: Download build artifacts
127+
uses: actions/download-artifact@v4
128+
with:
129+
name: dist
130+
path: dist/
131+
132+
- name: Create Release
133+
uses: softprops/action-gh-release@v2
134+
with:
135+
tag_name: v${{ needs.check-version-changed.outputs.version }}
136+
name: Release v${{ needs.check-version-changed.outputs.version }}
137+
draft: false
138+
prerelease: ${{ needs.check-version-changed.outputs.is-prerelease == 'true' }}
139+
generate_release_notes: true
140+
files: dist/*

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mouse-tracking"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "Runtime environment for mouse tracking experiments"
55
requires-python = ">=3.10,<3.11"
66
packages = ["src/mouse_tracking"]

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)