Release Notes Monitor #954
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Notes Monitor | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */3 * * *' # every 3 hours | |
jobs: | |
get-list-of-prs: | |
name: Get Release Notes for new PRs | |
outputs: | |
matrix: ${{ steps.get-pr-list.outputs.matrix }} | |
new_commit_hash: ${{ steps.get-pr-list.outputs.new_commit_hash }} | |
existing_commit_tag: ${{ steps.get-pr-list.outputs.existing_commit_tag }} | |
new_tag: ${{ steps.get-pr-list.outputs.new_tag }} | |
sui_version: ${{ steps.get-pr-list.outputs.sui_version }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sui repo main branch | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Get list of PRs | |
id: get-pr-list | |
working-directory: ./ | |
run: | | |
export new_commit_hash=$(git rev-parse HEAD) | |
export existing_commit_tag=$(git tag --points-at ${new_commit_hash} | grep -E 'sui_v(.*)_rel_notes' | head -n 1) | |
export previous_tag=$(git tag | grep -E 'sui_v1(.*)_rel_notes' | sort -rV | head -1) | |
export previous_commit_hash=$(git rev-list -n 1 ${previous_tag}) | |
export list_of_prs=$(git log --grep "\[x\]" --pretty=oneline --abbrev-commit ${previous_commit_hash}...${new_commit_hash} -- crates dashboards doc docker external-crates kiosk narwhal nre sui-execution | grep -o '#[0-9]\+' | grep -o '[0-9]\+' | jq -R -s -c 'split("\n")[:-1]') | |
echo "matrix=${list_of_prs}" >> $GITHUB_OUTPUT | |
echo "new_commit_hash=${new_commit_hash}" >> $GITHUB_OUTPUT | |
echo "existing_commit_tag=${existing_commit_tag}" >> $GITHUB_OUTPUT | |
export sui_crate_version=$(cat Cargo.toml | grep "^version =" | tr -d '"' | awk '{ print $3 }') | |
export new_tag=$(echo "sui_v${sui_crate_version}_$(date +%s)_rel_notes") | |
echo "new_tag=${new_tag}" >> $GITHUB_OUTPUT | |
echo "sui_version=${sui_crate_version}" >> $GITHUB_OUTPUT | |
process-prs: | |
name: Processing PR | |
needs: [ get-list-of-prs ] | |
if: ${{ needs.get-list-of-prs.outputs.matrix != '[]' && needs.get-list-of-prs.outputs.matrix != '' }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
pr: ${{ fromJson(needs.get-list-of-prs.outputs.matrix) }} | |
steps: | |
- name: Reading Release notes | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Processing PR#${{ matrix.pr }}" | |
# old format | |
export rel_notes=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/MystenLabs/sui/pulls/${{ matrix.pr }} --jq ".body" | awk '/### Release notes/{p=1; next} p' | sed '/^[[:space:]]*$/d') | |
# new format | |
[[ -z $rel_notes ]] && export rel_notes=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/MystenLabs/sui/pulls/${{ matrix.pr }} --jq ".body" | awk '/^\- \[x\]/') | |
# make text json payload friendly | |
rel_notes="${rel_notes//\\/\\\\}" | |
rel_notes="${rel_notes//\"/\\\"}" | |
rel_notes="${rel_notes//$'\r'/}" | |
echo "release_notes=${rel_notes}" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # pin v4.0.2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Get PR author | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export author=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/MystenLabs/sui/pulls/${{ matrix.pr }} --jq ".user.login") | |
export slack_id=$(aws s3 cp s3://mysten-employees-dir/employees.json - | jq --arg AUTHOR "${author}" '.[] | if .github_handle == $AUTHOR then .slack_id else empty end') | |
# if we don't have the slack id or the author is not part of Mysten org, get the reviewer instead | |
if [ -z "$slack_id" ]; then | |
export reviewer=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/MystenLabs/sui/pulls/${{ matrix.pr }}/reviews --jq ".[0].user.login") | |
export slack_id=$(aws s3 cp s3://mysten-employees-dir/employees.json - | jq --arg AUTHOR "${reviewer}" '.[] | if .github_handle == $AUTHOR then .slack_id else empty end') | |
fi | |
echo "slack_id=$(echo ${slack_id} | tr -d '"')" >> $GITHUB_ENV | |
- name: Post to a Slack channel | |
uses: slackapi/slack-github-action@34c3fd73326693ef04728f8611669d918a2d781d # [email protected] | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
with: | |
channel-id: '#ext-mysten-release-notes' | |
payload: | | |
{ | |
"text": "PR *${{ matrix.pr }}* Release Notes", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*PR* <https://github.com/MystenLabs/sui/pull/${{ matrix.pr }}|${{ matrix.pr }}> by <@${{ env.slack_id }}>\n<@U03LRLPR1QX> and <@U04A8V9E203> please review release notes for upcoming `v${{ needs.get-list-of-prs.outputs.sui_version }}` release.\n *Release Notes:*\n${{ env.release_notes }}" | |
} | |
}, | |
{ | |
"type": "divider" | |
} | |
] | |
} | |
tag: | |
name: Adding git tag to processed commit | |
needs: [ get-list-of-prs ] | |
if: ${{ success() && needs.get-list-of-prs.outputs.existing_commit_tag == '' }} | |
uses: mystenlabs/sui/.github/workflows/tag.yml@main | |
with: | |
sui_commit: ${{ needs.get-list-of-prs.outputs.new_commit_hash }} | |
tag_name: ${{ needs.get-list-of-prs.outputs.new_tag }} | |
secrets: inherit |