Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 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
f4de68a
Merge pull request #1 from chaptersix/ghcr-migration
chaptersix Nov 21, 2025
5cbb05d
Migrate Docker publishing from Docker Hub to GHCR
chaptersix Nov 21, 2025
1a397e1
Merge pull request #2 from chaptersix/ghcr-migration
chaptersix Nov 21, 2025
305e867
Fix IMAGE_REPO to include ghcr.io registry prefix for forks
chaptersix Nov 21, 2025
f813c53
Merge pull request #3 from chaptersix/fix-ghcr-registry-prefix
chaptersix Nov 21, 2025
01cf0a7
Improve repository and registry parameterization
chaptersix Nov 21, 2025
ddbb2e2
Merge pull request #4 from chaptersix/fix-ghcr-registry-prefix
chaptersix Nov 21, 2025
2c95596
Improve repository and registry parameterization
chaptersix Nov 21, 2025
3969e49
Resolve merge conflict in docker-bake.hcl
chaptersix Nov 21, 2025
09c343c
Merge pull request #5 from chaptersix/fix-ghcr-registry-prefix
chaptersix Nov 21, 2025
bc8ab4e
Add separate workflow for managing latest Docker tag
chaptersix Nov 21, 2025
9b61fa8
Merge remote-tracking branch 'origin/main' into fix-ghcr-registry-prefix
chaptersix Nov 21, 2025
8bdf5ef
Remove artifact uploading and add packages permission
chaptersix Nov 21, 2025
16e76e4
Merge pull request #6 from chaptersix/fix-ghcr-registry-prefix
chaptersix Nov 21, 2025
fc8907c
Make Docker image labels dynamic based on repository
chaptersix Nov 21, 2025
90d4238
Merge pull request #7 from chaptersix/fix-ghcr-registry-prefix
chaptersix Nov 21, 2025
f6d0470
Modernize Docker build with parameterization and registry flexibility
chaptersix Nov 21, 2025
bda2d14
Address PR feedback: simplify Dockerfile and workflows
chaptersix Nov 21, 2025
eb253ec
Merge origin/main, keeping JavaScript registry logic and major versio…
chaptersix Nov 21, 2025
de99805
Convert build-and-publish.yml registry logic to JavaScript
chaptersix Nov 21, 2025
3d355a1
Convert Dockerfile to use distroless base image
chaptersix Nov 22, 2025
5f92312
Move docker-bake.hcl to root and update references
chaptersix Nov 22, 2025
2d3086e
Convert Dockerfile to use scratch base for maximum minimalism
chaptersix Nov 22, 2025
f64d6f2
Fix Dockerfile to work with GoReleaser output structure
chaptersix Nov 22, 2025
144d933
Clean up Docker build file organization
chaptersix Nov 22, 2025
312bcef
Add latest tag detection for Docker image builds
chaptersix Nov 22, 2025
92f17f3
Fix latest tag logic to push both latest and release tags
chaptersix Nov 22, 2025
86172ad
Fix Docker build bugs: remove invalid platform ARG and correct TAG_LA…
chaptersix Nov 22, 2025
3dedd3e
Use intermediate dist stage for reliable multi-platform builds
chaptersix Nov 22, 2025
942869d
Simplify Dockerfile to use Alpine base without intermediate stage
chaptersix Nov 22, 2025
1db66a6
Clean up Dockerfile: remove syntax comment and simplify structure
chaptersix Nov 22, 2025
ff9df1a
Add explicit chmod to COPY instruction for binary permissions
chaptersix Nov 22, 2025
21f02c6
Restore intermediate dist stage for explicit path normalization
chaptersix Nov 22, 2025
214cd34
Restrict trigger-docs workflow to temporalio/cli repository only
chaptersix Nov 22, 2025
de4a3ec
Use version tag instead of commit SHA for goreleaser action
chaptersix Nov 22, 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
243 changes: 243 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
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:
description: "Container registry (docker.io, ghcr.io, etc.)"
required: false
type: string
default: ""
registry_namespace:
description: "Registry namespace/organization"
required: false
type: string
default: ""
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@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
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@v7
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/[email protected]
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/[email protected]
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: ${{ inputs.registry }}
INPUT_REGISTRY_NAMESPACE: ${{ inputs.registry_namespace }}
INPUT_IMAGE_NAME: ${{ inputs.image_name }}
REPO_OWNER: ${{ github.repository_owner }}
uses: actions/github-script@v7
with:
script: |
const inputVersion = process.env.INPUT_VERSION;
const inputPublish = process.env.INPUT_PUBLISH;
const inputRegistry = process.env.INPUT_REGISTRY;
const inputRegistryNamespace = process.env.INPUT_REGISTRY_NAMESPACE;
const inputImageName = process.env.INPUT_IMAGE_NAME;
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();
const imageBranchTag = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim();

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

