Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/actions/local-action/action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# action.yaml
name: "Get release version"
description: "A GitHub Action to determine the next version by checking the commit history for Conventional Commits"
inputs:
Expand Down
16 changes: 11 additions & 5 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ description: Setup python
runs:
using: composite
steps:
- name: "Setup Python, Poetry and Dependencies"
uses: packetcoders/action-setup-cache-python-poetry@main
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.12
poetry-version: 1.8.2
version: '0.6.2'
enable-cache: true

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'

- name: Install dependencies
run: poetry install --no-interaction --with dev
shell: bash
run: |
uv sync
80 changes: 20 additions & 60 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,37 @@ on:
- main

jobs:
app-pylint:
name: pylint (App)
style-check:
name: Code style checking
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python
uses: ./.github/actions/setup-python

- name: Add pylint annotator
uses: pr-annotators/pylint-pr-annotator@v0.0.1
- name: Run ruff format
run: |
uv run ruff format --check

- name: Run pylint
run: poetry run pylint get_release_version_action

app-flake8:
name: flake8 (App)
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python
uses: ./.github/actions/setup-python

- name: Add flake8 annotator
uses: rbialon/flake8-annotations@v1.1

- name: Run flake8
run: poetry run flake8 get_release_version_action
- name: Run ruff check
run: |
uv run ruff check --output-format=github

app-mypy:
name: mypy (App)
type-check-app:
name: Type checking (App)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python
uses: ./.github/actions/setup-python
Expand All @@ -52,46 +45,13 @@ jobs:
uses: pr-annotators/mypy-pr-annotator@v1.0.0

- name: Run mypy
run: poetry run mypy get_release_version_action

