From 2d21260f3778c8f9e6ab43e933b920905ab2aed5 Mon Sep 17 00:00:00 2001 From: Quadrubo <71718414+Quadrubo@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:53:59 +0200 Subject: [PATCH] feat: major and minor tags on docker build --- .github/workflows/cd-manual.yml | 19 +++++++++++++++++-- .github/workflows/cd.yml | 14 ++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd-manual.yml b/.github/workflows/cd-manual.yml index ac701fcc50..1f8651fa29 100644 --- a/.github/workflows/cd-manual.yml +++ b/.github/workflows/cd-manual.yml @@ -20,11 +20,26 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Extract version parts from input + id: extract_version + run: | + echo "version=$(echo ${{ github.event.inputs.version }})" >> $GITHUB_ENV + echo "major=$(echo ${{ github.event.inputs.version }} | cut -d. -f1)" >> $GITHUB_ENV + echo "minor=$(echo ${{ github.event.inputs.version }} | cut -d. -f2)" >> $GITHUB_ENV + + - name: Generate tags + id: generate_tags + run: | + echo "tag_major=$(echo ${{ matrix.db-type }}-${{ env.major }})" >> $GITHUB_ENV + echo "tag_minor=$(echo ${{ matrix.db-type }}-${{ env.major }}.${{ env.minor }})" >> $GITHUB_ENV + echo "tag_patch=$(echo ${{ matrix.db-type }}-${{ env.version }})" >> $GITHUB_ENV + echo "tag_latest=$(echo ${{ matrix.db-type }}-latest)" >> $GITHUB_ENV + - uses: mr-smithers-excellent/docker-build-push@v6 name: Build & push Docker image to ghcr.io for ${{ matrix.db-type }} with: image: umami - tags: ${{ matrix.db-type }}-${{ inputs.version }}, ${{ matrix.db-type }}-latest + tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }} buildArgs: DATABASE_TYPE=${{ matrix.db-type }} registry: ghcr.io multiPlatform: true @@ -36,7 +51,7 @@ jobs: name: Build & push Docker image to docker.io for ${{ matrix.db-type }} with: image: umamisoftware/umami - tags: ${{ matrix.db-type }}-${{ inputs.version }}, ${{ matrix.db-type }}-latest + tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }} buildArgs: DATABASE_TYPE=${{ matrix.db-type }} registry: docker.io username: ${{ secrets.DOCKER_USERNAME }} diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b4de549922..f67f51c385 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -17,14 +17,21 @@ jobs: - name: Set env run: | - echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV echo "NOW=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + + - name: Generate tags + id: generate_tags + run: | + echo "tag_patch=$(echo ${{ matrix.db-type }})-${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + echo "tag_minor=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1,2)" >> $GITHUB_ENV + echo "tag_major=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1)" >> $GITHUB_ENV + echo "tag_latest=$(echo ${{ matrix.db-type }})-latest" >> $GITHUB_ENV - uses: mr-smithers-excellent/docker-build-push@v6 name: Build & push Docker image to ghcr.io for ${{ matrix.db-type }} with: image: umami - tags: ${{ matrix.db-type }}-${{ env.RELEASE_VERSION }}, ${{ matrix.db-type }}-latest + tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }} buildArgs: DATABASE_TYPE=${{ matrix.db-type }} registry: ghcr.io multiPlatform: true @@ -32,12 +39,11 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - uses: mr-smithers-excellent/docker-build-push@v6 name: Build & push Docker image to docker.io for ${{ matrix.db-type }} with: image: umamisoftware/umami - tags: ${{ matrix.db-type }}-${{ env.RELEASE_VERSION }}, ${{ matrix.db-type }}-latest + tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }} buildArgs: DATABASE_TYPE=${{ matrix.db-type }} registry: docker.io username: ${{ secrets.DOCKER_USERNAME }}