Skip to content

Commit

Permalink
Allowing the developer to set the version in the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
crackitty committed Oct 30, 2024
1 parent a9ca2ef commit 9485075
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build-books-universium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: middlewaregruppen/books-universium
IMAGE_VERSION: 0.1.1
APP_PATH: books-universium

jobs:
build-and-push-image:
Expand All @@ -34,6 +34,12 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get version from __version__.py
id: get_version
run: |
VERSION=$(python -c 'import sys; sys.path.insert(0, "${{ env.APP_PATH }}"); from my_package import __version__; print(__version__)')
echo "IMAGE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
Expand All @@ -47,7 +53,7 @@ jobs:
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: books-universium
context: ${{ env.APP_PATH }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
10 changes: 8 additions & 2 deletions .github/workflows/build-demo-comics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: middlewaregruppen/demo-comics
IMAGE_VERSION: 0.21
APP_PATH: demo-comics

jobs:
build-and-push-image:
Expand All @@ -34,6 +34,12 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get version from __version__.py
id: get_version
run: |
VERSION=$(python -c 'import sys; sys.path.insert(0, "${{ env.APP_PATH }}"); from my_package import __version__; print(__version__)')
echo "IMAGE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
Expand All @@ -47,7 +53,7 @@ jobs:
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: demo-comics
context: ${{ env.APP_PATH }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions books-universium/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.1"
1 change: 1 addition & 0 deletions demo-comics/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.21"

0 comments on commit 9485075

Please sign in to comment.