-
Notifications
You must be signed in to change notification settings - Fork 4.3k
79 lines (74 loc) · 3.15 KB
/
publish_github_release_notes.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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# This workflow will take the release notes from
# /website/www/site/content/en/blog/beam-${RELEASE_VERSION}.md"
# and updated in beam repo.
name: Publish Github Release Notes
on:
workflow_dispatch:
inputs:
RELEASE_VERSION:
description: Release Version to update notes into beam repo
required: true
permissions: read-all
jobs:
set-properties:
runs-on: ubuntu-latest
outputs:
properties: ${{ steps.test-properties.outputs.properties }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: test-properties
uses: ./.github/actions/setup-default-test-properties
publish_github_release_notes:
runs-on: ubuntu-latest
needs: set-properties
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ github.event.inputs.RELEASE_VERSION}}
name: Publish Github Release Notes
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Publish github release notes
run: |
POST_PATH="website/www/site/content/en/blog/beam-${{env.RELEASE_VERSION}}.md"
RELEASE_NOTES=$(
cat ${POST_PATH} | # Read post's content
sed -n '/<!--/,$p' | # Remove post's metadata
sed -e :a -Ee 's/<!--.*-->.*//g;/<!--/N;//ba' | # Remove license
sed '/./,$!d' | # Remove leading whitespace
sed 's=](/=](https://beam.apache.org/=g' # Replace relative website path with absolute
)
ESCAPED_NOTES=$(printf '%s' "${RELEASE_NOTES}" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')
REQUEST_JSON="$(cat <<-EOF
{
"tag_name": "v${RELEASE_VERSION}",
"name": "Beam ${RELEASE_VERSION} release",
"body": ${ESCAPED_NOTES},
"generate_release_notes": true
}
EOF
)"
echo -e "Below is the request JSON about to be sent to the Github API:\n\n ${REQUEST_JSON}\n\n"
curl https://api.github.com/repos/apache/beam/releases \
-X POST \
-H "Authorization: token ${{env.GITHUB_TOKEN}}" \
-H "Content-Type:application/json" \
-d "${REQUEST_JSON}"
echo -e "\n\nView the release on Github: https://github.com/apache/beam/releases/tag/v${RELEASE_VERSION}"