Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 10 additions & 7 deletions .github/tests/test-publish-app-action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -562,21 +562,24 @@ for ref in refs/heads/main refs/pull/7/merge refs/heads/v1.2.3 v1.2.3; do
case_ref "$action_dir" "$ref" 'must run on a release tag' || fail "accepted or misjudged non-tag ref $ref: $(cat "$log")"
done
long_pre="$(printf 'a%.0s' $(seq 1 130))"
long_build="$(printf 'b%.0s' $(seq 1 251))"
for tag in v1.2.3garbage v1.2.3.4 v1.2 v1 1.2.3 V1.2.3 v01.2.3 v1.02.3 v1.2.03 v1.2.3- v1.2.3+ v1.2.3-01 \
v1.2.3-rc..1 v1.2.3-rc.1+ v1.2.3+build..1 v1.2.3_build 'v1.2.3 ' ' v1.2.3' v1.2.3-ünicode; do
long_tag_pre="$(printf 'c%.0s' $(seq 1 251))"
for tag in v1.2.3garbage v1.2.3.4 v1.2 v1 1.2.3 V1.2.3 v01.2.3 v1.02.3 v1.2.03 v1.2.3- v1.2.3-01 \
v1.2.3-rc..1 v1.2.3_build 'v1.2.3 ' ' v1.2.3' v1.2.3-ünicode; do
case_ref "$action_dir" "refs/tags/$tag" 'complete semantic version' || fail "accepted or misjudged tag '$tag': $(cat "$log")"
done
for tag in v9007199254740992.0.0 v1.0.18446744073709551616 v1.2.3-rc.1000000000000000 "v1.2.3+$long_build"; do
for tag in v1.2.3+build.5 v1.2.3-rc.1+build.5 v1.2.3+ v1.2.3-rc.1+ v1.2.3+build..1; do
case_ref "$action_dir" "refs/tags/$tag" 'carries build metadata' || fail "accepted build metadata in tag '$tag': $(cat "$log")"
done
for tag in v9007199254740992.0.0 v1.0.18446744073709551616 v1.2.3-rc.1000000000000000 "v1.2.3-$long_tag_pre"; do
case_ref "$action_dir" "refs/tags/$tag" 'at most 256 characters with numbers of at most 15 digits' ||
fail "accepted an unreadable version $tag: $(cat "$log")"
done
case_ref "$action_dir" "refs/tags/v1.2.3-$long_pre" 'longer than the 128 characters' || fail 'accepted an over-long OCI version'
echo 'ok only a complete v<semver> tag ref is admitted, before any registry contact'
echo 'ok only a complete v<semver> tag ref without build metadata is admitted, before any registry contact'

for entry in "v0.0.0|0.0.0|latest" "v10.20.30|10.20.30|latest" "v1.2.3-rc.1|1.2.3-rc.1|" \
"v1.0.0-alpha.beta.1|1.0.0-alpha.beta.1|" "v1.0.0-x-y-z.--|1.0.0-x-y-z.--|" "v1.2.3+build.5|1.2.3|latest" \
"v1.2.3-rc.1+build.5|1.2.3-rc.1|" "v999999999999999.0.0|999999999999999.0.0|latest"; do
"v1.0.0-alpha.beta.1|1.0.0-alpha.beta.1|" "v1.0.0-x-y-z.--|1.0.0-x-y-z.--|" \
"v999999999999999.0.0|999999999999999.0.0|latest"; do
IFS='|' read -r tag version latest <<<"$entry"
setup_case "$released"
sim_ref="refs/tags/$tag"
Expand Down
4 changes: 2 additions & 2 deletions actions/publish-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ every revision of a shared publisher.

1. **Admits the release, before any registry contact.** It refuses unless:
- the run's ref is `refs/tags/v<semver>` (SemVer 2.0.0; a pre-release is allowed, build
metadata is dropped from the published version, and every number has at most 15 digits);
metadata such as `+build.5` is refused, and every number has at most 15 digits);
- the calling workflow ref is this repository's own workflow file on that exact tag;
- the tagged commit is checked out at the workspace root, without a persisted git credential
(`persist-credentials: false`; the checkout is also the image build context);
Expand Down Expand Up @@ -72,7 +72,7 @@ directory on the way, nor the manifest itself, may be a link. A refused value is

| Name | Description |
|------|-------------|
| `version` | The published version: the tag without its `v` and build metadata |
| `version` | The published version: the tag without its `v` |
| `image-digest` | The signed image digest (empty in `manifests` mode) |
| `manifests-digest` | The signed manifests artifact digest |

Expand Down
2 changes: 1 addition & 1 deletion actions/publish-app/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inputs:

outputs:
version:
description: "The published version: the tag without its `v` and build metadata."
description: "The published version: the tag without its `v`."
value: ${{ steps.admit.outputs.version }}
image-digest:
description: "The signed image digest (empty in manifests mode)."
Expand Down
16 changes: 8 additions & 8 deletions actions/publish-app/admit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ check_inputs() {
fi
}

# The ref must be refs/tags/v<SemVer 2.0.0>. Keep this identical to the tag step of the reusable
# publish workflows: Flux and docker/metadata-action must both be able to read and order it.
# The ref must be refs/tags/v<SemVer 2.0.0> without build metadata: Flux and docker/metadata-action
# must both be able to read and order it. The tag is part of the signing identity, and the
# platform verifies that identity with a grammar that has no build suffix. An OCI tag cannot
# carry `+` either, so v1.2.3+a and v1.2.3+b would both publish as 1.2.3.
check_release_tag() {
local ref="${GITHUB_REF:-}" num pre build semver numbers too_long
local ref="${GITHUB_REF:-}" num pre semver numbers too_long
[[ "$ref" == refs/tags/* ]] || fail 'publish-app must run on a release tag (refs/tags/v<semver>), not a branch or pull request ref'
tag="${ref#refs/tags/}"
num='(0|[1-9][0-9]*)'
pre='(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)'
build='[0-9A-Za-z-]+'
semver="^v${num}\.${num}\.${num}(-${pre}(\.${pre})*)?(\+${build}(\.${build})*)?$"
[[ "$tag" =~ $semver ]] || fail 'the release tag must be a complete semantic version vMAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]'
# An OCI tag cannot carry `+`, and SemVer ignores build metadata when ordering versions.
case "$tag" in *+*) fail "the release tag $tag carries build metadata; tag the release as vMAJOR.MINOR.PATCH[-PRERELEASE] without a +BUILD suffix" ;; esac
semver="^v${num}\.${num}\.${num}(-${pre}(\.${pre})*)?$"
[[ "$tag" =~ $semver ]] || fail 'the release tag must be a complete semantic version vMAJOR.MINOR.PATCH[-PRERELEASE]'
version="${tag#v}"
version="${version%%+*}"
numbers=".${version%%-*}."
case "$version" in *-*) numbers="${numbers}${version#*-}." ;; esac
too_long='\.[0-9]{16,}\.'
Expand Down
Loading