Skip to content

Commit 116c1bc

Browse files
ci: Force publish artifacts to be from a tag when triggered by dispatch [backport] (#5680)
## Backport of #5673 This PR backports #5673 to release/v1.14. ### Original PR Author @kgeckhart ### Description ### Brief description of Pull Request Ensure the dispatch of the artifacts job will be from a tag. Previously this was not required which could accidentally cause artifacts to be generated from main. This also adds a dry run mode which prints the ref and exits. --- *This backport was created automatically.* Co-authored-by: Kyle Eckhart <kgeckhart@users.noreply.github.com>
1 parent 8565c63 commit 116c1bc

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

.github/workflows/publish-alloy-windows.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
required: false
1919
type: string
2020
default: ""
21+
ref:
22+
required: false
23+
type: string
24+
default: ""
2125

2226
permissions:
2327
contents: read
@@ -41,6 +45,7 @@ jobs:
4145
- name: Checkout code
4246
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4347
with:
48+
ref: ${{ inputs.ref }}
4449
persist-credentials: false
4550

4651
- name: Tag dev

.github/workflows/release-publish-alloy-artifacts.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,49 @@ on:
55
- 'v*'
66
workflow_dispatch:
77
inputs:
8-
tag:
9-
description: 'Release tag to publish artifacts for (e.g., v1.14.0-rc.0)'
10-
required: true
11-
type: string
8+
dry_run:
9+
# When dry_run is true, the validate job will intentionally fail and all downstream jobs will be skipped.
10+
description: 'Dry run (do not publish any artifacts)'
11+
type: boolean
12+
default: true
1213
env:
13-
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
14+
RELEASE_TAG: ${{ github.ref_name }}
1415

1516
permissions:
1617
contents: read
1718

1819
jobs:
20+
validate:
21+
name: Validate ref is a tag
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check ref type
25+
env:
26+
REF_TYPE: ${{ github.ref_type }}
27+
REF_NAME: ${{ github.ref_name }}
28+
DRY_RUN: ${{ inputs.dry_run }}
29+
run: |
30+
if [[ "$REF_TYPE" != "tag" ]]; then
31+
echo "::error::This workflow must be run from a tag, not a branch. Change the ref to a release tag (e.g., v1.14.0)."
32+
exit 1
33+
fi
34+
if [[ "$REF_NAME" != v* ]]; then
35+
echo "::error::Tag must start with 'v' (e.g., v1.14.0). Got: $REF_NAME"
36+
exit 1
37+
fi
38+
if [[ "$DRY_RUN" == "true" ]]; then
39+
echo "Dry run enabled for $REF_NAME. The following would run:"
40+
echo " - Publish Linux container images"
41+
echo " - Publish Windows container image"
42+
echo " - Build and sign Windows executables and installer"
43+
echo " - Upload release artifacts to GitHub"
44+
echo " - Submit WinGet manifest"
45+
echo "::error::Set dry_run to false to publish."
46+
exit 1
47+
fi
48+
1949
publish_linux_container:
50+
needs: validate
2051
uses: ./.github/workflows/publish-alloy-linux.yml
2152
permissions:
2253
contents: read
@@ -25,6 +56,7 @@ jobs:
2556
img-name: alloy
2657

2758
publish_linux_boringcrypto_container:
59+
needs: validate
2860
uses: ./.github/workflows/publish-alloy-linux.yml
2961
permissions:
3062
contents: read
@@ -33,12 +65,14 @@ jobs:
3365
img-name: alloy-boringcrypto
3466

3567
publish_windows_container:
68+
needs: validate
3669
uses: ./.github/workflows/publish-alloy-windows.yml
3770
permissions:
3871
contents: read
3972
id-token: write
4073
with:
4174
img-name: alloy
75+
ref: ${{ github.ref_name }}
4276

4377
build_alloy:
4478
name: Build Alloy
@@ -285,4 +319,4 @@ jobs:
285319
contents: read
286320
id-token: write
287321
with:
288-
release-tag: ${{ inputs.tag || github.event.release.tag_name }}
322+
release-tag: ${{ github.ref_name }}

0 commit comments

Comments
 (0)