aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-16 18:54:27 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-16 18:54:27 +0300
commit2dc50f08832058755ab42f75933e40e5d2188cb2 (patch)
treedeae6e6bd5dc9f98570aa42121c1080cab6aee67 /.github/workflows
parentb173a86e34343a94c2941fa960b9c7e6a3bcb26a (diff)
ci: close referenced issues after release
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/release.yml66
1 files changed, 66 insertions, 0 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 79d043ae..531ffe68 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -128,6 +128,72 @@ jobs:
herdr-macos-aarch64/herdr-macos-aarch64
body_path: RELEASE_NOTES.md
+ close-released-issues:
+ needs: release
+ runs-on: ubuntu-latest
+ continue-on-error: true
+ permissions:
+ contents: read
+ issues: write
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Close issues referenced by released commits
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ set -euo pipefail
+
+ 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)"
+
+ if [ -z "$PREVIOUS_TAG" ]; then
+ echo "No previous release tag found; skipping issue close."
+ exit 0
+ fi
+
+ echo "Scanning released commits in $PREVIOUS_TAG..$GITHUB_REF_NAME for refs #<issue> lines."
+ mapfile -t ISSUES < <(
+ git log --format=%b "$PREVIOUS_TAG..$CURRENT_COMMIT" \
+ | perl -ne 'print "$1\n" if /^\s*refs\s+#([0-9]+)\s*$/i' \
+ | sort -nu
+ )
+
+ if [ "${#ISSUES[@]}" -eq 0 ]; then
+ echo "No released issue refs found."
+ exit 0
+ fi
+
+ RELEASE_URL="https://github.com/${GITHUB_REPOSITORY}/releases/tag/v${VERSION}"
+
+ for issue in "${ISSUES[@]}"; do
+ echo "Checking #$issue"
+ if ! data="$(gh api "repos/${GITHUB_REPOSITORY}/issues/${issue}")"; then
+ echo "::warning::Could not read issue #$issue; skipping."
+ continue
+ fi
+
+ if jq -e 'has("pull_request")' <<<"$data" >/dev/null; then
+ echo "Skipping #$issue because it is a pull request."
+ continue
+ fi
+
+ if [ "$(jq -r '.state' <<<"$data")" != "open" ]; then
+ echo "Skipping #$issue because it is not open."
+ continue
+ fi
+
+ if ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed --comment "Released in [v${VERSION}](${RELEASE_URL})."; then
+ echo "::warning::Could not close issue #$issue."
+ continue
+ fi
+ done
+
update-latest-json:
needs: release
runs-on: ubuntu-latest