Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bc4f485
Automate Docker image builds
chaptersix Nov 20, 2025
42cc84f
move the docker ignore file to the correct location
chaptersix Nov 20, 2025
04e92b6
fix a few bugs
chaptersix Nov 20, 2025
0e9929e
support building on pr and upgrade goreleaser
chaptersix Nov 20, 2025
4667b5c
Fix semgrep issues and wf permission
chaptersix Nov 20, 2025
15163e4
remove write perm from re-usable wf
chaptersix Nov 20, 2025
062c9b7
update go releaser to use formats instead of format and gh wf to stop…
chaptersix Nov 20, 2025
2155012
turn on caching and upload build artifacts.
chaptersix Nov 20, 2025
5ecf25a
remove makefile that is not longer needed
chaptersix Nov 21, 2025
8918ee7
correct alpine update command
chaptersix Nov 21, 2025
f6d0470
Modernize Docker build with parameterization and registry flexibility
chaptersix Nov 21, 2025
363f893
Address PR feedback: simplify Docker build and fix workflow issues
chaptersix Nov 22, 2025
41f7f4d
Update Dockerfile
chaptersix Nov 22, 2025
98cfaff
Add explicit permissions to trigger-docs workflow
chaptersix Nov 22, 2025
24bbfb8
Restore Makefile from upstream
chaptersix Nov 22, 2025
5aa5d9d
remoe support for ghcr, simplify script, action version update
chaptersix Nov 26, 2025
4274740
a few minor fixes
chaptersix Nov 26, 2025
fa17267
update action versions
chaptersix Nov 26, 2025
ef83ff2
simplify script again
chaptersix Nov 26, 2025
4864813
fix syntax and corrections for lint issues
chaptersix Nov 26, 2025
05b0021
add namespace default
chaptersix Nov 26, 2025
b7bda83
correct image name
chaptersix Nov 26, 2025
0388341
refactor update tag workflow
chaptersix Dec 1, 2025
2098e5c
remove comments and checks that are no longer needed
chaptersix Dec 1, 2025
a096c92
security fixes
chaptersix Dec 1, 2025
90577f9
add tzdata to dockerfile
chaptersix Dec 2, 2025
7b1df2e
update tag latest workflow and remove latest tagging from other code
chaptersix Dec 2, 2025
4249db7
refactor to build docker images only in a manually triggered workflow.
chaptersix Dec 3, 2025
c31c2f9
add option to publish a docker image
chaptersix Dec 3, 2025
c19e100
remove go releaser builds on pr and main
chaptersix Dec 3, 2025
0f2c204
fix bug. collect proper cli sha
chaptersix Dec 3, 2025
7c6e522
Merge branch 'main' into alex/docker-image-re
chaptersix Dec 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/scripts/check-latest-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { execFileSync } = require('child_process');
const fs = require('fs');

const releaseTag = process.env.RELEASE_TAG;
const version = releaseTag.startsWith('v') ? releaseTag.slice(1) : releaseTag;
const sourceImage = `temporalio/temporal:${version}`;
const latestImage = 'temporalio/temporal:latest';

// Set outputs for use in next step
fs.appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `source_image=${sourceImage}\n`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, `latest_image=${latestImage}\n`);

console.log(`Version: ${version}`);
console.log('Checking if image is already tagged as latest...');

try {
const latestManifest = execFileSync(
'docker',
['manifest', 'inspect', latestImage],
{ encoding: 'utf8' }
);
const latestDigest = JSON.parse(latestManifest).config.digest;

const sourceManifest = execFileSync(
'docker',
['manifest', 'inspect', sourceImage],
{ encoding: 'utf8' }
);
const sourceDigest = JSON.parse(sourceManifest).config.digest;

if (latestDigest === sourceDigest) {
console.log(`Image ${version} is already tagged as latest`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'already_latest=true\n');
process.exit(0);
}

console.log(`Latest digest: ${latestDigest}`);
console.log(`Source digest: ${sourceDigest}`);
console.log('Digests do not match, will update latest tag');
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'already_latest=false\n');

} catch (error) {
console.log('Could not compare digests (image may not exist yet)');
console.log(`Error: ${error.message}`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'already_latest=false\n');
}
191 changes: 191 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Build and Publish (Reusable)

on:
workflow_call:
inputs:
publish:
description: "Whether to publish the release and Docker image"
required: true
type: boolean
version:
description: "Version tag for the release (required if publish is true)"
required: false
type: string
registry_namespace:
description: "Registry namespace/organization"
required: false
type: string
default: "temporalio"
image_name:
description: "Image name"
required: false
type: string
default: "temporal"
secrets:
DOCKER_USERNAME:
required: false
DOCKER_PASSWORD:
required: false

jobs:
build:
name: Build and Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "go.mod"
check-latest: true
cache: true

- name: Get build date
id: date
run: echo "date=$(date '+%F-%T')" >> "$GITHUB_OUTPUT"

- name: Get build unix timestamp
id: timestamp
run: echo "timestamp=$(date '+%s')" >> "$GITHUB_OUTPUT"

- name: Get git branch
id: branch
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"

- name: Get build platform
id: platform
run: echo "platform=$(go version | cut -d ' ' -f 4)" >> "$GITHUB_OUTPUT"

- name: Get Go version
id: go
run: echo "go=$(go version | cut -d ' ' -f 3)" >> "$GITHUB_OUTPUT"

- name: Check if release is latest
if: inputs.publish
id: check_latest_release
uses: actions/github-script@v8
with:
script: |
const releaseTag = '${{ inputs.version }}';
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: releaseTag
});

const isLatest = !release.prerelease && !release.draft;
core.setOutput('is_latest', isLatest);
console.log(`Release: ${release.tag_name}`);
console.log(`Prerelease: ${release.prerelease}, Draft: ${release.draft}`);
console.log(`Should tag as latest: ${isLatest}`);

