diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e810d9d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +docs/ +.claude +.benchmarks +.venv +.nf-test +mouse-tracking-runtime +nextflow +support_code +vm +*.h5 +*.sh +tests \ No newline at end of file diff --git a/.github/workflows/_build-docker-action.yml b/.github/workflows/_build-docker-action.yml index 2b2b1a1..c7c297a 100644 --- a/.github/workflows/_build-docker-action.yml +++ b/.github/workflows/_build-docker-action.yml @@ -47,4 +47,4 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 271baf0..f11c78c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,7 +2,7 @@ name: Pull Request Checks on: pull_request: - branches: [ main, repository-reorganization ] + branches: [ main ] jobs: format-lint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f682b5b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,140 @@ +name: Build and Release + +on: + push: + branches: [ main, master ] + paths: + - 'pyproject.toml' + +permissions: + contents: write + id-token: write + packages: write + +jobs: + format-lint: + name: "Format and Lint" + uses: ./.github/workflows/_format-lint-action.yml + + test: + name: "Run Tests" + needs: format-lint + uses: ./.github/workflows/_run-tests-action.yml + + build: + name: "Build Docker Image" + needs: [format-lint, test] + secrets: inherit + uses: ./.github/workflows/_build-docker-action.yml + + check-version-changed: + name: "Check if version changed" + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + version-changed: ${{ steps.check.outputs.changed }} + is-prerelease: ${{ steps.version.outputs.is-prerelease }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Get current version + id: version + run: | + VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') + echo "version=$VERSION" >> $GITHUB_OUTPUT + + # Check if version contains letters (indicating pre-release) + if echo "$VERSION" | grep -q '[a-zA-Z]'; then + echo "is-prerelease=true" >> $GITHUB_OUTPUT + echo "Detected pre-release version: $VERSION" + else + echo "is-prerelease=false" >> $GITHUB_OUTPUT + echo "Detected stable release version: $VERSION" + fi + + - name: Check if version changed + id: check + run: | + if git diff HEAD~1 HEAD --name-only | grep -q pyproject.toml; then + if git diff HEAD~1 HEAD pyproject.toml | grep -q '^+version = '; then + echo "changed=true" >> $GITHUB_OUTPUT + echo "Version changed in pyproject.toml" + else + echo "changed=false" >> $GITHUB_OUTPUT + echo "pyproject.toml changed but version did not change" + fi + else + echo "changed=false" >> $GITHUB_OUTPUT + echo "pyproject.toml was not changed" + fi + + build-package: + name: "Build Python Package" + runs-on: ubuntu-latest + needs: [build, check-version-changed] + if: needs.check-version-changed.outputs.version-changed == 'true' + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + enable-cache: true + + - name: Set up Python + run: uv python install 3.10 + + - name: Build package + run: uv build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + publish-pypi: + name: "Publish to PyPI" + runs-on: ubuntu-latest + needs: [build-package, check-version-changed] + if: needs.check-version-changed.outputs.version-changed == 'true' + environment: release + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Publish to PyPI + run: uv publish --token ${{ secrets.PYPI_API_TOKEN }} + working-directory: . + + create-release: + name: "Create GitHub Release" + runs-on: ubuntu-latest + needs: [publish-pypi, check-version-changed] + if: needs.check-version-changed.outputs.version-changed == 'true' + steps: + - uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ needs.check-version-changed.outputs.version }} + name: Release v${{ needs.check-version-changed.outputs.version }} + draft: false + prerelease: ${{ needs.check-version-changed.outputs.is-prerelease == 'true' }} + generate_release_notes: true + files: dist/* diff --git a/pyproject.toml b/pyproject.toml index 6c8ecd1..435619c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mouse-tracking" -version = "0.1.0" +version = "0.1.1" description = "Runtime environment for mouse tracking experiments" requires-python = ">=3.10,<3.11" packages = ["src/mouse_tracking"] diff --git a/uv.lock b/uv.lock index 2b2697b..25d1a3c 100644 --- a/uv.lock +++ b/uv.lock @@ -470,7 +470,7 @@ wheels = [ [[package]] name = "mouse-tracking" -version = "0.1.0" +version = "0.1.1" source = { editable = "." } dependencies = [ { name = "absl-py" },