tests-pylint:
name: pylint (Tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: ./.github/actions/setup-python

- name: Add pylint annotator
uses: pr-annotators/pylint-pr-annotator@main

- name: Run pylint
run: poetry run pylint tests/e2e

tests-flake8:
name: flake8 (Tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: ./.github/actions/setup-python

- name: Add pylint annotator
uses: rbialon/flake8-annotations@v1.1

- name: Run flake8
run: poetry run flake8 tests
run: uv run mypy src/get_release_version_action

tests-mypy:
name: mypy (Tests)
type-check-tests:
name: Type checking (Tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Python
uses: ./.github/actions/setup-python
Expand All @@ -100,4 +60,4 @@ jobs:
uses: pr-annotators/mypy-pr-annotator@v1.0.0

- name: Run mypy
run: poetry run mypy tests
run: uv run mypy tests
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
uses: ./.github/actions/setup-python

- name: Run pytest
run: poetry run pytest --junit-xml test-result.xml tests/e2e
run: uv run pytest --junit-xml test-result.xml tests/e2e

- name: Upload test results
if: always()
uses: pmeier/pytest-results-action@v0.6.0
uses: pmeier/pytest-results-action@v0.7.1
with:
path: test-result.xml
summary: true
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

55 changes: 27 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
FROM python:3.12-slim

# Install poetry
# Thanks to Soof Golan and jjmerelo from StackOverflow: https://stackoverflow.com/a/72465422
ARG POETRY_VERSION=1.8.2
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache

# Create a venv and install Poetry there
RUN /usr/local/bin/python3.12 -m venv $POETRY_VENV
RUN $POETRY_VENV/bin/python -m pip install -U pip setuptools
RUN $POETRY_VENV/bin/python -m pip install poetry==${POETRY_VERSION}

# Add Poetry to the PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"

# Print which git
RUN echo "which git: $(which git)"
FROM python:3.13-slim

# Install git
RUN apt-get -yq update && \
apt-get -yq install git && \
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y git && \
apt clean -y && \
rm -rf /var/lib/apt/lists/*

# Copy the action
COPY ["poetry.lock", "pyproject.toml", "/action/"]
COPY ["get_release_version_action/", "/action/get_release_version_action/"]
# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.6.2 /uv /bin/

# Do not update the lock file
ARG UV_FROZEN=1
# Copy cached packages instead of linking them
ARG UV_LINK_MODE=copy
# Compile Python bytecode on build time to improve startup times
ARG UV_COMPILE_BYTECODE=1

# Install dependencies
RUN poetry -C /action install --no-interaction --no-cache --without dev
RUN poetry -C /action install --no-interaction --no-cache --only-root
WORKDIR /app
COPY .python-version pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-install-project --no-dev

# Add virtual environment to PATH
ENV PATH="/app/.venv/bin:$PATH"

ENV PYTHONPATH="/action"
# Copy and install source code
COPY src/get_release_version_action/ src/get_release_version_action/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev

RUN chmod +x /action/get_release_version_action/entrypoint.sh
ENTRYPOINT ["/action/get_release_version_action/entrypoint.sh"]
RUN chmod +x /app/src/get_release_version_action/entrypoint.sh
ENTRYPOINT ["/app/src/get_release_version_action/entrypoint.sh"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 wemogy
Copyright (c) 2025 wemogy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
59 changes: 10 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,24 @@ We had this issue, which finally led to the decision to implement the semantic r

## Development

This project uses [poetry](https://python-poetry.org/docs/#installation) for dependency management.
This project uses [uv](https://docs.astral.sh/uv/).

### Install dependencies

For development:

```bash
# working directory: repository root
poetry install --with dev
uv sync
```

For production:

```bash
# working directory: repository root
poetry install --without dev
```
This commands creates a virtual environment that can be used just like one created by the `venv` module.

### Add or update dependencies
### Add, update and remove dependencies

```bash
# working directory: repository root
poetry add <dependency>[@^<version>] [--group dev]
poetry update [<dependency>[@^<version>]]
uv add <dependency>[==<version>] [--dev]
uv add "<dependency>==<version>" --upgrade-package <dependency> [--dev]
uv remove <dependency> [--dev]
```

Some dependencies are missing type definitions (stubs) for mypy.
Expand All @@ -140,19 +134,11 @@ Again, check those functions and classes after you run the command.
stubgen -o .mypy_stubs -p semantic_release
```

### Activate the poetry shell

```bash
# working directory: repository root
poetry shell
```

### Run the script

```bash
# with poetry shell
# working directory: src
python3 app.py [...args]
# working directory: repository root
uv run src/get_release_version_action/app.py [...args]
```

### Run the Docker container
Expand All @@ -174,31 +160,6 @@ docker run get-release-version-action:local
### Run the tests

```bash
# with poetry shell
# working directory: tests
pytest tests
uv run pytest tests
```

The tests are isolated from the actual source code, because they are supposed to test the same interface that the action also uses.
This means that the tests **must not** import anything from the source code or vice versa.

### Run linting and type checking

This project uses pylint and flake8 for linting / code style checking and mypy for static type checking.

All tools are configured in the `pyproject.toml`.

```bash
# with poetry shell
# working directory: repository root
pylint get_release_version_action
flake8 get_release_version_action
mypy get_release_version_action

pylint tests/e2e
flake8 tests
mypy tests
```

> [!IMPORTANT]
> Source code and tests are isolated from each other and also need to be checked isolated from each other to prevent false warnings.
3 changes: 1 addition & 2 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# action.yaml
name: "Get release version"
description: "A GitHub Action to determine the next version by checking the commit history for Conventional Commits"
inputs:
Expand Down Expand Up @@ -51,7 +50,7 @@ outputs:
description: "If any relevant changes got detected and a tag got created."
runs:
using: "docker"
image: "docker://ghcr.io/wemogy/get-release-version-action:4.3.2"
image: "docker://ghcr.io/wemogy/get-release-version-action:4.3.3"
args:
- --prefix
- ${{ inputs.prefix }}
Expand Down
13 changes: 0 additions & 13 deletions get_release_version_action/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions get_release_version_action/app.py

This file was deleted.

9 changes: 0 additions & 9 deletions get_release_version_action/models/__init__.py

This file was deleted.

Loading
Loading