-
Notifications
You must be signed in to change notification settings - Fork 1k
112 lines (93 loc) · 3.99 KB
/
post-release-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Post Release Workflow
on:
workflow_dispatch: # Enables manual trigger
jobs:
generate-release-notes:
name: Generate Release Notes
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Download Changelog Generator
run: |
curl -L -o github-changelog-generator.jar https://github.com/spring-io/github-changelog-generator/releases/download/v0.0.11/github-changelog-generator.jar
- name: Generate release notes
id: generate_notes
run: |
java -jar github-changelog-generator.jar \
${GITHUB_REF_NAME#v} \
changelog.md \
--changelog.repository="${{ github.repository }}" \
--github.token="${{ secrets.GITHUB_TOKEN }}"
- name: Run script to process Markdown file
run: python .github/workflows/process_changelog.py
- name: Update release text
run: |
echo -e "::Info::Original changelog\n\n"
cat changelog.md
echo -e "\n\n"
echo -e "::Info::Processed changelog\n\n"
cat changelog-output.md
gh release edit ${{ github.ref_name }} --notes-file changelog-output.md
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
close-milestone:
name: Close Milestone
runs-on: ubuntu-latest
needs: generate-release-notes
steps:
- name: Close milestone
run: |
# Extract version without 'v' prefix
milestone_name=${GITHUB_REF_NAME#v}
echo "Closing milestone: $milestone_name"
# List milestones and find the ID
milestone_id=$(gh api "/repos/${{ github.repository }}/milestones?state=open" \
--jq ".[] | select(.title == \"$milestone_name\").number")
if [ -z "$milestone_id" ]; then
echo "::error::Milestone '$milestone_name' not found"
exit 1
fi
# Close the milestone
gh api --method PATCH "/repos/${{ github.repository }}/milestones/$milestone_id" \
-f state=closed
echo "Successfully closed milestone: $milestone_name"
env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
notify:
name: Send Notifications
runs-on: ubuntu-latest
needs: close-milestone
steps:
- name: Announce Release on `Spring-Releases` space
run: |
milestone_name=${GITHUB_REF_NAME#v}
curl --location --request POST '${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }}' \
--header 'Content-Type: application/json' \
--data-raw "{ text: \"${{ github.event.repository.name }}-announcing ${milestone_name}\"}"
- name: Post on Bluesky
env:
BSKY_IDENTIFIER: ${{ secrets.BLUESKY_HANDLE }}
BSKY_PASSWORD: ${{ secrets.BLUESKY_PASSWORD }}
run: |
# First get the session token
SESSION_TOKEN=$(curl -s -X POST https://bsky.social/xrpc/com.atproto.server.createSession \
-H "Content-Type: application/json" \
-d "{\"identifier\":\"$BSKY_IDENTIFIER\",\"password\":\"$BSKY_PASSWORD\"}" | \
jq -r .accessJwt)
# Create post content
VERSION=${GITHUB_REF_NAME#v}
POST_TEXT="${{ github.event.repository.name }} ${VERSION} has been released!\n\nCheck out the changelog: https://github.com/${GITHUB_REPOSITORY}/releases/tag/${GITHUB_REF_NAME}"
# Create the post
curl -X POST https://bsky.social/xrpc/com.atproto.repo.createRecord \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${SESSION_TOKEN}" \
-d "{
\"repo\": \"$BSKY_IDENTIFIER\",
\"collection\": \"app.bsky.feed.post\",
\"record\": {
\"\$type\": \"app.bsky.feed.post\",
\"text\": \"$POST_TEXT\",
\"createdAt\": \"$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")\"
}
}"