Skip to content

Commit 0c6f25d

Browse files
committed
Update of release process to include update of changelog and publishing of release announcement on Org Discussion.
1 parent 5019705 commit 0c6f25d

4 files changed

Lines changed: 105 additions & 202 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
# Posts a release announcement to the utPLSQL org .github repository's
3+
# Announcements discussion category.
4+
#
5+
# Required environment variables:
6+
# GH_TOKEN - GitHub token with write:discussion scope (ORG_DISCUSSION_TOKEN)
7+
# RELEASE_TAG - e.g. v3.2.3
8+
# RELEASE_BODY - markdown release notes
9+
# RELEASE_URL - URL of the GitHub release page
10+
11+
set -euo pipefail
12+
13+
ORG="utPLSQL"
14+
REPO_NAME=".github"
15+
16+
# Get org node ID
17+
ORG_DATA=$(gh api graphql -f query='query($org: String!) {
18+
organization(login: $org) {
19+
id
20+
}
21+
}' -f org="$ORG")
22+
ORG_ID=$(echo "$ORG_DATA" | jq -r '.data.organization.id')
23+
24+
# Get repository node ID
25+
REPO_DATA=$(gh api graphql -f query='query($owner: String!, $name: String!) {
26+
repository(owner: $owner, name: $name) {
27+
id
28+
}
29+
}' -f owner="$ORG" -f name="$REPO_NAME")
30+
REPO_ID=$(echo "$REPO_DATA" | jq -r '.data.repository.id')
31+
32+
# Get Announcements category ID
33+
CATEGORY_DATA=$(gh api graphql -f query='query($owner: String!, $name: String!) {
34+
repository(owner: $owner, name: $name) {
35+
discussionCategories(first: 20) {
36+
nodes { id name }
37+
}
38+
}
39+
}' -f owner="$ORG" -f name="$REPO_NAME")
40+
CATEGORY_ID=$(echo "$CATEGORY_DATA" | jq -r \
41+
'.data.repository.discussionCategories.nodes[] | select(.name == "Announcements") | .id')
42+
43+
BODY="${RELEASE_BODY}
44+
45+
<hr /><em>This discussion was created from the release <a href='${RELEASE_URL}'>${RELEASE_TAG}</a>.</em>"
46+
47+
DISCUSSION_URL=$(gh api graphql -f query='mutation($repoId: ID!, $categoryId: ID!, $title: String!, $body: String!) {
48+
createDiscussion(input: {
49+
repositoryId: $repoId,
50+
categoryId: $categoryId,
51+
title: $title,
52+
body: $body
53+
}) {
54+
discussion { url }
55+
}
56+
}' \
57+
-f repoId="$REPO_ID" \
58+
-f categoryId="$CATEGORY_ID" \
59+
-f title="utPLSQL ${RELEASE_TAG} released" \
60+
-f body="$BODY" \
61+
--jq '.data.createDiscussion.discussion.url')
62+
63+
echo "Announcement posted: $DISCUSSION_URL"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Updates CHANGELOG.md by prepending a new section for the release.
3+
#
4+
# Required environment variables:
5+
# RELEASE_TAG - e.g. v3.2.3
6+
# RELEASE_BODY - markdown release notes
7+
# RELEASE_DATE - ISO-8601 date string (only the first 10 chars are used)
8+
# TARGET_BRANCH - branch to push the updated changelog to
9+
10+
set -euo pipefail
11+
12+
python3 - <<'PYEOF'
13+
import os
14+
15+
tag = os.environ['RELEASE_TAG']
16+
body = os.environ['RELEASE_BODY'].strip()
17+
date = os.environ['RELEASE_DATE'][:10]
18+
19+
new_section = f"## [{tag}] - {date}\n\n{body}\n\n---\n\n"
20+
21+
with open('CHANGELOG.md', 'r') as f:
22+
content = f.read()
23+
24+
marker = '\n---\n'
25+
pos = content.index(marker) + len(marker)
26+
updated = content[:pos] + '\n' + new_section + content[pos:]
27+
28+
with open('CHANGELOG.md', 'w') as f:
29+
f.write(updated)
30+
31+
print(f"Added {tag} to CHANGELOG.md")
32+
PYEOF
33+
34+
git add CHANGELOG.md
35+
git commit -m "Add release notes for ${RELEASE_TAG} to CHANGELOG.md [skip ci]"
36+
git push origin HEAD:"${TARGET_BRANCH}"

