Skip to content

Commit 9a2bc50

Browse files
authored
Fix checkout-free publish repository context (#1796)
1 parent 2d8d1b9 commit 9a2bc50

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/dispatcher-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ jobs:
134134
id-token: write
135135
attestations: write
136136
artifact-metadata: write
137+
env:
138+
GH_REPO: ${{ github.repository }}
137139
steps:
138140
- name: Download packaged dispatcher assets
139141
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093

.github/workflows/native-cli-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ jobs:
144144
id-token: write
145145
attestations: write
146146
artifact-metadata: write
147+
env:
148+
GH_REPO: ${{ github.repository }}
147149
steps:
148150
- name: Download packaged release assets
149151
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093

scripts/test-dispatcher-publish-workflow.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ test_publish_validates_metadata_without_checking_out_source() {
122122
fi
123123
}
124124

125+
test_checkout_free_publish_has_explicit_repository_context() {
126+
if ! publish_section | grep -F ' GH_REPO: ${{ github.repository }}' >/dev/null 2>&1; then
127+
echo "Checkout-free publish job must define GH_REPO for gh release commands." >&2
128+
exit 1
129+
fi
130+
}
131+
125132
test_dispatcher_assets_are_attested_after_the_manifest_is_verified() {
126133
assert_contains " - name: Verify release asset manifest"
127134
assert_contains " - name: Attest dispatcher release assets"
@@ -203,6 +210,7 @@ test_dispatcher_release_target_and_prerelease_state_remain_verified() {
203210
test_build_and_publish_jobs_have_separate_trust_boundaries
204211
test_unprivileged_build_uses_only_the_approved_event_commit
205212
test_publish_validates_metadata_without_checking_out_source
213+
test_checkout_free_publish_has_explicit_repository_context
206214
test_dispatcher_assets_are_attested_after_the_manifest_is_verified
207215
test_dispatcher_verifies_tagged_installers_after_draft_creation
208216
test_publish_rejects_manifest_and_existing_tag_mismatches

scripts/test-native-cli-publish-workflow.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ test_publish_validates_metadata_without_checking_out_source() {
122122
fi
123123
}
124124

125+
test_checkout_free_publish_has_explicit_repository_context() {
126+
if ! publish_section | grep -F ' GH_REPO: ${{ github.repository }}' >/dev/null 2>&1; then
127+
echo "Checkout-free publish job must define GH_REPO for gh release commands." >&2
128+
exit 1
129+
fi
130+
}
131+
125132
test_assets_are_attested_after_the_manifest_is_verified() {
126133
assert_contains " - name: Verify release asset manifest"
127134
assert_contains " - name: Attest native CLI release assets"
@@ -192,6 +199,7 @@ test_post_publish_automation_remains_outside_the_privileged_job() {
192199
test_build_and_publish_jobs_have_separate_trust_boundaries
193200
test_unprivileged_build_uses_only_the_approved_event_commit
194201
test_publish_validates_metadata_without_checking_out_source
202+
test_checkout_free_publish_has_explicit_repository_context
195203
test_assets_are_attested_after_the_manifest_is_verified
196204
test_publish_rejects_manifest_and_existing_tag_mismatches
197205
test_draft_creation_accepts_only_the_known_missing_tag_responses

0 commit comments

Comments
 (0)