aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-19 01:01:15 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-19 01:01:15 +0300
commitf412d171d0423e524056969463a3ef29d5da7a90 (patch)
tree857d63f53fd1806e7a9cf0e1ed180a9b4d8f0a36 /.github/workflows
parent6925f8a5d67d254a10703f22897b0efab5b453a5 (diff)
ci: close implemented issues pending release
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/label-next-release-issues.yml55
-rw-r--r--.github/workflows/release.yml59
2 files changed, 102 insertions, 12 deletions
diff --git a/.github/workflows/label-next-release-issues.yml b/.github/workflows/label-next-release-issues.yml
index 5e98b1f5..7a27edc6 100644
--- a/.github/workflows/label-next-release-issues.yml
+++ b/.github/workflows/label-next-release-issues.yml
@@ -1,4 +1,4 @@
-name: Label next-release issues
+name: Close pending-release issues
on:
push:
@@ -9,10 +9,10 @@ permissions:
issues: write
env:
- NEXT_RELEASE_LABEL: included-in-next-release
+ NEXT_RELEASE_LABEL: pending-release
jobs:
- label:
+ close:
runs-on: ubuntu-latest
steps:
@@ -20,13 +20,15 @@ jobs:
with:
fetch-depth: 0
- - name: Label issues referenced by pushed commits
+ - name: Close issues referenced by pushed commits
shell: bash
env:
- GH_TOKEN: ${{ github.token }}
+ GH_TOKEN: ${{ secrets.KANGAL_GITHUB_TOKEN }}
run: |
set -euo pipefail
+ echo "Using GitHub token for $(gh api user --jq .login)."
+
BEFORE="${{ github.event.before }}"
AFTER="${{ github.sha }}"
ZERO_SHA="0000000000000000000000000000000000000000"
@@ -54,11 +56,25 @@ jobs:
gh api -X POST "repos/${GITHUB_REPOSITORY}/labels" \
-f name="$NEXT_RELEASE_LABEL" \
-f color="5319E7" \
- -f description="Landed on master and planned for the next release." \
+ -f description="Implemented on master and pending a published release." \
>/dev/null \
|| gh api "repos/${GITHUB_REPOSITORY}/labels/${NEXT_RELEASE_LABEL}" >/dev/null
fi
+ PENDING_COMMENT_MARKER="<!-- herdr:pending-release -->"
+ PENDING_COMMENT="${PENDING_COMMENT_MARKER}"$'\n'"Implemented on master and queued for the next release. This is not available in a published Herdr release yet."
+
+ issue_has_comment_marker() {
+ local issue="$1"
+ local marker="$2"
+ local comments
+ if ! comments="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${issue}/comments?per_page=100" --jq '.[].body')"; then
+ echo "::warning::Could not read comments for issue #$issue."
+ return 2
+ fi
+ grep -F -- "$marker" >/dev/null <<<"$comments"
+ }
+
for issue in "${ISSUES[@]}"; do
echo "Checking #$issue"
if ! data="$(gh api "repos/${GITHUB_REPOSITORY}/issues/${issue}")"; then
@@ -76,8 +92,31 @@ jobs:
continue
fi
- if ! gh issue edit "$issue" --repo "$GITHUB_REPOSITORY" --add-label "$NEXT_RELEASE_LABEL"; then
- echo "::warning::Could not label issue #$issue."
+ HAS_NEXT_RELEASE_LABEL="$(jq -r --arg label "$NEXT_RELEASE_LABEL" 'any(.labels[].name; . == $label)' <<<"$data")"
+ if [ "$HAS_NEXT_RELEASE_LABEL" != "true" ]; then
+ if ! gh issue edit "$issue" --repo "$GITHUB_REPOSITORY" --add-label "$NEXT_RELEASE_LABEL"; then
+ echo "::warning::Could not label issue #$issue."
+ continue
+ fi
+ fi
+
+ MARKER_STATUS=0
+ issue_has_comment_marker "$issue" "$PENDING_COMMENT_MARKER" || MARKER_STATUS="$?"
+ if [ "$MARKER_STATUS" -eq 2 ]; then
+ continue
+ fi
+ HAS_PENDING_COMMENT="false"
+ if [ "$MARKER_STATUS" -eq 0 ]; then
+ HAS_PENDING_COMMENT="true"
+ fi
+
+ if [ "$HAS_PENDING_COMMENT" = "true" ]; then
+ if ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed; then
+ echo "::warning::Could not close issue #$issue."
+ continue
+ fi
+ elif ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed --comment "$PENDING_COMMENT"; then
+ echo "::warning::Could not close issue #$issue."
continue
fi
done
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 45ad76aa..fd293529 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -144,11 +144,14 @@ jobs:
- name: Close issues referenced by released commits
shell: bash
env:
- GH_TOKEN: ${{ github.token }}
- NEXT_RELEASE_LABEL: included-in-next-release
+ GH_TOKEN: ${{ secrets.KANGAL_GITHUB_TOKEN }}
+ NEXT_RELEASE_LABEL: pending-release
+ LEGACY_NEXT_RELEASE_LABEL: included-in-next-release
run: |
set -euo pipefail
+ echo "Using GitHub token for $(gh api user --jq .login)."
+
VERSION="${GITHUB_REF_NAME#v}"
CURRENT_COMMIT="$(git rev-list -n 1 "$GITHUB_REF_NAME")"
PREVIOUS_TAG="$(git describe --first-parent --tags --match 'v[0-9]*' --abbrev=0 "${CURRENT_COMMIT}^" 2>/dev/null || true)"
@@ -171,6 +174,19 @@ jobs:
fi
RELEASE_URL="https://github.com/${GITHUB_REPOSITORY}/releases/tag/v${VERSION}"
+ RELEASE_COMMENT_MARKER="<!-- herdr:released:v${VERSION} -->"
+ RELEASE_COMMENT="${RELEASE_COMMENT_MARKER}"$'\n'"Released in [v${VERSION}](${RELEASE_URL})."
+
+ issue_has_comment_marker() {
+ local issue="$1"
+ local marker="$2"
+ local comments
+ if ! comments="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${issue}/comments?per_page=100" --jq '.[].body')"; then
+ echo "::warning::Could not read comments for issue #$issue."
+ return 2
+ fi
+ grep -F -- "$marker" >/dev/null <<<"$comments"
+ }
for issue in "${ISSUES[@]}"; do
echo "Checking #$issue"
@@ -185,14 +201,42 @@ jobs:
fi
HAS_NEXT_RELEASE_LABEL="$(jq -r --arg label "$NEXT_RELEASE_LABEL" 'any(.labels[].name; . == $label)' <<<"$data")"
+ HAS_LEGACY_NEXT_RELEASE_LABEL="$(jq -r --arg label "$LEGACY_NEXT_RELEASE_LABEL" 'any(.labels[].name; . == $label)' <<<"$data")"
+ HAS_PENDING_RELEASE_LABEL="false"
+ if [ "$HAS_NEXT_RELEASE_LABEL" = "true" ] || [ "$HAS_LEGACY_NEXT_RELEASE_LABEL" = "true" ]; then
+ HAS_PENDING_RELEASE_LABEL="true"
+ fi
+ MARKER_STATUS=0
+ issue_has_comment_marker "$issue" "$RELEASE_COMMENT_MARKER" || MARKER_STATUS="$?"
+ if [ "$MARKER_STATUS" -eq 2 ]; then
+ continue
+ fi
+ HAS_RELEASE_COMMENT="false"
+ if [ "$MARKER_STATUS" -eq 0 ]; then
+ HAS_RELEASE_COMMENT="true"
+ fi
if [ "$(jq -r '.state' <<<"$data")" = "open" ]; then
- if ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed --comment "Released in [v${VERSION}](${RELEASE_URL})."; then
+ if [ "$HAS_RELEASE_COMMENT" = "true" ]; then
+ if ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed; then
+ echo "::warning::Could not close issue #$issue."
+ continue
+ fi
+ elif ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed --comment "$RELEASE_COMMENT"; then
echo "::warning::Could not close issue #$issue."
continue
fi
+ elif [ "$HAS_PENDING_RELEASE_LABEL" = "true" ]; then
+ if [ "$HAS_RELEASE_COMMENT" != "true" ]; then
+ if ! gh issue comment "$issue" --repo "$GITHUB_REPOSITORY" --body "$RELEASE_COMMENT"; then
+ echo "::warning::Could not comment on issue #$issue."
+ continue
+ fi
+ else
+ echo "Skipping release comment for #$issue because it already exists."
+ fi
else
- echo "Skipping close for #$issue because it is not open."
+ echo "Skipping release comment for #$issue because it is closed and has no $NEXT_RELEASE_LABEL label."
fi
if [ "$HAS_NEXT_RELEASE_LABEL" = "true" ]; then
@@ -201,6 +245,13 @@ jobs:
continue
fi
fi
+
+ if [ "$HAS_LEGACY_NEXT_RELEASE_LABEL" = "true" ]; then
+ if ! gh issue edit "$issue" --repo "$GITHUB_REPOSITORY" --remove-label "$LEGACY_NEXT_RELEASE_LABEL"; then
+ echo "::warning::Could not remove $LEGACY_NEXT_RELEASE_LABEL from issue #$issue."
+ continue
+ fi
+ fi
done
update-latest-json: