@@ -38,12 +38,12 @@ jobs:
3838 runs-on : ubuntu-latest
3939 steps :
4040 - name : Checkout
41- uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
41+ uses : actions/checkout@v3
4242 with :
4343 fetch-depth : 0
4444
4545 - name : Set up Go
46- uses : actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
46+ uses : actions/setup-go@v4
4747 with :
4848 go-version-file : " go.mod"
4949 check-latest : true
6969 id : go
7070 run : echo "go=$(go version | cut -d ' ' -f 3)" >> $GITHUB_OUTPUT
7171
72+ - name : Check if release is latest
73+ if : inputs.publish
74+ id : check_latest_release
75+ uses : actions/github-script@v7
76+ with :
77+ script : |
78+ const releaseTag = '${{ inputs.version }}';
79+ const { data: release } = await github.rest.repos.getReleaseByTag({
80+ owner: context.repo.owner,
81+ repo: context.repo.repo,
82+ tag: releaseTag
83+ });
84+
85+ const isLatest = !release.prerelease && !release.draft;
86+ core.setOutput('is_latest', isLatest);
87+ console.log(`Release: ${release.tag_name}`);
88+ console.log(`Prerelease: ${release.prerelease}, Draft: ${release.draft}`);
89+ console.log(`Should tag as latest: ${isLatest}`);
90+
7291 - name : Run GoReleaser (release)
7392 if : inputs.publish
7493 uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
@@ -108,60 +127,70 @@ jobs:
108127 INPUT_REGISTRY_NAMESPACE : ${{ inputs.registry_namespace }}
109128 INPUT_IMAGE_NAME : ${{ inputs.image_name }}
110129 REPO_OWNER : ${{ github.repository_owner }}
111- run : |
112- echo "cli_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
113- echo "image_sha_tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
114- echo "image_branch_tag=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
115-
116- if [[ "$INPUT_PUBLISH" == "true" ]]; then
117- # Get version from input, strip 'v' prefix
118- VERSION="$INPUT_VERSION"
119- VERSION="${VERSION#v}"
120- echo "version=$VERSION" >> $GITHUB_OUTPUT
121- else
122- echo "version=snapshot" >> $GITHUB_OUTPUT
123- fi
124-
125- # Determine registry (with auto-detection for temporalio vs forks)
126- REGISTRY="$INPUT_REGISTRY"
127- if [[ -z "$REGISTRY" ]]; then
128- if [[ "$REPO_OWNER" == "temporalio" ]]; then
129- REGISTRY="docker.io"
130- else
131- REGISTRY="ghcr.io"
132- fi
133- fi
134-
135- # Determine registry type for authentication
136- if [[ "$REGISTRY" == "ghcr.io" ]]; then
137- echo "registry_type=ghcr" >> $GITHUB_OUTPUT
138- elif [[ "$REGISTRY" == "docker.io" ]]; then
139- echo "registry_type=dockerhub" >> $GITHUB_OUTPUT
140- else
141- echo "registry_type=other" >> $GITHUB_OUTPUT
142- fi
143-
144- # Set namespace (defaults to repository owner)
145- NAMESPACE="$INPUT_REGISTRY_NAMESPACE"
146- if [[ -z "$NAMESPACE" ]]; then
147- NAMESPACE="$REPO_OWNER"
148- fi
149-
150- # Set image name (defaults to 'temporal')
151- IMAGE_NAME="$INPUT_IMAGE_NAME"
152- if [[ -z "$IMAGE_NAME" ]]; then
153- IMAGE_NAME="temporal"
154- fi
155-
156- # For Docker Hub, use empty string as registry (special case)
157- if [[ "$REGISTRY" == "docker.io" ]]; then
158- echo "image_repo=" >> $GITHUB_OUTPUT
159- else
160- echo "image_repo=${REGISTRY}" >> $GITHUB_OUTPUT
161- fi
162-
163- echo "image_namespace=${NAMESPACE}" >> $GITHUB_OUTPUT
164- echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
130+ uses : actions/github-script@v7
131+ with :
132+ script : |
133+ const inputVersion = process.env.INPUT_VERSION;
134+ const inputPublish = process.env.INPUT_PUBLISH;
135+ const inputRegistry = process.env.INPUT_REGISTRY;
136+ const inputRegistryNamespace = process.env.INPUT_REGISTRY_NAMESPACE;
137+ const inputImageName = process.env.INPUT_IMAGE_NAME;
138+ const repoOwner = process.env.REPO_OWNER;
139+
140+ // Get git information
141+ const { execSync } = require('child_process');
142+ const cliSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
143+ const imageShaTag = execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim();
144+ const imageBranchTag = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim();
145+
146+ core.setOutput('cli_sha', cliSha);
147+ core.setOutput('image_sha_tag', imageShaTag);
148+ core.setOutput('image_branch_tag', imageBranchTag);
149+
150+ // Determine version
151+ let version;
152+ if (inputPublish === 'true') {
153+ // Get version from input, strip 'v' prefix
154+ version = inputVersion.startsWith('v') ? inputVersion.slice(1) : inputVersion;
155+ } else {
156+ version = 'snapshot';
157+ }
158+ core.setOutput('version', version);
159+
160+ // Determine registry (with auto-detection for temporalio vs forks)
161+ let registry = inputRegistry;
162+ if (!registry) {
163+ if (repoOwner === 'temporalio') {
164+ registry = 'docker.io';
165+ } else {
166+ registry = 'ghcr.io';
167+ }
168+ }
169+
170+ // Determine registry type for authentication
171+ let registryType;
172+ if (registry === 'ghcr.io') {
173+ registryType = 'ghcr';
174+ } else if (registry === 'docker.io') {
175+ registryType = 'dockerhub';
176+ } else {
177+ registryType = 'other';
178+ }
179+ core.setOutput('registry_type', registryType);
180+
181+ // Set namespace (defaults to repository owner)
182+ const namespace = inputRegistryNamespace || repoOwner;
183+ core.setOutput('image_namespace', namespace);
184+
185+ // Set image name (defaults to 'temporal')
186+ const imageName = inputImageName || 'temporal';
187+ core.setOutput('image_name', imageName);
188+
189+ // For Docker Hub, use empty string as registry (special case)
190+ const imageRepo = registry === 'docker.io' ? '' : registry;
191+ core.setOutput('image_repo', imageRepo);
192+
193+ console.log(`Registry: ${registry}, Type: ${registryType}, Namespace: ${namespace}, Image: ${imageName}`);
165194
166195 - name : Log in to GitHub Container Registry
167196 if : inputs.publish && steps.meta.outputs.registry_type == 'ghcr'
@@ -182,15 +211,15 @@ jobs:
182211 if : inputs.publish
183212 run : |
184213 docker buildx bake \
185- --file .github/docker/ docker-bake.hcl \
214+ --file docker-bake.hcl \
186215 --push \
187216 cli
188217 env :
189218 CLI_SHA : ${{ steps.meta.outputs.cli_sha }}
190219 IMAGE_SHA_TAG : ${{ steps.meta.outputs.image_sha_tag }}
191220 IMAGE_BRANCH_TAG : ${{ steps.meta.outputs.image_branch_tag }}
192221 VERSION : ${{ steps.meta.outputs.version }}
193- TAG_LATEST : false
222+ TAG_LATEST : ${{ steps.check_latest_release.outputs.is_latest == 'true' }}
194223 IMAGE_REPO : ${{ steps.meta.outputs.image_repo }}
195224 IMAGE_NAMESPACE : ${{ steps.meta.outputs.image_namespace }}
196225 IMAGE_NAME : ${{ steps.meta.outputs.image_name }}
@@ -200,7 +229,7 @@ jobs:
200229 if : ${{ !inputs.publish }}
201230 run : |
202231 docker buildx bake \
203- --file .github/docker/ docker-bake.hcl \
232+ --file docker-bake.hcl \
204233 cli
205234 env :
206235 CLI_SHA : ${{ steps.meta.outputs.cli_sha }}
0 commit comments