Skip to content

Commit

Permalink
chore(CI): improve milestone handling (#4403)
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm authored Jun 27, 2024
1 parent c30681a commit ca2f788
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/CREATE_MILESTONE.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Create new Milestone

on:
milestone:
types: ['closed']

jobs:
create-milestone:
runs-on: ubuntu-latest
name: Create new Milestone
if: startsWith(github.event.milestone.title, 'M')
steps:
- name: Get new Milestone Title
id: getTitle
env:
TITLE: ${{github.event.milestone.title}}
run: |
MILESTONE_NUMBER=${TITLE:1}
INCREMENTED_NUMBER=$((MILESTONE_NUMBER + 1))
echo "MILESTONE_NAME=M$INCREMENTED_NUMBER" >> $GITHUB_OUTPUT
- name: Create new Milestone
env:
TITLE: ${{steps.getTitle.outputs.MILESTONE_NAME}}
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method POST \
/repos/${{ github.repository }}/milestones \
-f "title=$TITLE" -f "state=open"
43 changes: 14 additions & 29 deletions .github/workflows/RELEASE_ISSUE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,34 @@ jobs:
template-path: 'docs/.project/RELEASE_TEMPLATE.md'
package-path: 'app/package.json'

createMilestone:
assignMilestone:
needs: createReleaseIssue
if: github.event.issue.milestone
runs-on: ubuntu-latest
name: Create new Milestones
name: Assign Milestone
steps:
- name: Close old Milestone
- name: Get current Milestone
id: getMilestone
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/milestones/${{ github.event.issue.milestone.number }} \
-f "state=closed"
- name: Create and Assign new Milestone
# Fetch the list of milestones for the repository
# Filter for milestones that start with 'M' and are open
MILESTONE=$(gh api -H "Accept: application/vnd.github.v3+json" \
/repos/${{ github.repository }}/milestones \
--jq '.[] | select(.title | startswith("M")) | .number'
)
echo "MILESTONE_NUMBER=$MILESTONE" >> $GITHUB_OUTPUT
- name: Assign Milestone to new Issue
env:
GH_TOKEN: ${{ github.token }}
TITLE: ${{github.event.issue.milestone.title}}
run: |
# Generate new Milestone Title (M<number+1>)
MILESTONE_NUMBER=${TITLE:1}
INCREMENTED_NUMBER=$((MILESTONE_NUMBER + 1))
MILESTONE_NAME=M$INCREMENTED_NUMBER
# Create new Milestone
echo "Creating Milestone" $MILESTONE_NAME
NEW_MILESTONE_NUMBER=$(gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/milestones \
-f "title=$MILESTONE_NAME" -f "state=open" \
--jq '.number'
)
echo "Created Milestone" $NEW_MILESTONE_NUMBER
# Assign new Milestone to new issue
echo "Assigning Milestone to release issue"
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{ fromJson(needs.createReleaseIssue.outputs.issue).number }} \
-F "milestone=$MILESTONE_NUMBER"
-F "milestone=${{steps.getMilestone.outputs.MILESTONE_NUMBER}}"
updateSlackRole:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions docs/.project/RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ _To be done to build the release after release testing completed._
_To be done once the release is built._

* [ ] publish release on [Github Releases](https://github.com/camunda/camunda-modeler/releases)
* [ ] close [current milestone](https://github.com/camunda/camunda-modeler/milestones)

_To be done as a post-release activity._

* [ ] update Camunda Modeler screenshots (and potentially text content) in the docs by running [screenshots workflow](https://github.com/camunda/camunda-docs-modeler-screenshots/actions/workflows/CREATE_SCREENSHOTS.yml). Download artifacts and create PRs for:
* [ ] [camunda-docs-static](https://github.com/camunda/camunda-docs-static)
* [ ] [camunda-docs-manual](https://github.com/camunda/camunda-docs-manual)
Expand Down

0 comments on commit ca2f788

Please sign in to comment.