Skip to content

Commit a1167e2

Browse files
authored
Merge pull request #36 from KumarLabJax/master-branch-actions-trigger
Add trigger for commits on the github actions branch
2 parents 329c152 + 390b118 commit a1167e2

File tree

3 files changed

+145
-2
lines changed

3 files changed

+145
-2
lines changed

.github/workflows/release.yml

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

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[project]
22
name = "jabs-postprocess"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "A python library for JABS postprocessing utilities."
55
readme = "README.md"
6+
license = "LicenseRef-PLATFORM-LICENSE-AGREEMENT-FOR-NON-COMMERCIAL-USE"
7+
license-files = ["LICENSE"]
68
requires-python = ">=3.10"
79

810
dependencies = [
@@ -26,6 +28,9 @@ dependencies = [
2628
"typer>=0.15.4",
2729
]
2830

31+
[project.urls]
32+
repository = "https://github.com/KumarLabJax/JABS-postprocess"
33+
2934
[project.scripts]
3035
"jabs-postprocess" = "jabs_postprocess.cli.main:app"
3136

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)