// 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);

// Determine registry (with auto-detection for temporalio vs forks)
let registry = inputRegistry;
if (!registry) {
if (repoOwner === 'temporalio') {
registry = 'docker.io';
} else {
registry = 'ghcr.io';
}
}

// Determine registry type for authentication
let registryType;
if (registry === 'ghcr.io') {
registryType = 'ghcr';
} else if (registry === 'docker.io') {
registryType = 'dockerhub';
} else {
registryType = 'other';
}
core.setOutput('registry_type', registryType);

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

// Set image name (defaults to 'temporal')
const imageName = inputImageName || 'temporal';
core.setOutput('image_name', imageName);

// For Docker Hub, use empty string as registry (special case)
const imageRepo = registry === 'docker.io' ? '' : registry;
core.setOutput('image_repo', imageRepo);

console.log(`Registry: ${registry}, Type: ${registryType}, Namespace: ${namespace}, Image: ${imageName}`);

- name: Log in to GitHub Container Registry
if: inputs.publish && steps.meta.outputs.registry_type == 'ghcr'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Docker Hub
if: inputs.publish && steps.meta.outputs.registry_type == 'dockerhub'
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 }}
IMAGE_BRANCH_TAG: ${{ steps.meta.outputs.image_branch_tag }}
VERSION: ${{ steps.meta.outputs.version }}
TAG_LATEST: ${{ steps.check_latest_release.outputs.is_latest == 'true' }}
IMAGE_REPO: ${{ steps.meta.outputs.image_repo }}
IMAGE_NAMESPACE: ${{ steps.meta.outputs.image_namespace }}
IMAGE_NAME: ${{ steps.meta.outputs.image_name }}
GITHUB_REPOSITORY: ${{ github.repository }}

- 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 }}
IMAGE_BRANCH_TAG: ${{ steps.meta.outputs.image_branch_tag }}
VERSION: ${{ steps.meta.outputs.version }}
TAG_LATEST: false
IMAGE_REPO: ${{ steps.meta.outputs.image_repo }}
IMAGE_NAMESPACE: ${{ steps.meta.outputs.image_namespace }}
IMAGE_NAME: ${{ steps.meta.outputs.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
60 changes: 13 additions & 47 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,21 @@
name: goreleaser
name: Release

on:
workflow_dispatch:
release:
types:
- published

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: "go.mod"
check-latest: true

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

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

- name: Get git branch
id: branch
run: echo "::set-output name=branch::$(git rev-parse --abbrev-ref HEAD)"
permissions:
contents: write
packages: write

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

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

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0
with:
version: v1.26.2
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 }}
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 }}
1 change: 1 addition & 0 deletions .github/workflows/trigger-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
types: [published]
jobs:
update:
if: github.repository == 'temporalio/cli'
runs-on: ubuntu-latest
defaults:
run:
Expand Down
40 changes: 0 additions & 40 deletions .github/workflows/trigger-publish.yml

This file was deleted.

Loading
Loading