From c808eaf05379728e0f149b2d041e47a5231238ac Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 12:15:13 -0700 Subject: [PATCH 1/9] Calculate admintools tag --- .github/workflows/release-admin-tools.yml | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index 69f3287b..6285fa32 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -8,9 +8,9 @@ on: commit: description: "Repo Commit sha" required: true - admintools_tag: - description: "The tag for the new admintools image" - required: true + patch: + description: "The optional patch version of the admintools image" + required: false latest: type: boolean description: "Also update latest tag" @@ -21,6 +21,11 @@ on: description: "Also update major tag" required: true default: false + dry-run: + description: "Whether or not this is a dry run" + type: boolean + required: false + default: true jobs: retag-and-release: @@ -32,10 +37,21 @@ jobs: - uses: actions/setup-go@v5 with: go-version-file: "**/go.mod" + - name: Calculate admintools tag + run: | + today=$(date "+%Y.%m.%d" | tr -d '\n') + patch= + if [ -n "${{inputs.patch}}" ]; then + patch="_${{inputs.patch}}" + fi + temporal_sha=$(shell sh -c 'git submodule status -- temporal | cut -c2-40') + cli_sha=$(shell sh -c 'git submodule status -- cli | cut -c2-40') + echo "TAG=${today}${patch}+server-${temporal_sha}-cli-${cli_sha}" >> "${GITHUB_ENV}" - name: Copy images + if: ! ${{ inputs.dry-run }} env: COMMIT: ${{ github.event.inputs.commit }} - TAG: ${{ github.event.inputs.admintools_tag }} + TAG: ${{ env.TAG }} USERNAME: ${{ secrets.DOCKER_USERNAME }} PASSWORD: ${{ secrets.DOCKER_PAT }} IMAGES: admintools From a00b6419aa7bb8fc121d4277f1aaf7fbf7fb540f Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 12:16:41 -0700 Subject: [PATCH 2/9] Move exclamation mark --- .github/workflows/release-admin-tools.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index 6285fa32..b4f1c804 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -48,7 +48,7 @@ jobs: cli_sha=$(shell sh -c 'git submodule status -- cli | cut -c2-40') echo "TAG=${today}${patch}+server-${temporal_sha}-cli-${cli_sha}" >> "${GITHUB_ENV}" - name: Copy images - if: ! ${{ inputs.dry-run }} + if: ${{ ! inputs.dry-run }} env: COMMIT: ${{ github.event.inputs.commit }} TAG: ${{ env.TAG }} From 7b942cd90faf7453defa71b499ab0c5ae43e6907 Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 12:18:48 -0700 Subject: [PATCH 3/9] DL submodules --- .github/workflows/release-admin-tools.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index b4f1c804..e54ca3ba 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -34,9 +34,11 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: "true" - uses: actions/setup-go@v5 with: - go-version-file: "**/go.mod" + go-version-file: "src/go.mod" - name: Calculate admintools tag run: | today=$(date "+%Y.%m.%d" | tr -d '\n') From 861e2c8e2688fb5b2e3d01c235341fac8208d595 Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 12:38:14 -0700 Subject: [PATCH 4/9] Calculate version --- .github/workflows/release-admin-tools.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index e54ca3ba..4f8ead4c 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -28,7 +28,7 @@ on: default: true jobs: - retag-and-release: + release-admin-tools: name: "Re-tag and release images" runs-on: ubuntu-latest @@ -41,16 +41,16 @@ jobs: go-version-file: "src/go.mod" - name: Calculate admintools tag run: | - today=$(date "+%Y.%m.%d" | tr -d '\n') - patch= - if [ -n "${{inputs.patch}}" ]; then - patch="_${{inputs.patch}}" - fi - temporal_sha=$(shell sh -c 'git submodule status -- temporal | cut -c2-40') - cli_sha=$(shell sh -c 'git submodule status -- cli | cut -c2-40') - echo "TAG=${today}${patch}+server-${temporal_sha}-cli-${cli_sha}" >> "${GITHUB_ENV}" + today=$(date "+%Y.%-m.%-d" | tr -d '\n') + patch= + if [ -n "${{inputs.patch}}" ]; then + patch="-p${{inputs.patch}}" + fi + temporal_ver=$(cd temporal && git describe --tags | cut -d '-' -f-2) + cli_ver=$(cd cli && git describe --tags | cut -d '-' -f-2) + tctl_ver=$(cd tctl && git describe --tags | cut -d '-' -f-2) + echo "TAG=${today}${patch}+server-${temporal_ver}.cli-${cli_ver}.tctl-${tctl_ver}" >> "${GITHUB_ENV}" - name: Copy images - if: ${{ ! inputs.dry-run }} env: COMMIT: ${{ github.event.inputs.commit }} TAG: ${{ env.TAG }} From c0067a3b19fc6362c9084c158627b27bea0ea98b Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 13:49:55 -0700 Subject: [PATCH 5/9] Calculate versions based on the provided commit --- .github/workflows/release-admin-tools.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index 4f8ead4c..695a3b7c 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -33,9 +33,14 @@ jobs: runs-on: ubuntu-latest steps: + # Main + - uses: actions/checkout@v4 + # For the action itself - uses: actions/checkout@v4 with: + path: target submodules: "true" + ref: ${{ github.event.inputs.commit }} - uses: actions/setup-go@v5 with: go-version-file: "src/go.mod" @@ -46,9 +51,9 @@ jobs: if [ -n "${{inputs.patch}}" ]; then patch="-p${{inputs.patch}}" fi - temporal_ver=$(cd temporal && git describe --tags | cut -d '-' -f-2) - cli_ver=$(cd cli && git describe --tags | cut -d '-' -f-2) - tctl_ver=$(cd tctl && git describe --tags | cut -d '-' -f-2) + temporal_ver=$(cd target/temporal && git describe --tags | cut -d '-' -f-2) + cli_ver=$(cd target/cli && git describe --tags | cut -d '-' -f-2) + tctl_ver=$(cd target/tctl && git describe --tags | cut -d '-' -f-2) echo "TAG=${today}${patch}+server-${temporal_ver}.cli-${cli_ver}.tctl-${tctl_ver}" >> "${GITHUB_ENV}" - name: Copy images env: From 726dd074e71028d0363467325d5dfd6084472c4f Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 14:35:37 -0700 Subject: [PATCH 6/9] Calculate them even better This is a bit nasty but it's due to how shallow checkouts work. We need to fetch the tag detail (then remove the shallow flag) so that git describe behaves as we want. We still use `--always` as `tctl` doesn't always seem to have a findable tag... --- .github/workflows/release-admin-tools.yml | 28 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index 695a3b7c..f46527e3 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -36,7 +36,8 @@ jobs: # Main - uses: actions/checkout@v4 # For the action itself - - uses: actions/checkout@v4 + - name: Check out target commit + uses: actions/checkout@v4 with: path: target submodules: "true" @@ -46,15 +47,32 @@ jobs: go-version-file: "src/go.mod" - name: Calculate admintools tag run: | + get_tag() { + # We need to remove the `shallow` marker for this submodule or else + # `git describe --tags` won't find our tags + cd "target/$1" + # We need to fetch the tags before git describe will do what we want + # We _only_ fetch the tags to save time + git fetch origin 'refs/tags/*:refs/tags/*' >&2 + rm -f ../.git/modules/$1/shallow + git describe --tags --always | cut -d '-' -f-2 + } + today=$(date "+%Y.%-m.%-d" | tr -d '\n') patch= if [ -n "${{inputs.patch}}" ]; then patch="-p${{inputs.patch}}" fi - temporal_ver=$(cd target/temporal && git describe --tags | cut -d '-' -f-2) - cli_ver=$(cd target/cli && git describe --tags | cut -d '-' -f-2) - tctl_ver=$(cd target/tctl && git describe --tags | cut -d '-' -f-2) - echo "TAG=${today}${patch}+server-${temporal_ver}.cli-${cli_ver}.tctl-${tctl_ver}" >> "${GITHUB_ENV}" + + tag="${today}${patch}+" + while read module; do + tag="${tag}${module}-$(get_tag ${module})." + done < <(git submodule status | cut -d ' ' -f3 | grep -v dockerize) + + # remove trailing period + tag=$(echo "${tag}" | sed 's/\.$//') + + echo "TAG=${tag}" >> "${GITHUB_ENV}" - name: Copy images env: COMMIT: ${{ github.event.inputs.commit }} From ef47e939d79f07c38aac427e7519c7c3147724cf Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart <409226+tdeebswihart@users.noreply.github.com> Date: Tue, 21 May 2024 14:41:50 -0700 Subject: [PATCH 7/9] Update .github/workflows/release-admin-tools.yml Co-authored-by: David Reiss --- .github/workflows/release-admin-tools.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index f46527e3..41e34fdb 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -58,7 +58,7 @@ jobs: git describe --tags --always | cut -d '-' -f-2 } - today=$(date "+%Y.%-m.%-d" | tr -d '\n') + today=$(date "+%Y.%-m.%-d") patch= if [ -n "${{inputs.patch}}" ]; then patch="-p${{inputs.patch}}" From 76ff211d8471eb35e618de40ffe65967d2d76a84 Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 14:51:56 -0700 Subject: [PATCH 8/9] Simplify slightly --- .github/workflows/release-admin-tools.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index 41e34fdb..7bac559b 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -21,11 +21,6 @@ on: description: "Also update major tag" required: true default: false - dry-run: - description: "Whether or not this is a dry run" - type: boolean - required: false - default: true jobs: release-admin-tools: @@ -69,10 +64,7 @@ jobs: tag="${tag}${module}-$(get_tag ${module})." done < <(git submodule status | cut -d ' ' -f3 | grep -v dockerize) - # remove trailing period - tag=$(echo "${tag}" | sed 's/\.$//') - - echo "TAG=${tag}" >> "${GITHUB_ENV}" + echo "TAG=${tag%.}" >> "${GITHUB_ENV}" - name: Copy images env: COMMIT: ${{ github.event.inputs.commit }} From 82b90d10772c50245a03df26072f6902934ed448 Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Tue, 21 May 2024 15:15:14 -0700 Subject: [PATCH 9/9] Clean up tag calculation slightly --- .github/workflows/release-admin-tools.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index 7bac559b..e34c4edd 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -53,13 +53,12 @@ jobs: git describe --tags --always | cut -d '-' -f-2 } - today=$(date "+%Y.%-m.%-d") - patch= + tag=$(date "+%Y.%-m.%-d") if [ -n "${{inputs.patch}}" ]; then - patch="-p${{inputs.patch}}" + tag="${tag}-p${{inputs.patch}}" fi - tag="${today}${patch}+" + tag="${tag}+" while read module; do tag="${tag}${module}-$(get_tag ${module})." done < <(git submodule status | cut -d ' ' -f3 | grep -v dockerize)