Skip to content

Commit 7a396ac

Browse files
committed
build: release: close milestone when finish
1 parent 5eff2dd commit 7a396ac

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/maven-central.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
runs-on: ubuntu-latest
5252
permissions:
5353
contents: write
54+
issues: write # Required to update/close milestones
5455

5556
steps:
5657
- uses: actions/checkout@v4
@@ -162,3 +163,25 @@ jobs:
162163
163164
# Overwrite the existing release notes
164165
gh release edit $CURRENT_TAG --notes-file changelog.md
166+
167+
- name: Close Milestone
168+
env:
169+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170+
run: |
171+
CURRENT_TAG=${{ github.ref_name }}
172+
VERSION_NUM=${CURRENT_TAG#v}
173+
174+
# Fetch the ID of the milestone only if it is currently open
175+
MILESTONE_ID=$(gh api repos/${{ github.repository }}/milestones -q ".[] | select(.title==\"$VERSION_NUM\" and .state==\"open\") | .number")
176+
177+
if [ -n "$MILESTONE_ID" ]; then
178+
echo "Closing milestone $VERSION_NUM (ID: $MILESTONE_ID)..."
179+
gh api \
180+
--method PATCH \
181+
-H "Accept: application/vnd.github+json" \
182+
repos/${{ github.repository }}/milestones/$MILESTONE_ID \
183+
-f state='closed'
184+
echo "Milestone closed successfully."
185+
else
186+
echo "No open milestone found matching version $VERSION_NUM. Skipping."
187+
fi

0 commit comments

Comments
 (0)