Skip to content

Commit ae13d5b

Browse files
committed
ci(store): fix an empty expression, a silent skip, and an unchecked run id
Three review findings, one of which would have stopped the workflow from running at all. `${{ }}` inside a `run:` block is not a comment. Actions substitutes expressions across the whole block before the shell sees it, and an empty one is a parse error. build.yml has the same text at line 1072 and is fine, because there it sits in a YAML comment that never reaches the expression parser -- the distinction is which side of `run:` it falls on. My local YAML and shell checks could not see this: it is neither. The job-level `if: vars.MSSTORE_PRODUCT_ID != ''` skipped the whole job when unconfigured, and a skipped job is green and silent. build.yml can afford that as one job in an automatic release; this one exists to be triggered by hand, where "nothing happened, no error" is the worst answer. MSSTORE_PRODUCT_ID moves into the configuration check and fails loudly with a Summary line. And an explicitly supplied run_id was trusted as given. Nothing downstream inspects what is inside the artifact, so a transposed digit would submit another commit's package to the Store under this tag. It is now checked to be a build.yml run whose head_sha matches the tag being published -- verified against the real v1.9.5 run first, so the check accepts the run it exists to retry rather than rejecting it. Not taken: "afterwards" -> "afterward". The repo uses "afterwards" throughout (AGENTS.md, build-and-packaging.md, release-and-secrets.md, manual-e2e-checklist.md, website/docs); changing one instance would make it the odd one out.
1 parent 89d58bd commit ae13d5b

1 file changed

Lines changed: 39 additions & 9 deletions

File tree

‎.github/workflows/publish-msstore.yml‎

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ jobs:
4545
submit:
4646
name: Submit ${{ inputs.release_tag }} to the Store
4747
runs-on: windows-latest
48-
# Same gate as build.yml: an RC reaching the Store would go through
49-
# certification and land on every user's machine as an automatic update.
50-
if: ${{ vars.MSSTORE_PRODUCT_ID != '' }}
48+
# No job-level `if` on MSSTORE_PRODUCT_ID, deliberately. build.yml can afford
49+
# to skip: it is one job among many in an automatic release. This one is
50+
# something a person asked for by hand, and a skipped job is green and
51+
# silent — the exact shape that let Homebrew and WinGet report success while
52+
# publishing nothing for eight releases. Missing configuration is checked
53+
# below and fails loudly instead.
5154
steps:
5255
- name: Validate the tag
5356
id: tag
@@ -63,23 +66,28 @@ jobs:
6366
6467
# All-or-nothing, as in build.yml: a half-configured publisher is a
6568
# misnamed secret, and failing loudly beats submitting nothing quietly.
66-
- name: Resolve Store credentials
69+
- name: Resolve Store configuration
6770
id: store
6871
shell: bash
6972
env:
73+
MSSTORE_PRODUCT_ID: ${{ vars.MSSTORE_PRODUCT_ID }}
7074
AZURE_AD_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }}
7175
AZURE_AD_APPLICATION_CLIENT_ID: ${{ secrets.AZURE_AD_APPLICATION_CLIENT_ID }}
7276
AZURE_AD_APPLICATION_SECRET: ${{ secrets.AZURE_AD_APPLICATION_SECRET }}
7377
SELLER_ID: ${{ secrets.SELLER_ID }}
7478
run: |
75-
required=(AZURE_AD_TENANT_ID AZURE_AD_APPLICATION_CLIENT_ID
76-
AZURE_AD_APPLICATION_SECRET SELLER_ID)
79+
# MSSTORE_PRODUCT_ID is in here rather than in a job-level `if` so an
80+
# unconfigured repository gets an error and a Summary line, not a
81+
# silent skip on a run somebody triggered on purpose.
82+
required=(MSSTORE_PRODUCT_ID AZURE_AD_TENANT_ID
83+
AZURE_AD_APPLICATION_CLIENT_ID AZURE_AD_APPLICATION_SECRET
84+
SELLER_ID)
7785
missing=()
7886
for name in "${required[@]}"; do
7987
[[ -n "${!name}" ]] || missing+=("$name")
8088
done
8189
if [[ ${#missing[@]} -ne 0 ]]; then
82-
echo "::error::Store credentials incomplete; missing: ${missing[*]}"
90+
echo "::error::Store configuration incomplete; missing: ${missing[*]}"
8391
exit 1
8492
fi
8593
@@ -104,7 +112,28 @@ jobs:
104112
RUN_ID: ${{ inputs.run_id }}
105113
run: |
106114
if [[ -n "$RUN_ID" ]]; then
107-
echo "Using the run id given: $RUN_ID"
115+
# A hand-typed run id is the one input that can quietly ship the
116+
# wrong bytes: nothing downstream re-checks what is inside the
117+
# artifact, so a transposed digit could submit another commit's
118+
# package to the Store under this tag. Confirm it is a build.yml run
119+
# and that it was built from the tag being published.
120+
INFO="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${RUN_ID}" \
121+
--jq '{path: .path, sha: .head_sha}' 2>/dev/null)" || {
122+
echo "::error::Run ${RUN_ID} not found in ${GITHUB_REPOSITORY}."
123+
exit 1
124+
}
125+
RUN_PATH="$(jq -r .path <<<"$INFO")"
126+
RUN_SHA="$(jq -r .sha <<<"$INFO")"
127+
TAG_SHA="$(git rev-parse HEAD)"
128+
if [[ "$RUN_PATH" != ".github/workflows/build.yml" ]]; then
129+
echo "::error::Run ${RUN_ID} is ${RUN_PATH}, not build.yml."
130+
exit 1
131+
fi
132+
if [[ "$RUN_SHA" != "$TAG_SHA" ]]; then
133+
echo "::error::Run ${RUN_ID} built ${RUN_SHA}, but ${TAG} is ${TAG_SHA}."
134+
exit 1
135+
fi
136+
echo "Using run ${RUN_ID}: build.yml at ${RUN_SHA}"
108137
else
109138
# Deliberately not filtered on conclusion: the run this is most
110139
# likely to be retrying is the one whose Store step failed, so
@@ -142,7 +171,8 @@ jobs:
142171
CLIENT_SECRET: ${{ secrets.AZURE_AD_APPLICATION_SECRET }}
143172
DRY_RUN: ${{ inputs.dry_run }}
144173
run: |
145-
# Through env rather than `${{ }}` expanded straight into shell source.
174+
# Secrets arrive through env, not through expression interpolation
175+
# expanded straight into shell source.
146176
msstore reconfigure `
147177
--tenantId $env:TENANT_ID `
148178
--sellerId $env:SELLER_ID `

0 commit comments

Comments
 (0)