- name: Run GoReleaser (release)
if: inputs.publish
uses: goreleaser/goreleaser-action@v6
with:
version: v2.12.7
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_DATE: ${{ steps.date.outputs.date }}
BUILD_TS_UNIX: ${{ steps.timestamp.outputs.timestamp }}
GIT_BRANCH: ${{ steps.branch.outputs.branch }}
BUILD_PLATFORM: ${{ steps.platform.outputs.platform }}
GO_VERSION: ${{ steps.go.outputs.go }}

- name: Run GoReleaser (snapshot)
if: ${{ !inputs.publish }}
uses: goreleaser/goreleaser-action@v6
with:
version: v2.12.7
args: release --snapshot --clean
env:
BUILD_DATE: ${{ steps.date.outputs.date }}
BUILD_TS_UNIX: ${{ steps.timestamp.outputs.timestamp }}
GIT_BRANCH: ${{ steps.branch.outputs.branch }}
BUILD_PLATFORM: ${{ steps.platform.outputs.platform }}
GO_VERSION: ${{ steps.go.outputs.go }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Get build metadata
id: meta
env:
INPUT_VERSION: ${{ inputs.version }}
INPUT_PUBLISH: ${{ inputs.publish }}
INPUT_REGISTRY_NAMESPACE: ${{ inputs.registry_namespace }}
INPUT_IMAGE_NAME: ${{ inputs.image_name }}
REPO_OWNER: ${{ github.repository_owner }}
uses: actions/github-script@v8
with:
script: |
const inputVersion = process.env.INPUT_VERSION;
const inputPublish = process.env.INPUT_PUBLISH;
const inputRegistryNamespace = process.env.INPUT_REGISTRY_NAMESPACE;
const repoOwner = process.env.REPO_OWNER;

// Get git information
const { execSync } = require('child_process');
const cliSha = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
const imageShaTag = execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim();

core.setOutput('cli_sha', cliSha);
core.setOutput('image_sha_tag', imageShaTag);

// Determine version
let version;
if (inputPublish === 'true') {
// Get version from input, strip 'v' prefix
version = inputVersion.startsWith('v') ? inputVersion.slice(1) : inputVersion;
} else {
version = 'snapshot';
}
core.setOutput('version', version);

// Set namespace (defaults to repository owner)
const namespace = inputRegistryNamespace || repoOwner;
core.setOutput('image_namespace', namespace);

- name: Build Docker image
if: ${{ !inputs.publish }}
run: |
docker buildx bake \
--file docker-bake.hcl \
cli
env:
CLI_SHA: ${{ steps.meta.outputs.cli_sha }}
IMAGE_SHA_TAG: ${{ steps.meta.outputs.image_sha_tag }}
VERSION: ${{ steps.meta.outputs.version }}
TAG_LATEST: false
IMAGE_NAMESPACE: ${{ inputs.registry_namespace }}
IMAGE_NAME: ${{ inputs.image_name }}
GITHUB_REPOSITORY: ${{ github.repository }}

- name: Log in to Docker Hub
if: inputs.publish
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
if: ${{ inputs.publish }}
run: |
docker buildx bake \
--file docker-bake.hcl \
--push \
cli
env:
CLI_SHA: ${{ steps.meta.outputs.cli_sha }}
IMAGE_SHA_TAG: ${{ steps.meta.outputs.image_sha_tag }}
VERSION: ${{ steps.meta.outputs.version }}
TAG_LATEST: ${{ steps.check_latest_release.outputs.is_latest == 'true' }}
IMAGE_NAMESPACE: ${{ steps.meta.outputs.image_namespace }}
IMAGE_NAME: ${{ inputs.image_name }}
GITHUB_REPOSITORY: ${{ github.repository }}

15 changes: 15 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build Docker Image

on:
pull_request:
push:
branches:
- main

jobs:
build:
permissions:
contents: read
uses: ./.github/workflows/build-and-publish.yml
with:
publish: false
55 changes: 0 additions & 55 deletions .github/workflows/goreleaser.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
workflow_dispatch:
release:
types:
- published

permissions:
contents: write
packages: write

jobs:
release:
uses: ./.github/workflows/build-and-publish.yml
with:
publish: true
version: ${{ github.ref_name }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
25 changes: 16 additions & 9 deletions .github/workflows/trigger-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,39 @@ on:
workflow_dispatch:
release:
types: [published]

permissions:
contents: read

jobs:
update:
if: github.repository == 'temporalio/cli'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get user info from GitHub API
id: get_user
env:
GITHUB_ACTOR: ${{ github.actor }}
run: |
echo "GitHub actor: ${{ github.actor }}"
echo "GitHub actor: ${GITHUB_ACTOR}"
# Query the GitHub API for the user's details.
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/users/${{ github.actor }} > user.json
"https://api.github.com/users/${GITHUB_ACTOR}" > user.json

# Extract the user's full name if available, default to the username otherwise.
git_name=$(jq -r '.name // empty' user.json)
if [ -z "$git_name" ]; then
git_name="${{ github.actor }}"
git_name="${GITHUB_ACTOR}"
fi
git_email="${{ github.actor }}@users.noreply.github.com"

git_email="${GITHUB_ACTOR}@users.noreply.github.com"

# Set the outputs for subsequent steps.
echo "GIT_NAME=$git_name" >> $GITHUB_OUTPUT
echo "GIT_EMAIL=$git_email" >> $GITHUB_OUTPUT
echo "GIT_NAME=$git_name" >> "$GITHUB_OUTPUT"
echo "GIT_EMAIL=$git_email" >> "$GITHUB_OUTPUT"

- name: Generate token
id: generate_token
Expand Down
Loading
Loading