Skip to content

fix(winget): use release PR URL for deployments #840

fix(winget): use release PR URL for deployments

fix(winget): use release PR URL for deployments #840

Workflow file for this run

---
# This workflow is intended to work with all our organization Docker projects. A readme named `DOCKER_README.md`
# will be used to update the description on Docker hub.
# Repositories can define their build graph in `docker-bake.hcl`. When present,
# the `default` group is built, and targets in an optional `artifacts` group
# export files from `/artifacts`. A target's `dev.lizardbyte.image.variant` label
# supplies its image tag suffix and job name. Without that label, the resolved
# Dockerfile name is used. Each platform is dispatched to an allowlisted native
# runner.
# Repositories without a Bake definition emit a warning and skip Docker builds.
# `CI_PR` is set for Bake files that use a reduced pull-request platform list.
# Targets with `no-cache = true` do not import or export the GitHub Actions cache.
# See https://docs.docker.com/build/bake/ for the standard file format.
name: Docker (called)
permissions: {}
on:
pull_request:
workflow_call:
inputs:
docker_hub_username:
description: 'Docker Hub username to use for the workflow.'
required: false
type: string
gh_bot_name:
description: 'GitHub bot name to use for the workflow.'
required: false
type: string
maximize_build_space:
description: 'Maximize build space.'
required: false
type: boolean
default: false
publish_release:
required: true
type: string
release_commit:
required: true
type: string
release_tag:
required: true
type: string
release_version:
required: true
type: string
secrets:
DOCKER_HUB_PASSWORD:
description: 'Docker Hub password to use for the workflow.'
required: false
DOCKER_HUB_ACCESS_TOKEN:
description: 'Docker Hub access token to use for the workflow.'
required: false
GH_BOT_TOKEN:
description: 'GitHub bot token to use for the workflow.'
required: false
GH_TOKEN:
description: 'GitHub token to use for the workflow.'
required: false
jobs:
check_dockerfiles:
name: Plan Docker builds
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Resolve Docker builds
id: find
env:
CI_PR: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
if [[ ! -f docker-bake.hcl ]]; then
echo "::warning::No docker-bake.hcl file was found; skipping Docker builds."
echo "has_bake=false" >> "${GITHUB_OUTPUT}"
exit 0
fi
echo "has_bake=true" >> "${GITHUB_OUTPUT}"
definition_file=$(mktemp)
CI_PR="${CI_PR}" docker buildx bake \
--file docker-bake.hcl \
--print \
default > "${definition_file}"
artifacts_file=$(mktemp)
if CI_PR="${CI_PR}" docker buildx bake \
--file docker-bake.hcl \
--print \
artifacts > "${artifacts_file}" 2>/dev/null; then
artifact_targets=$(jq -c '.group.artifacts.targets // []' "${artifacts_file}")
else
artifact_targets='[]'
fi
matrix_data=$(jq -c --argjson artifact_targets "${artifact_targets}" '
def dockerfile_name($dockerfile):
($dockerfile | split("/") | last) as $filename
| if ($filename | ascii_downcase) == "dockerfile" then
""
elif ($filename | ascii_downcase | endswith(".dockerfile")) then
$filename[0:-11]
else
error("Dockerfile names must be Dockerfile or end in .dockerfile: " + $dockerfile)
end;
def image_name($definition; $target; $dockerfile):
(
$definition.target[$target].labels["dev.lizardbyte.image.variant"]
// dockerfile_name($dockerfile)
) as $name
| if ($name | test("^[A-Za-z0-9_.-]*$")) then
$name
else
error("Invalid image variant for Bake target " + $target + ": " + $name)
end;
def runner($platform):
if $platform == "linux/amd64" then
"ubuntu-24.04"
elif $platform == "linux/arm64" or ($platform | startswith("linux/arm64/")) then
"ubuntu-24.04-arm"
else
error("No native runner is configured for Bake platform " + $platform)
end;
. as $definition
| [
$definition.group.default.targets[] as $target
| ($definition.target[$target].dockerfile // "Dockerfile") as $dockerfile
| image_name($definition; $target; $dockerfile) as $name
| ($definition.target[$target].platforms // ["linux/amd64"])[] as $platform
| {
target: $target,
platform: $platform,
platform_pair: (
$platform
| gsub("[^A-Za-z0-9]+"; "-")
| sub("^-"; "")
| sub("-$"; "")
),
runner: runner($platform),
artifacts: (($artifact_targets | index($target)) != null),
cache: (($definition.target[$target]["no-cache"] // false) == false),
name: $name,
tag: (if $name == "" then "" else "-" + $name end)
}
] as $builds
| [
$definition.group.default.targets[] as $target
| ($definition.target[$target].dockerfile // "Dockerfile") as $dockerfile
| image_name($definition; $target; $dockerfile) as $name
| {
target: $target,
platform_count: (($definition.target[$target].platforms // ["linux/amd64"]) | length),
name: $name,
tag: (if $name == "" then "" else "-" + $name end)
}
] as $targets
| {
builds: {include: $builds},
targets: {include: $targets}
}
' "${definition_file}")
echo "Bake build matrix:"
jq '.builds' <<< "${matrix_data}"
echo "bake_build_matrix=$(jq -c '.builds' <<< "${matrix_data}")" >> "${GITHUB_OUTPUT}"
echo "bake_target_matrix=$(jq -c '.targets' <<< "${matrix_data}")" >> "${GITHUB_OUTPUT}"
- name: Set image name
id: additional_outputs
if: steps.find.outputs.has_bake == 'true'
run: |
# set outputs for later jobs
REPOSITORY="${{ github.repository }}"
BASE_TAG=$(echo ${REPOSITORY} | tr '[:upper:]' '[:lower:]')
echo "base_tag=${BASE_TAG}" >> "${GITHUB_OUTPUT}"
outputs:
bake_build_matrix: ${{ steps.find.outputs.bake_build_matrix }}
bake_target_matrix: ${{ steps.find.outputs.bake_target_matrix }}
base_tag: ${{ steps.additional_outputs.outputs.base_tag }}
has_bake: ${{ steps.find.outputs.has_bake }}
docker_bake:
name: ${{ matrix.name && format('{0} ({1})', matrix.name, matrix.platform) || matrix.platform }}
if: needs.check_dockerfiles.outputs.has_bake == 'true'
needs:
- check_dockerfiles
permissions:
contents: read
packages: write
runs-on: ${{ matrix.runner }}
environment:
name: >-
${{
inputs.publish_release == 'true' &&
format('docker{0}', matrix.tag) ||
null
}}
url: >-
${{
inputs.publish_release == 'true' &&
format('https://hub.docker.com/r/{0}/tags?name={1}',
needs.check_dockerfiles.outputs.base_tag, matrix.tag) ||
null
}}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.check_dockerfiles.outputs.bake_build_matrix) }}
steps:
- name: More space
if: inputs.maximize_build_space
uses: LizardByte/actions/actions/more_space@28374bf43cc8b6ee88b9b8a3419b2ac7a6573906 # v2026.928.123224
with:
analyze-space-savings: true
clean-all: true
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- name: Prepare Bake overrides
id: prepare
env:
BRANCH: ${{ github.ref }}
COMMIT: ${{ inputs.release_commit }}
GH_EVENT_REPOSITORY_CLONE_URL: ${{ github.event.repository.clone_url }}
PUBLISH_RELEASE: ${{ inputs.publish_release }}
RELEASE_VERSION: ${{ inputs.release_version }}
USE_CACHE: ${{ matrix.cache }}
shell: bash
run: |
branch="${BRANCH:-master}"
commit="${COMMIT:-${GITHUB_SHA}}"
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
branch="${GITHUB_REF_NAME}"
fi
target="${{ matrix.target }}"
cache_scope="docker-${target}-${{ matrix.platform_pair }}"
base_tag="${{ needs.check_dockerfiles.outputs.base_tag }}"
{
echo "set<<EOF"
echo "${target}.platform=${{ matrix.platform }}"
echo "${target}.args.BRANCH=${branch}"
echo "${target}.args.BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
echo "${target}.args.BUILD_VERSION=${RELEASE_VERSION}"
echo "${target}.args.COMMIT=${commit}"
echo "${target}.args.CLONE_URL=${GH_EVENT_REPOSITORY_CLONE_URL}"
echo "${target}.args.RELEASE=${PUBLISH_RELEASE}"
if [[ "${USE_CACHE}" == "true" ]]; then
echo "${target}.cache-from=type=gha,scope=${cache_scope}"
echo "${target}.cache-to=type=gha,mode=max,scope=${cache_scope}"
fi
if [[ "${PUBLISH_RELEASE}" == "true" ]]; then
image_output="${target}.output=type=image,\"name=${base_tag},ghcr.io/${base_tag}\""
image_output+=",push-by-digest=true,name-canonical=true,push=true"
echo "${image_output}"
if [[ "${{ matrix.artifacts }}" == "true" ]]; then
echo "${target}.output+=type=local,dest=image"
fi
elif [[ "${{ matrix.artifacts }}" == "true" ]]; then
echo "${target}.output=type=local,dest=image"
else
echo "${target}.output=type=cacheonly"
fi
echo "EOF"
} >> "${GITHUB_OUTPUT}"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to Docker Hub
if: inputs.publish_release == 'true' # PRs do not have access to secrets
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ inputs.docker_hub_username }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Log in to the Container registry
if: inputs.publish_release == 'true' # PRs do not have access to secrets
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ inputs.gh_bot_name }}
password: ${{ secrets.GH_BOT_TOKEN }}
- name: Add problem matcher
shell: bash
run: |
if [ -f "${{ github.workspace }}/.github/matchers/docker.json" ]; then
echo "::add-matcher::${{ github.workspace }}/.github/matchers/docker.json"
fi
- name: Build and push by digest
id: build
uses: docker/bake-action@018cb6412ab401ebaa809aa5f85966b74628600f # v7.4.0
with:
builder: ${{ steps.buildx.outputs.name }}
files: ./docker-bake.hcl
source: .
targets: ${{ matrix.target }}
set: ${{ steps.prepare.outputs.set }}
- name: Arrange Artifacts
if: matrix.artifacts
shell: bash
run: |
mkdir -p artifacts
echo "::group::Moving artifacts"
find \
./image \
-mindepth 1 \
-maxdepth 3 \
-type d \
-name 'artifacts' \
-exec bash -c 'cp -rv "$1"/* ./artifacts/' _ {} \;
echo "::endgroup::"
echo "::group::Artifacts"
ls -la ./artifacts/
echo "::endgroup::"
- name: Upload Artifacts
if: matrix.artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: build-Docker${{ matrix.tag }}-${{ matrix.platform_pair }}
path: artifacts/
if-no-files-found: error
- name: Export digest
if: inputs.publish_release == 'true'
env:
BUILD_METADATA: ${{ steps.build.outputs.metadata }}
shell: bash
run: |
digest=$(jq -r --arg target "${{ matrix.target }}" \
'.[$target]["containerimage.digest"] // empty' <<< "${BUILD_METADATA}")
if [[ ! "${digest}" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "Unable to find a valid image digest for ${{ matrix.target }}" >&2
exit 1
fi
mkdir -p digests
touch "digests/${digest#sha256:}"
- name: Upload digest
if: inputs.publish_release == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: docker-digests-${{ matrix.target }}-${{ matrix.platform_pair }}
path: digests/*
if-no-files-found: error
retention-days: 1
docker_bake_manifest:
name: Manifest
if: inputs.publish_release == 'true'
needs:
- check_dockerfiles
- docker_bake
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.check_dockerfiles.outputs.bake_target_matrix) }}
steps:
- name: Download digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: docker-digests-${{ matrix.target }}-*
path: digests
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to Docker Hub
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ inputs.docker_hub_username }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ inputs.gh_bot_name }}
password: ${{ secrets.GH_BOT_TOKEN }}
- name: Create manifests
env:
BASE_TAG: ${{ needs.check_dockerfiles.outputs.base_tag }}
COMMIT: ${{ inputs.release_commit }}
EXPECTED_PLATFORMS: ${{ matrix.platform_count }}
NEW_TAG: ${{ inputs.release_tag }}
TAG_SUFFIX: ${{ matrix.tag }}
shell: bash
run: |
mapfile -t digests < <(find digests -maxdepth 1 -type f -printf '%f\n' | sort)
if [[ "${#digests[@]}" -ne "${EXPECTED_PLATFORMS}" ]]; then
echo "Expected ${EXPECTED_PLATFORMS} digests, found ${#digests[@]}" >&2
exit 1
fi
commit="${COMMIT:-${GITHUB_SHA}}"
tags=("${commit:0:7}${TAG_SUFFIX}")
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
tags+=("latest${TAG_SUFFIX}" "master${TAG_SUFFIX}")
else
tags+=("test${TAG_SUFFIX}")
fi
if [[ -n "${NEW_TAG}" ]]; then
tags+=("${NEW_TAG}${TAG_SUFFIX}")
fi
docker_sources=()
ghcr_sources=()
for digest in "${digests[@]}"; do
docker_sources+=("${BASE_TAG}@sha256:${digest}")
ghcr_sources+=("ghcr.io/${BASE_TAG}@sha256:${digest}")
done
docker_tags=()
ghcr_tags=()
for tag in "${tags[@]}"; do
docker_tags+=(--tag "${BASE_TAG}:${tag}")
ghcr_tags+=(--tag "ghcr.io/${BASE_TAG}:${tag}")
done
docker buildx imagetools create "${docker_tags[@]}" "${docker_sources[@]}"
docker buildx imagetools create "${ghcr_tags[@]}" "${ghcr_sources[@]}"
docker_complete:
name: Conclusion
if: >-
always() &&
needs.check_dockerfiles.outputs.has_bake == 'true'
needs:
- check_dockerfiles
- docker_bake
- docker_bake_manifest
permissions: {}
runs-on: ubuntu-latest
steps:
- name: Check Docker jobs
env:
BAKE_RESULT: ${{ needs.docker_bake.result }}
MANIFEST_RESULT: ${{ needs.docker_bake_manifest.result }}
shell: bash
run: |
for result in "${BAKE_RESULT}" "${MANIFEST_RESULT}"; do
if [[ "${result}" == "failure" || "${result}" == "cancelled" ]]; then
exit 1
fi
done
release:
name: Release
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs:
- check_dockerfiles
- docker_complete
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: |
DOCKER_README.md
sparse-checkout-cone-mode: false
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0
with:
username: ${{ inputs.docker_hub_username }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }} # token is not currently supported
repository: ${{ needs.check_dockerfiles.outputs.base_tag }}
short-description: ${{ github.event.repository.description }}
readme-filepath: ./DOCKER_README.md