Skip to content

Commit

Permalink
Fixing app verison in build?
Browse files Browse the repository at this point in the history
  • Loading branch information
camerongraybill committed Sep 15, 2024
1 parent 6411260 commit a7a65fa
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ jobs:

- uses: docker/setup-buildx-action@v3

- id: version
run: |
python -m venv ./venv
./venv/bin/pip install dunamai
echo "APP_VERSION=$(dunamai from git --style pep440)" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v6
with:
context: .
push: false
tags: ci
build-args:
APP_VERSION: ${{ steps.version.outputs.APP_VERSION }}
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ RUN python3 -m venv ./tools_venv
# We always want the latest pip, but the rest of our build dependencies should be locked.
RUN /venv/bin/pip install -U pip
RUN ./tools_venv/bin/pip install -U pip
RUN /venv/bin/pip install wheel==0.37.0
RUN ./tools_venv/bin/pip install wheel==0.37.0 poetry==1.6.1
RUN /venv/bin/pip install wheel
RUN ./tools_venv/bin/pip install wheel poetry==1.8.3

# Build and install dependencies to the output virtualenv first so we don't have to re-do it when the dependencies do not change
COPY ./poetry.lock ./poetry.lock
COPY ./pyproject.toml ./pyproject.toml
RUN ./tools_venv/bin/poetry export --with release --without dev -f 'requirements.txt' -o ./requirements.txt --without-hashes
RUN PATH=/home/build/tools_venv/bin:$PATH /venv/bin/pip install -r ./requirements.txt
RUN ./tools_venv/bin/pip install poetry-dynamic-versioning==0.13.1

# Copy in all source code so we can build the wheel
COPY --chown=build:users . ./src/
WORKDIR ./src/
COPY --chown=build:users ./src ./src
ARG APP_VERSION
RUN sed -i -e 's/v0.0.0/v$APP_VERSION/g' pyproject.toml
RUN PATH=/home/build/tools_venv/bin:$PATH ../tools_venv/bin/poetry build

# Install in the output virtualenv, which will eventually be copied to the final image
Expand Down
27 changes: 26 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mypy = "^1.11.2"
django-stubs = "^5.0.4"
ruff = "^0.6.5"
psycopg = { extras = ["binary"], version = "^3.2.1" }
dunamai = "^1.22.0"


[tool.poetry.group.release]
Expand All @@ -40,13 +41,9 @@ psycopg = { extras = ["c"], version = "^3.2.1" }
uvloop = "^0.20.0"

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"

[tool.mypy]
files = "src"
Expand Down

0 comments on commit a7a65fa

Please sign in to comment.