mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
workflows/docker: fix publishing Docker images (again)
Follow-up to #19480. Tags were being serialised in the wrong format. This fixes that.
This commit is contained in:
parent
b10fe2a699
commit
cd33a3e032
26
.github/workflows/docker.yml
vendored
26
.github/workflows/docker.yml
vendored
@ -29,6 +29,7 @@ jobs:
|
|||||||
tags: ${{ steps.attributes.outputs.tags }}
|
tags: ${{ steps.attributes.outputs.tags }}
|
||||||
labels: ${{ steps.attributes.outputs.labels }}
|
labels: ${{ steps.attributes.outputs.labels }}
|
||||||
push: ${{ steps.attributes.outputs.push }}
|
push: ${{ steps.attributes.outputs.push }}
|
||||||
|
merge: ${{ steps.attributes.outputs.merge }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
@ -62,6 +63,7 @@ jobs:
|
|||||||
typeset -A tag_hash
|
typeset -A tag_hash
|
||||||
typeset -A push_hash
|
typeset -A push_hash
|
||||||
matrix=()
|
matrix=()
|
||||||
|
merge=false
|
||||||
while IFS=$'\n' read -r version; do
|
while IFS=$'\n' read -r version; do
|
||||||
tags=()
|
tags=()
|
||||||
if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
|
if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
|
||||||
@ -91,8 +93,12 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${#tags[@]}" -ne 0 ]]; then
|
if [[ "${#tags[@]}" -ne 0 ]]; then
|
||||||
tag_hash["${version}"]="${tags[*]}"
|
tags_as_json_array="$(
|
||||||
|
jq --null-input --compact-output '$ARGS.positional' --args "${tags[@]}"
|
||||||
|
)"
|
||||||
|
tag_hash["${version}"]="${tags_as_json_array}"
|
||||||
push_hash["${version}"]=true
|
push_hash["${version}"]=true
|
||||||
|
merge=true
|
||||||
matrix+=("${version}")
|
matrix+=("${version}")
|
||||||
else
|
else
|
||||||
push_hash["${version}"]=false
|
push_hash["${version}"]=false
|
||||||
@ -101,6 +107,7 @@ jobs:
|
|||||||
|
|
||||||
# Transform the `matrix` variable into a JSON array.
|
# Transform the `matrix` variable into a JSON array.
|
||||||
echo "matrix=$(jq --null-input --compact-output '$ARGS.positional' --args "${matrix[@]}")" >>"${GITHUB_OUTPUT}"
|
echo "matrix=$(jq --null-input --compact-output '$ARGS.positional' --args "${matrix[@]}")" >>"${GITHUB_OUTPUT}"
|
||||||
|
echo "merge=${merge}" >>"${GITHUB_OUTPUT}"
|
||||||
|
|
||||||
{
|
{
|
||||||
DELIMITER="END_TAGS_$(uuidgen)"
|
DELIMITER="END_TAGS_$(uuidgen)"
|
||||||
@ -109,7 +116,7 @@ jobs:
|
|||||||
printf '{'
|
printf '{'
|
||||||
for version in "${!tag_hash[@]}"; do
|
for version in "${!tag_hash[@]}"; do
|
||||||
[[ -n "${has_previous:-}" ]] && printf ','
|
[[ -n "${has_previous:-}" ]] && printf ','
|
||||||
printf '"%s": "%s"' "${version}" "${tag_hash[$version]}"
|
printf '"%s": %s' "${version}" "${tag_hash[$version]}"
|
||||||
has_previous=1
|
has_previous=1
|
||||||
done
|
done
|
||||||
echo '}'
|
echo '}'
|
||||||
@ -123,7 +130,7 @@ jobs:
|
|||||||
printf '{'
|
printf '{'
|
||||||
for version in "${!push_hash[@]}"; do
|
for version in "${!push_hash[@]}"; do
|
||||||
[[ -n "${has_previous:-}" ]] && printf ','
|
[[ -n "${has_previous:-}" ]] && printf ','
|
||||||
printf '"%s": "%s"' "${version}" "${push_hash[$version]}"
|
printf '"%s": %s' "${version}" "${push_hash[$version]}"
|
||||||
has_previous=1
|
has_previous=1
|
||||||
done
|
done
|
||||||
echo '}'
|
echo '}'
|
||||||
@ -234,7 +241,7 @@ jobs:
|
|||||||
|
|
||||||
merge:
|
merge:
|
||||||
needs: [generate-tags, build]
|
needs: [generate-tags, build]
|
||||||
if: github.repository_owner == 'Homebrew'
|
if: github.repository_owner == 'Homebrew' && fromJSON(needs.generate-tags.outputs.merge)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -266,22 +273,17 @@ jobs:
|
|||||||
username: BrewTestBot
|
username: BrewTestBot
|
||||||
password: ${{ secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN }}
|
password: ${{ secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN }}
|
||||||
|
|
||||||
- name: Export TAGS and VERSION to environment
|
- name: Merge and push Docker image
|
||||||
env:
|
env:
|
||||||
TAGS: ${{ needs.generate-tags.outputs.tags }}
|
TAGS: ${{ needs.generate-tags.outputs.tags }}
|
||||||
VERSION: ${{ matrix.version }}
|
VERSION: ${{ matrix.version }}
|
||||||
run: |
|
run: |
|
||||||
filter="$(printf '.["%s"]' "${VERSION}")"
|
filter="$(printf '.["%s"].[]' "${VERSION}")"
|
||||||
echo "TAGS=$(jq --raw-output "${filter}" <<<"${TAGS}")" >>"${GITHUB_ENV}"
|
|
||||||
echo "VERSION=${VERSION}" >>"${GITHUB_ENV}"
|
|
||||||
|
|
||||||
- name: Merge and push Docker image
|
|
||||||
run: |
|
|
||||||
tag_args=()
|
tag_args=()
|
||||||
while IFS=$'\n' read -r tag; do
|
while IFS=$'\n' read -r tag; do
|
||||||
[[ -n "${tag}" ]] || continue
|
[[ -n "${tag}" ]] || continue
|
||||||
tag_args+=("--tag=${tag}")
|
tag_args+=("--tag=${tag}")
|
||||||
done <<<"${TAGS}"
|
done <<<"$(jq --raw-output "${filter}" <<<"${TAGS}")"
|
||||||
|
|
||||||
image_args=("ghcr.io/homebrew/ubuntu${VERSION}@sha256:$(<"${RUNNER_TEMP}/digests/${VERSION}-x86_64")")
|
image_args=("ghcr.io/homebrew/ubuntu${VERSION}@sha256:$(<"${RUNNER_TEMP}/digests/${VERSION}-x86_64")")
|
||||||
if [[ "${VERSION}" != 18.04 ]]; then
|
if [[ "${VERSION}" != 18.04 ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user