.github/workflows/release.yml

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,7 @@ jobs:
3434
RELEASE_TAG: ${{ github.event.release.tag_name }}
3535
RELEASE_DATE: ${{ github.event.release.published_at }}
3636
TARGET_BRANCH: ${{ github.event.release.target_commitish }}
37-
run: |
38-
python3 - <<'PYEOF'
39-
import os
40-
41-
tag = os.environ['RELEASE_TAG']
42-
body = os.environ['RELEASE_BODY'].strip()
43-
date = os.environ['RELEASE_DATE'][:10]
44-
45-
new_section = f"## [{tag}] - {date}\n\n{body}\n\n---\n\n"
46-
47-
with open('CHANGELOG.md', 'r') as f:
48-
content = f.read()
49-
50-
marker = '\n---\n'
51-
pos = content.index(marker) + len(marker)
52-
updated = content[:pos] + '\n' + new_section + content[pos:]
53-
54-
with open('CHANGELOG.md', 'w') as f:
55-
f.write(updated)
56-
57-
print(f"Added {tag} to CHANGELOG.md")
58-
PYEOF
59-
git add CHANGELOG.md
60-
git commit -m "Add release notes for ${RELEASE_TAG} to CHANGELOG.md [skip ci]"
61-
git push origin HEAD:"${TARGET_BRANCH}"
37+
run: .github/scripts/update_changelog.sh
6238

6339
- name: Set build version number env variables
6440
run: .github/scripts/set_release_version_numbers_env.sh
@@ -83,60 +59,23 @@ jobs:
8359
run: |
8460
git archive --prefix=utPLSQL/ -o utPLSQL.zip --format=zip HEAD
8561
git archive --prefix=utPLSQL/ -o utPLSQL.tar.gz --format=tar.gz HEAD
86-
md5sum utPLSQL.zip --tag > utPLSQL.zip.md5
87-
md5sum utPLSQL.tar.gz --tag > utPLSQL.tar.gz.md5
62+
sha256sum utPLSQL.zip --tag > utPLSQL.zip.sha256
63+
sha256sum utPLSQL.tar.gz --tag > utPLSQL.tar.gz.sha256
8864
8965
- name: Release
9066
uses: softprops/action-gh-release@v1
9167
with:
9268
files: |
9369
utPLSQL.zip
94-
utPLSQL.zip.md5
70+
utPLSQL.zip.sha256
9571
utPLSQL.tar.gz
96-
utPLSQL.tar.gz.md5
72+
utPLSQL.tar.gz.sha256
9773
9874
- name: Post release announcement to org discussions
9975
env:
10076
GH_TOKEN: ${{ secrets.ORG_DISCUSSION_TOKEN }}
10177
RELEASE_TAG: ${{ github.event.release.tag_name }}
10278
RELEASE_BODY: ${{ github.event.release.body }}
10379
RELEASE_URL: ${{ github.event.release.html_url }}
104-
run: |
105-
ORG="utPLSQL"
106-
107-
ORG_DATA=$(gh api graphql -f query='query($org: String!) {
108-
organization(login: $org) {
109-
id
110-
discussionCategories(first: 20) {
111-
nodes { id name }
112-
}
113-
}
114-
}' -f org="$ORG")
115-
116-
ORG_ID=$(echo "$ORG_DATA" | jq -r '.data.organization.id')
117-
CATEGORY_ID=$(echo "$ORG_DATA" | jq -r \
118-
'.data.organization.discussionCategories.nodes[] | select(.name == "Announcements") | .id')
119-
120-
BODY="${RELEASE_BODY}
121-
122-
---
123-
[View full release on GitHub](${RELEASE_URL})"
124-
125-
DISCUSSION_URL=$(gh api graphql -f query='mutation($orgId: ID!, $categoryId: ID!, $title: String!, $body: String!) {
126-
createDiscussion(input: {
127-
organizationId: $orgId,
128-
categoryId: $categoryId,
129-
title: $title,
130-
body: $body
131-
}) {
132-
discussion { url }
133-
}
134-
}' \
135-
-f orgId="$ORG_ID" \
136-
-f categoryId="$CATEGORY_ID" \
137-
-f title="utPLSQL ${RELEASE_TAG} released" \
138-
-f body="$BODY" \
139-
--jq '.data.createDiscussion.discussion.url')
140-
141-
echo "Announcement posted: $DISCUSSION_URL"
80+
run: .github/scripts/post_release_announcement.sh
14281

.github/workflows/test_publishing.yml

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)