Decide "is this a tag" from the ref the forge actually sends

e1ac5f6 · Gabriel Morell · 2026-09-16 19:38

3 files +21 -12
Message
{commit_body(@commit)}

Files changed

modified .forgejo/workflows/publish.yml
+21 −12
@@ -120,20 +120,29 @@ jobs:
120 120 # token is reported by length, never by value.
121 121 : "${REGISTRY_NAME:?registry name is empty}"
122 122 : "${CARGO_HOME:?cargo home is unset}"
123 − echo "registry=$REGISTRY_NAME ref_type=${GITHUB_REF_TYPE:-<unset>} ref=${GITHUB_REF_NAME:-<unset>}"
123 + echo "registry=$REGISTRY_NAME ref=${GITHUB_REF:-<unset>}"
124 124 token=${CARGO_REGISTRIES_NEIAM_PORTAL_TOKEN:-}
125 125 echo "token: ${#token} chars"
126 126 echo "config: $CARGO_HOME/config.toml"
127 127 grep -A 1 "registries" "$CARGO_HOME/config.toml" || echo " (no registry stanza!)"
128 128
129 − if [ "${GITHUB_REF_TYPE:-branch}" = "tag" ]; then
130 − cargo publish --registry "$REGISTRY_NAME"
131 − echo
132 − echo "Published. Consumers add:"
133 − echo " [registries.$REGISTRY_NAME]"
134 − echo " index = \"sparse+$FORGE_URL/pkg/cargo/${{ github.repository }}/\""
135 − else
136 − # --dry-run still packages and verify-builds; it just does not
137 − # upload. That is the whole value of running this on master.
138 − cargo publish --registry "$REGISTRY_NAME" --dry-run
139 − fi
129 + # Off GITHUB_REF, not GITHUB_REF_TYPE: this forge hands the runner
130 + # `ref`, `sha` and `repository` and no ref_type at all
131 + # (runner_controller.ex), so `${GITHUB_REF_TYPE:-branch}` read
132 + # "branch" on a tag push and run #7 quietly took the dry run —
133 + # green, and publishing nothing. A ref that starts with refs/tags/
134 + # is a tag; there is nothing to be unset about.
135 + case "${GITHUB_REF:-}" in
136 + refs/tags/*)
137 + cargo publish --registry "$REGISTRY_NAME"
138 + echo
139 + echo "Published. Consumers add:"
140 + echo " [registries.$REGISTRY_NAME]"
141 + echo " index = \"sparse+$FORGE_URL/pkg/cargo/${{ github.repository }}/\""
142 + ;;
143 + *)
144 + # --dry-run still packages and verify-builds; it just does not
145 + # upload. That is the whole value of running this on master.
146 + cargo publish --registry "$REGISTRY_NAME" --dry-run
147 + ;;
148 + esac

Parents: b46a4bd