Merge pull request 'Autofill deploy version from latest git tag' (#13) from feature/auto-version-from-tag into develop
Some checks failed
Some checks failed
Reviewed-on: https://srvr.nu/git/git/jocke/bilhej/pulls/13
This commit is contained in:
commit
f60af7237e
1 changed files with 32 additions and 8 deletions
|
|
@ -4,9 +4,9 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: 'Git tag to create for this deploy (e.g. v0.1.2) — not the branch/tag above'
|
description: 'Leave as "auto" to bump from latest git tag, or enter a specific version (e.g. v0.1.2)'
|
||||||
required: true
|
required: false
|
||||||
default: 'v0.1.0'
|
default: 'auto'
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
@ -21,12 +21,36 @@ jobs:
|
||||||
git fetch --depth 1 origin ${GITHUB_SHA}
|
git fetch --depth 1 origin ${GITHUB_SHA}
|
||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
|
|
||||||
|
- name: Resolve version
|
||||||
|
run: |
|
||||||
|
INPUT_VERSION="${{ github.event.inputs.version }}"
|
||||||
|
if [ -z "$INPUT_VERSION" ] || [ "$INPUT_VERSION" = "auto" ]; then
|
||||||
|
git fetch --tags origin
|
||||||
|
LATEST=$(git tag --list 'v*' --sort=-v:refname | head -1)
|
||||||
|
if [ -z "$LATEST" ]; then LATEST="v0.0.0"; fi
|
||||||
|
BASE="${LATEST#v}"
|
||||||
|
MAJOR=$(echo "$BASE" | cut -d. -f1)
|
||||||
|
MINOR=$(echo "$BASE" | cut -d. -f2)
|
||||||
|
PATCH=$(echo "$BASE" | cut -d. -f3)
|
||||||
|
PATCH=$(( ${PATCH:-0} + 1 ))
|
||||||
|
VERSION="v${MAJOR:-0}.${MINOR:-0}.${PATCH}"
|
||||||
|
echo "Latest tag: $LATEST → auto-bumped to $VERSION"
|
||||||
|
else
|
||||||
|
VERSION="$INPUT_VERSION"
|
||||||
|
echo "Using manual version: $VERSION"
|
||||||
|
fi
|
||||||
|
if ! echo "$VERSION" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||||
|
echo "ERROR: resolved version '$VERSION' is not valid semver (expected vX.Y.Z)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Tag version
|
- name: Tag version
|
||||||
run: |
|
run: |
|
||||||
git tag -d ${{ github.event.inputs.version }} 2>/dev/null || true
|
git tag -d ${{ env.VERSION }} 2>/dev/null || true
|
||||||
git push origin --delete ${{ github.event.inputs.version }} 2>/dev/null || true
|
git push origin --delete ${{ env.VERSION }} 2>/dev/null || true
|
||||||
git tag ${{ github.event.inputs.version }}
|
git tag ${{ env.VERSION }}
|
||||||
git push origin ${{ github.event.inputs.version }}
|
git push origin ${{ env.VERSION }}
|
||||||
|
|
||||||
- name: Write production .env
|
- name: Write production .env
|
||||||
env:
|
env:
|
||||||
|
|
@ -134,7 +158,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo ""
|
echo ""
|
||||||
echo "═══════════════════════════════════════════════════"
|
echo "═══════════════════════════════════════════════════"
|
||||||
echo " Deployed ${{ github.event.inputs.version }} to production"
|
echo " Deployed ${{ env.VERSION }} to production"
|
||||||
echo "═══════════════════════════════════════════════════"
|
echo "═══════════════════════════════════════════════════"
|
||||||
echo ""
|
echo ""
|
||||||
docker compose -p bilhej-prod -f docker-compose.prod.yml ps
|
docker compose -p bilhej-prod -f docker-compose.prod.yml ps
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue