Skip to content

Publish latest version of TSL #22

Publish latest version of TSL

Publish latest version of TSL #22

name: Packaging
run-name: Publish latest version of TSL
# on:
# workflow_run:
# workflows: [create-package-images]
# types:
# - completed
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
setup-rpm-build-environment:
name: Setup RPM Build Environment
uses: ./.github/workflows/setup-environment.yml
with:
requirement-file: "requirements.txt"
docker-tag: "${{ vars.RPM_TAG }}"
context: ".github/actions/tsl-rpm-build"
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
setup-deb-build-environment:
name: Setup DEB Build Environment
uses: ./.github/workflows/setup-environment.yml
with:
requirement-file: "requirements.txt"
docker-tag: "${{ vars.DEB_TAG }}"
context: ".github/actions/tsl-deb-build"
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
auto-tag:
name: Auto-Tag current Head
runs-on: ubuntu-latest
if:
github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions: write-all
outputs:
tag: ${{ steps.push-tag.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Auto-Tag
id: push-tag
run: |
git fetch --tags
LATEST_TAG=$(git tag -l --sort=-v:refname "v*" | head -n 1)
if [ -z "${LATEST_TAG}" ]; then
echo "No tag: $LATEST_TAG"
LATEST_TAG=v0.0.0-rc1
else
echo "Latest tag: $LATEST_TAG"
fi
LATEST_TAG=${LATEST_TAG:1}
echo "latest=${LATEST_TAG}"
MAJOR=${LATEST_TAG%%.*}
echo "major=${MAJOR}"
TEMP=${LATEST_TAG#*.}
echo "temp=${TEMP}"
MINOR=${TEMP%%.*}
echo "minor=${MINOR}"
PATCHTEMP=${TEMP#*.}
echo "patchtemp=$PATCHTEMP"
PATCH=${PATCHTEMP%%-*}
echo "patch=${PATCH}"
RC_TMP=${PATCHTEMP#*-}
RC=${RC_TMP:2}
if [ -z "${RC}" ]; then
PATCH=$((PATCH+1))
RC=1
else
RC=$((RC+1))
fi
echo "rc=${RC}"
VERSION="v${MAJOR}.${MINOR}.${PATCH}-rc${RC}"
echo "New Version: ${VERSION}"
echo "tag=${VERSION}"
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action (Maintainer: Johannes Pietrzyk)"
git tag -a $VERSION -m "${VERSION} (Auto-tagged by GitHub Actions)"
git push origin --tags
release-on-push:
name: Release on Push
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [setup-rpm-build-environment, setup-deb-build-environment, auto-tag]
permissions: write-all
uses: ./.github/workflows/release-tsl.yml
with:
tag-name: ${{ needs.auto-tag.outputs.tag }}
secrets:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
get-tag:
name: Get Tag
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
outputs:
tag: ${{ steps.get-tag.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Tag
id: get-tag
run: |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
release-on-tag:
name: Release on Tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [setup-rpm-build-environment, setup-deb-build-environment, get-tag]
permissions: write-all
uses: ./.github/workflows/release-tsl.yml
with:
tag-name: ${{ needs.get-tag.outputs.tag }}
secrets:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}