From 5a26610a01f022d3618edc672375e899d8cba9c3 Mon Sep 17 00:00:00 2001 From: david-loe <56305409+david-loe@users.noreply.github.com> Date: Tue, 12 Nov 2024 07:37:34 +0100 Subject: [PATCH] fix: update publish workfow to only tag stable versions latest (#1405) ## Description This pull request introduces modifications to the GitHub Actions workflow to ensure that the `latest` Docker tag is only pushed for stable releases. It prevents the `latest` tag from being assigned to release candidates (`-rc`), beta versions, or other pre-release tags. This enhancement improves version management by keeping the `latest` tag reserved exclusively for fully stable versions (e.g., `1.0.0`). ## Related Issue Fixes #1404 ## Changes Made - Added a conditional check to verify if the release version follows the format `X.Y.Z` (stable release format). - Updated the Docker manifest creation steps to only push the `latest` tag if the version is a stable full release. - Modified both DockerHub and GitHub Container Registry push steps to reflect the new versioning conditions. --- .github/workflows/publish.yml | 56 +++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f69ddb57b..3d65574c6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Publish Docker on: push: - branches: ['release'] + branches: ["release"] jobs: build_and_publish_platform_containers: @@ -89,22 +89,35 @@ jobs: APP_VERSION="$(git name-rev --tags --name-only $(git rev-parse HEAD) | head -n 1 | sed 's/\^0//')" GIT_SHA="$(git rev-parse HEAD)" - docker manifest create \ - documenso/documenso:latest \ - --amend documenso/documenso-amd64:latest \ - --amend documenso/documenso-arm64:latest \ + # Check if the version is stable (no rc or beta in the version) + if [[ "$APP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + docker manifest create \ + documenso/documenso:latest \ + --amend documenso/documenso-amd64:latest \ + --amend documenso/documenso-arm64:latest + + docker manifest push documenso/documenso:latest + fi + + if [[ "$APP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ ]]; then + docker manifest create \ + documenso/documenso:rc \ + --amend documenso/documenso-amd64:rc \ + --amend documenso/documenso-arm64:rc + + docker manifest push documenso/documenso:rc + fi docker manifest create \ documenso/documenso:$GIT_SHA \ --amend documenso/documenso-amd64:$GIT_SHA \ - --amend documenso/documenso-arm64:$GIT_SHA \ + --amend documenso/documenso-arm64:$GIT_SHA docker manifest create \ documenso/documenso:$APP_VERSION \ --amend documenso/documenso-amd64:$APP_VERSION \ - --amend documenso/documenso-arm64:$APP_VERSION \ + --amend documenso/documenso-arm64:$APP_VERSION - docker manifest push documenso/documenso:latest docker manifest push documenso/documenso:$GIT_SHA docker manifest push documenso/documenso:$APP_VERSION @@ -113,21 +126,34 @@ jobs: APP_VERSION="$(git name-rev --tags --name-only $(git rev-parse HEAD) | head -n 1 | sed 's/\^0//')" GIT_SHA="$(git rev-parse HEAD)" - docker manifest create \ - ghcr.io/documenso/documenso:latest \ - --amend ghcr.io/documenso/documenso-amd64:latest \ - --amend ghcr.io/documenso/documenso-arm64:latest \ + # Check if the version is stable (no rc or beta in the version) + if [[ "$APP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + docker manifest create \ + ghcr.io/documenso/documenso:latest \ + --amend ghcr.io/documenso/documenso-amd64:latest \ + --amend ghcr.io/documenso/documenso-arm64:latest + + docker manifest push ghcr.io/documenso/documenso:latest + fi + + if [[ "$APP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ ]]; then + docker manifest create \ + ghcr.io/documenso/documenso:rc \ + --amend ghcr.io/documenso/documenso-amd64:rc \ + --amend ghcr.io/documenso/documenso-arm64:rc + + docker manifest push ghcr.io/documenso/documenso:rc + fi docker manifest create \ ghcr.io/documenso/documenso:$GIT_SHA \ --amend ghcr.io/documenso/documenso-amd64:$GIT_SHA \ - --amend ghcr.io/documenso/documenso-arm64:$GIT_SHA \ + --amend ghcr.io/documenso/documenso-arm64:$GIT_SHA docker manifest create \ ghcr.io/documenso/documenso:$APP_VERSION \ --amend ghcr.io/documenso/documenso-amd64:$APP_VERSION \ - --amend ghcr.io/documenso/documenso-arm64:$APP_VERSION \ + --amend ghcr.io/documenso/documenso-arm64:$APP_VERSION - docker manifest push ghcr.io/documenso/documenso:latest docker manifest push ghcr.io/documenso/documenso:$GIT_SHA docker manifest push ghcr.io/documenso/documenso:$APP_VERSION