Skip to content

Commit

Permalink
Calculate version when building
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjohnsontv committed Dec 2, 2024
1 parent 773450d commit 043f14c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
inputs:
IMAGE_VERSION:
description: Version to use for image tag
required: true
default: "0.0.0"
required: false
type: string
BRANCH:
description: Git branch to fetch code from
Expand All @@ -27,16 +26,24 @@ jobs:
fetch-depth: 0
ref: ${{ inputs.BRANCH }}

- name: Calculate default version if not provided
id: set-version
run: |
if [ -z "${{ inputs.IMAGE_VERSION }}" ]; then
version=$(git describe --tags --abbrev=0 --match="v[0-9]*" | cut -c2-)-dev-${{ inputs.BRANCH }}-$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')
echo "IMAGE_VERSION=$version" >> $GITHUB_ENV
else
echo "IMAGE_VERSION=${{ inputs.IMAGE_VERSION }}" >> $GITHUB_ENV
fi
- uses: actions/download-artifact@v4
with:
name: build
path: build/webpack

- name: Set release info
run: |
release_version=${{ inputs.IMAGE_VERSION }}
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "TAGS=${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:$release_version" >> $GITHUB_ENV
echo "TAGS=${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}" >> $GITHUB_ENV
- name: Login
uses: docker/login-action@v3
Expand Down Expand Up @@ -71,4 +78,4 @@ jobs:
tags: ${{ env.TAGS }}
labels: |
org.opencontainers.image.source=https://github.com/${{ env.IMAGE_NAME }}
org.opencontainers.image.version=${{ env.RELEASE_VERSION }}
org.opencontainers.image.version=${{ env.IMAGE_VERSION }}
6 changes: 3 additions & 3 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
type: string
THD_DECK_VERSION:
description: Version of THD Deck
required: true
default: "0.0.0"
required: false
default: ""
type: string

jobs:
Expand All @@ -25,4 +25,4 @@ jobs:
uses: ./.github/workflows/docker-build.yml
with:
BRANCH: ${{ inputs.BRANCH }}
IMAGE_VERSION: ${{ inputs.THD_DECK_VERSION }}
IMAGE_VERSION: ${{ inputs.THD_DECK_VERSION }}

0 comments on commit 043f14c

Please sign in to comment.