From 7da0095a1f76dd06ba69693a166f07ccb9bb0c2b Mon Sep 17 00:00:00 2001 From: edraft Date: Fri, 17 Jan 2025 19:45:18 +0100 Subject: [PATCH] New version format --- .gitea/workflows/build dev.yaml | 67 ++++++++++++++++++++++++++++----- .gitea/workflows/build.yaml | 49 ++++++++++++++++++++---- version.txt | 1 - 3 files changed, 100 insertions(+), 17 deletions(-) delete mode 100644 version.txt diff --git a/.gitea/workflows/build dev.yaml b/.gitea/workflows/build dev.yaml index 1ab0ca0..71cb934 100644 --- a/.gitea/workflows/build dev.yaml +++ b/.gitea/workflows/build dev.yaml @@ -1,13 +1,49 @@ -name: Build dev on push -run-name: Build dev on push +name: Build on push +run-name: Build on push on: push: branches: - dev jobs: + prepare: + runs-on: [runner] + container: git.sh-edraft.de/sh-edraft.de/act-runner:latest + steps: + - name: Clone Repository + uses: https://github.com/actions/checkout@v3 + with: + token: ${{ secrets.CI_ACCESS_TOKEN }} + + - name: Get Date and Build Number + run: | + DATE=$(date +'%Y.%m.%d') + git fetch --tags + TAG_COUNT=$(git tag -l "${DATE}.*" | wc -l) + BUILD_NUMBER=$(($TAG_COUNT + 1)) + BUILD_VERSION="${DATE}.${BUILD_NUMBER}-dev" + echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV + + - name: Create Git Tag for Build + run: | + git config user.name "ci" + git config user.email "dev@sh-edratf.de" + git tag ${{ env.BUILD_VERSION }} + git push origin ${{ env.BUILD_VERSION }} + + - name: Save Version Info + run: | + echo "VERSION = \"${{ env.BUILD_VERSION }}\"" > api/version.py + + - name: Upload build version artifact + uses: actions/upload-artifact@v3 + with: + name: build-version + path: build_version.txt + build-api: runs-on: [runner] + needs: prepare container: git.sh-edraft.de/sh-edraft.de/act-runner:latest steps: - name: Clone Repository @@ -15,10 +51,21 @@ jobs: with: token: ${{ secrets.CI_ACCESS_TOKEN }} + + - name: Download build version artifact + uses: actions/download-artifact@v3 + with: + name: build-version + + - name: Load build version + run: | + BUILD_VERSION=$(cat build_version.txt) + echo "Loaded BUILD_VERSION=$BUILD_VERSION" + - name: Build docker run: | cd api - docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-api-dev:$(cat ../version.txt) . + docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-api:$BUILD_VERSION . - name: Login to registry git.sh-edraft.de uses: https://github.com/docker/login-action@v1 @@ -29,10 +76,11 @@ jobs: - name: Push image run: | - docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api-dev:$(cat version.txt) - + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api:${{ needs.prepare.outputs.build_version }} + build-redirector: runs-on: [runner] + needs: prepare container: git.sh-edraft.de/sh-edraft.de/act-runner:latest steps: - name: Clone Repository @@ -43,7 +91,7 @@ jobs: - name: Build docker run: | cd api - docker build -f dockerfile_redirector -t git.sh-edraft.de/sh-edraft.de/open-redirect-redirector-dev:$(cat ../version.txt) . + docker build -f dockerfile_redirector -t git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:${{ needs.prepare.outputs.build_version }} . - name: Login to registry git.sh-edraft.de uses: https://github.com/docker/login-action@v1 @@ -54,10 +102,11 @@ jobs: - name: Push image run: | - docker push git.sh-edraft.de/sh-edraft.de/open-redirect-redirector-dev:$(cat version.txt) + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:${{ needs.prepare.outputs.build_version }} build-web: runs-on: [runner] + needs: prepare container: git.sh-edraft.de/sh-edraft.de/act-runner:latest steps: - name: Clone Repository @@ -78,7 +127,7 @@ jobs: - name: Build docker run: | cd web - docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-web-dev:$(cat ../version.txt) . + docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-web:${{ needs.prepare.outputs.build_version }} . - name: Login to registry git.sh-edraft.de uses: https://github.com/docker/login-action@v1 @@ -89,4 +138,4 @@ jobs: - name: Push image run: | - docker push git.sh-edraft.de/sh-edraft.de/open-redirect-web-dev:$(cat version.txt) + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-web:${{ needs.prepare.outputs.build_version }} diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 1d48b26..f898529 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -6,8 +6,41 @@ on: - master jobs: + prepare: + runs-on: [runner] + container: git.sh-edraft.de/sh-edraft.de/act-runner:latest + outputs: + build_version: ${{ steps.prepare.outputs.build_version }} + steps: + - name: Clone Repository + uses: https://github.com/actions/checkout@v3 + with: + token: ${{ secrets.CI_ACCESS_TOKEN }} + + - name: Get Date and Build Number + run: | + DATE=$(date +'%Y.%m.%d') + git fetch --tags + TAG_COUNT=$(git tag -l "${DATE}.*" | wc -l) + BUILD_NUMBER=$(($TAG_COUNT + 1)) + BUILD_VERSION="${DATE}.${BUILD_NUMBER}" + echo "build_version=$BUILD_VERSION" >> $GITHUB_OUTPUT + echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV + + - name: Create Git Tag for Build + run: | + git config user.name "ci" + git config user.email "dev@sh-edratf.de" + git tag ${{ env.BUILD_VERSION }} + git push origin ${{ env.BUILD_VERSION }} + + - name: Save Version Info + run: | + echo "VERSION = \"${{ env.BUILD_VERSION }}\"" > api/version.py + build-api: runs-on: [runner] + needs: [prepare] container: git.sh-edraft.de/sh-edraft.de/act-runner:latest steps: - name: Clone Repository @@ -18,7 +51,7 @@ jobs: - name: Build docker run: | cd api - docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-api:$(cat ../version.txt) . + docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-api:${{ needs.prepare.outputs.build_version }} . - name: Login to registry git.sh-edraft.de uses: https://github.com/docker/login-action@v1 @@ -29,10 +62,11 @@ jobs: - name: Push image run: | - docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api:$(cat version.txt) - + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api:${{ needs.prepare.outputs.build_version }} + build-redirector: runs-on: [runner] + needs: [prepare] container: git.sh-edraft.de/sh-edraft.de/act-runner:latest steps: - name: Clone Repository @@ -43,7 +77,7 @@ jobs: - name: Build docker run: | cd api - docker build -f dockerfile_redirector -t git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:$(cat ../version.txt) . + docker build -f dockerfile_redirector -t git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:${{ needs.prepare.outputs.build_version }} . - name: Login to registry git.sh-edraft.de uses: https://github.com/docker/login-action@v1 @@ -54,10 +88,11 @@ jobs: - name: Push image run: | - docker push git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:$(cat version.txt) + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-redirector:${{ needs.prepare.outputs.build_version }} build-web: runs-on: [runner] + needs: [prepare] container: git.sh-edraft.de/sh-edraft.de/act-runner:latest steps: - name: Clone Repository @@ -78,7 +113,7 @@ jobs: - name: Build docker run: | cd web - docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-web:$(cat ../version.txt) . + docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-web:${{ needs.prepare.outputs.build_version }} . - name: Login to registry git.sh-edraft.de uses: https://github.com/docker/login-action@v1 @@ -89,4 +124,4 @@ jobs: - name: Push image run: | - docker push git.sh-edraft.de/sh-edraft.de/open-redirect-web:$(cat version.txt) + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-web:${{ needs.prepare.outputs.build_version }} diff --git a/version.txt b/version.txt deleted file mode 100644 index cb174d5..0000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -1.2.1 \ No newline at end of file