[ci] tagging
This commit is contained in:
parent
426f30e8d5
commit
a133e7f655
2 changed files with 32 additions and 3 deletions
20
.github/get-tags.py
vendored
Executable file
20
.github/get-tags.py
vendored
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from subprocess import check_output
|
||||
import sys
|
||||
|
||||
branch = check_output(["git", "branch", "--show-current"], text=True).strip()
|
||||
describe = check_output(["git", "describe", "--tags"], text=True).strip()
|
||||
tag = describe.split("-")[0][1:]
|
||||
a, b, c = tag.split(".")
|
||||
|
||||
if branch == "main":
|
||||
print("tags=latest")
|
||||
elif branch.startswith("branch-2."):
|
||||
if "-" in describe:
|
||||
print(f"tags={a},{a}.{b}")
|
||||
else:
|
||||
print(f"tags={a},{a}.{b},{a}.{b}.{c}")
|
||||
else:
|
||||
print("Only run from main or branch-2.X")
|
||||
sys.exit(1)
|
15
.github/workflows/publish.yml
vendored
15
.github/workflows/publish.yml
vendored
|
@ -9,8 +9,8 @@ on:
|
|||
types: completed
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
branches:
|
||||
- 'branch-2.*'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
@ -23,13 +23,22 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.workflow_run.head_sha }}
|
||||
fetch-tags: true
|
||||
fetch-depth: 0
|
||||
- name: Checkout main commit
|
||||
if: ${{ github.event_name != 'workflow_run' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
fetch-depth: 0
|
||||
- name: Set build vars
|
||||
run: |
|
||||
echo "BUILD_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
|
||||
echo "BUILD_HASH=$GITHUB_SHA" >> $GITHUB_ENV
|
||||
- name: Get tags
|
||||
id: get-tags
|
||||
shell: bash
|
||||
run: ./.github/get-tags.py >> $GITHUB_OUTPUT
|
||||
- name: Publish to Registry
|
||||
uses: elgohr/Publish-Docker-Github-Action@main
|
||||
with:
|
||||
|
@ -39,4 +48,4 @@ jobs:
|
|||
cache: ${{ github.event_name != 'schedule' }}
|
||||
buildoptions: "--build-arg RUN_TESTS=false"
|
||||
buildargs: BUILD_TIME,BUILD_HASH
|
||||
tag_semver: true
|
||||
tags: "${{ steps.get-tags.outputs.tags }}"
|
||||
|
|
Reference in a new issue