From ef30fa824b5ff42224c0dabb4ce2bba33154b866 Mon Sep 17 00:00:00 2001 From: Torsten Brendgen Date: Sat, 25 Apr 2026 18:17:03 +0200 Subject: [PATCH] refactor workflow: streamline tag creation process and improve variable handling --- .gitea/workflows/tag-from-toc.yml | 41 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/.gitea/workflows/tag-from-toc.yml b/.gitea/workflows/tag-from-toc.yml index bab6f1f..f24519f 100644 --- a/.gitea/workflows/tag-from-toc.yml +++ b/.gitea/workflows/tag-from-toc.yml @@ -12,6 +12,7 @@ jobs: steps: - name: Tools installieren run: | + set -e apt-get update apt-get install -y git grep sed @@ -19,22 +20,34 @@ jobs: run: | set -e echo "REPO=${{ gitea.repository }}" >> "$GITHUB_ENV" - echo "TAG=${{ gitea.ref_name }}" >> "$GITHUB_ENV" + echo "BRANCH=${{ gitea.ref_name }}" >> "$GITHUB_ENV" echo "SERVER_URL=https://git.local.unique-studios.de" >> "$GITHUB_ENV" echo "API_BASE=https://git.local.unique-studios.de/api/v1" >> "$GITHUB_ENV" + echo "TAG_PREFIX=v" >> "$GITHUB_ENV" + echo "GIT_USER_NAME=Gitea Actions" >> "$GITHUB_ENV" + echo "GIT_USER_EMAIL=actions@local" >> "$GITHUB_ENV" + + - name: Abgeleitete Variablen setzen + run: | + set -e + + REPO_NAME="${REPO##*/}" + + echo "REPO_NAME=${REPO_NAME}" >> "$GITHUB_ENV" + echo "TOC_FILE=${REPO_NAME}.toc" >> "$GITHUB_ENV" + echo "REPO_URL=https://oauth2:${{ secrets.PAT_TOKEN }}@git.local.unique-studios.de/${REPO}.git" >> "$GITHUB_ENV" - name: Repo klonen run: | + set -e rm -rf /tmp/repo - git clone https://oauth2:${{ secrets.PAT_TOKEN }}@git.local.unique-studios.de/${REPO}.git" /tmp/repo + git clone "${REPO_URL}" /tmp/repo - name: Version aus TOC lesen run: | set -e cd /tmp/repo - TOC_FILE="${REPO}.toc" - if [ ! -f "$TOC_FILE" ]; then echo "TOC-Datei nicht gefunden: $TOC_FILE" exit 1 @@ -47,12 +60,13 @@ jobs: exit 1 fi - TAG="v$VERSION" + RELEASE_TAG="${TAG_PREFIX}${VERSION}" echo "Gefundene Version: $VERSION" - echo "Neues Tag wäre: $TAG" + echo "Neues Tag wäre: $RELEASE_TAG" - echo "$TAG" > /tmp/release_tag.txt + echo "VERSION=${VERSION}" >> "$GITHUB_ENV" + echo "RELEASE_TAG=${RELEASE_TAG}" >> "$GITHUB_ENV" - name: Tag nur erstellen, wenn noch nicht vorhanden run: | @@ -60,15 +74,14 @@ jobs: cd /tmp/repo git fetch --tags - TAG=$(cat /tmp/release_tag.txt) - if git rev-parse "$TAG" >/dev/null 2>&1; then - echo "Tag $TAG existiert bereits, nichts zu tun." + if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then + echo "Tag $RELEASE_TAG existiert bereits, nichts zu tun." exit 0 fi - git config user.name "Gitea Actions" - git config user.email "actions@local" + git config user.name "$GIT_USER_NAME" + git config user.email "$GIT_USER_EMAIL" - git tag "$TAG" - git push origin "$TAG" \ No newline at end of file + git tag "$RELEASE_TAG" + git push origin "$RELEASE_TAG" \ No newline at end of file