Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish version change #17

Merged
merged 13 commits into from
Apr 28, 2024
47 changes: 31 additions & 16 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,55 +74,70 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Check PR Title
id: check_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch main branch
run: |
git fetch origin main:main --depth=1

- name: Get version from pyproject.toml in PR
id: pr_version
run: |
PR_VERSION=$(grep -Po '(?<=version = ")[^"]*' pyproject.toml)
echo "PR version: $PR_VERSION"
echo "::set-output name=pr_version::$PR_VERSION"

- name: Get version from pyproject.toml in main
id: main_version
run: |
git checkout main
MAIN_VERSION=$(grep -Po '(?<=version = ")[^"]*' pyproject.toml)
echo "Main version: $MAIN_VERSION"
echo "::set-output name=main_version::$MAIN_VERSION"

- name: Compare versions and set flag
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR_TITLE: $PR_TITLE"
VERSION_PATTERN="^Bump version: [0-9]+\.[0-9]+\.[0-9]+ → [0-9]+\.[0-9]+\.[0-9]+$"
if [[ "$PR_TITLE" =~ $VERSION_PATTERN ]]; then
echo "Valid PR title for publishing."
if [[ "${{ steps.pr_version.outputs.pr_version }}" != "${{ steps.main_version.outputs.main_version }}" ]]; then
echo "Version changed from ${{ steps.main_version.outputs.main_version }} to ${{ steps.pr_version.outputs.pr_version }}."
echo "::set-output name=should_publish::true"
else
echo "PR title does not match the required format for publishing."
echo "No version change detected."
echo "::set-output name=should_publish::false"
fi

- name: Set up python
if: steps.check_title.outputs.should_publish == 'true'
if: steps.check_version_change.outputs.should_publish == 'true'
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
if: steps.check_title.outputs.should_publish == 'true'
if: steps.check_version_change.outputs.should_publish == 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
if: steps.check_title.outputs.should_publish == 'true'
if: steps.check_version_change.outputs.should_publish == 'true'
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-3.x-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.check_title.outputs.should_publish == 'true' && steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
if: steps.check_version_change.outputs.should_publish == 'true' && steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install project
if: steps.check_title.outputs.should_publish == 'true'
if: steps.check_version_change.outputs.should_publish == 'true'
run: poetry install --no-interaction

- name: Publish to PyPI
if: steps.check_title.outputs.should_publish == 'true'
if: steps.check_version_change.outputs.should_publish == 'true'
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[tool.poetry]
name = "visprompt"
version = "0.1.2"
description = ""
description = "Repository and basic GUI for experimenting with visual prompting based on SAM and segGPT."
authors = ["mschnei"]
homepage = "https://github.com/MSchnei/visprompt"
packages = [ {include = "visprompt"} ]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
Expand Down
Loading