Skip to content

Commit 57e36ec

Browse files
Copilotfelickz
andauthored
Updating auto updater for version labeling (#208)
* Label auto-update Chore PRs with the version number Co-authored-by: felickz <1760475+felickz@users.noreply.github.com> * Skip empty label values in label creation loop Co-authored-by: felickz <1760475+felickz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
1 parent 81c6bb8 commit 57e36ec

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

‎.github/workflows/update-codeql-version.yml‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,36 @@ jobs:
187187
app-id: ${{ secrets.SECLABS_APP_ID }}
188188
private-key: ${{ secrets.SECLABS_APP_KEY }}
189189

190+
- name: Compute PR labels
191+
id: pr_labels
192+
run: |
193+
set -euo pipefail
194+
{
195+
echo "list<<EOF"
196+
echo "version"
197+
echo "codeql-cli-v${{ steps.version.outputs.version }}"
198+
if [[ -n "${{ steps.release_bump.outputs.bump }}" ]]; then
199+
echo "release-v${{ steps.release_version.outputs.version }}"
200+
fi
201+
echo "EOF"
202+
} >> "$GITHUB_OUTPUT"
203+
204+
- name: Ensure version labels exist
205+
env:
206+
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
207+
run: |
208+
set -euo pipefail
209+
# `version` already exists in the repo; only the version-specific
210+
# labels below need to be created on demand. `gh label create --force`
211+
# is idempotent, so re-running this workflow for the same version is
212+
# safe.
213+
while IFS= read -r LABEL; do
214+
if [[ -z "$LABEL" || "$LABEL" == "version" ]]; then
215+
continue
216+
fi
217+
gh label create "$LABEL" --color ededed --force
218+
done <<< "${{ steps.pr_labels.outputs.list }}"
219+
190220
- name: Build PR title and body
191221
id: pr_meta
192222
run: |
@@ -260,5 +290,5 @@ jobs:
260290
commit-message: ${{ steps.pr_meta.outputs.title }}
261291
body-path: "${{ runner.temp }}/pr-body.md"
262292
branch: "chore/update-codeql-cli-${{ steps.version.outputs.version }}"
263-
labels: "version"
293+
labels: ${{ steps.pr_labels.outputs.list }}
264294
delete-branch: true

‎.github/workflows/update-release.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ jobs:
5959
ghcr.io/42bytelabs/patch-release-me@sha256:d9d7abe7051855d0c395fec99d931acc002fb6b299ca16b8123e2c8ef0c7e750 \
6060
--disable-banner bump -m ${{ inputs.mode }}
6161
62+
- name: Determine new release version
63+
id: release_version
64+
run: |
65+
set -euo pipefail
66+
NEW_VERSION="$(grep -E '^version:' .release.yml | head -1 | sed -E 's/^version:[[:space:]]*"?([^"[:space:]]+)"?/\1/')"
67+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
68+
echo "Release version bumped to ${NEW_VERSION}"
69+
6270
- name: Set release prerelease flag
6371
run: |
6472
set -euo pipefail
@@ -75,6 +83,15 @@ jobs:
7583
sed -i -E "/^version:/a prerelease: ${{ inputs.prerelease }}" .release.yml
7684
fi
7785
86+
- name: Ensure version label exists
87+
env:
88+
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
89+
run: |
90+
set -euo pipefail
91+
# `gh label create --force` is idempotent, so re-running this
92+
# workflow for the same release version is safe.
93+
gh label create "release-v${{ steps.release_version.outputs.version }}" --color ededed --force
94+
7895
- name: Create Pull Request
7996
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
8097
with:
@@ -90,5 +107,7 @@ jobs:
90107
Merging this PR triggers `publish.yml`'s real batch publish. Its `summary`
91108
job will create the matching GitHub Release as a **${{ inputs.prerelease && 'pre-release' || 'full release' }}**.
92109
branch: "auto-patch-release"
93-
labels: "version"
110+
labels: |
111+
version
112+
release-v${{ steps.release_version.outputs.version }}
94113
delete-branch: true

0 commit comments

Comments
 (0)