Skip to content

Commit 6b1b6ee

Browse files
kylecarbsclaude
andcommitted
ci: validate the publish version before it reaches the shell
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fdcb9bf commit 6b1b6ee

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

‎.github/workflows/publish.yaml‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ jobs:
3333
steps:
3434
- name: Set version to tag without leading v
3535
run: |
36-
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
36+
# TAG comes from the dispatch input, so only a version may reach GITHUB_ENV and the shell.
37+
if [[ ! "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
38+
echo "::error::The version must look like v1.2.3 or v1.2.3-rc.1."
39+
exit 1
40+
fi
41+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
3742
3843
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
3944
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
@@ -66,7 +71,12 @@ jobs:
6671
steps:
6772
- name: Set version to tag without leading v
6873
run: |
69-
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
74+
# TAG comes from the dispatch input, so only a version may reach GITHUB_ENV and the shell.
75+
if [[ ! "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
76+
echo "::error::The version must look like v1.2.3 or v1.2.3-rc.1."
77+
exit 1
78+
fi
79+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
7080
7181
- name: Generate coder-automations app token
7282
id: app_token
@@ -113,15 +123,15 @@ jobs:
113123
env:
114124
GH_TOKEN: ${{ steps.app_token.outputs.token }}
115125
run: |
116-
git checkout -b update-version-${{ env.VERSION }}
126+
git checkout -b "update-version-$VERSION"
117127
git add .
118-
git commit -m "Update to ${{ env.VERSION }}"
119-
git push -u origin $(git branch --show)
128+
git commit -m "Update to $VERSION"
129+
git push -u origin "$(git branch --show)"
120130
gh pr create \
121131
--repo coder/code-server-aur \
122-
--title "Update to ${{ env.VERSION }}" \
132+
--title "Update to $VERSION" \
123133
--body "PR opened by @$GITHUB_ACTOR" \
124-
--assignee $GITHUB_ACTOR
134+
--assignee "$GITHUB_ACTOR"
125135
126136
docker:
127137
runs-on: ubuntu-latest
@@ -140,7 +150,12 @@ jobs:
140150
steps:
141151
- name: Set version to tag without leading v
142152
run: |
143-
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
153+
# TAG comes from the dispatch input, so only a version may reach GITHUB_ENV and the shell.
154+
if [[ ! "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
155+
echo "::error::The version must look like v1.2.3 or v1.2.3-rc.1."
156+
exit 1
157+
fi
158+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
144159
145160
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
146161
- uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
@@ -189,7 +204,12 @@ jobs:
189204
steps:
190205
- name: Set version to tag without leading v
191206
run: |
192-
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
207+
# TAG comes from the dispatch input, so only a version may reach GITHUB_ENV and the shell.
208+
if [[ ! "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
209+
echo "::error::The version must look like v1.2.3 or v1.2.3-rc.1."
210+
exit 1
211+
fi
212+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
193213
194214
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
195215

0 commit comments

Comments
 (0)