Skip to content

Release Notes Monitor #1

Release Notes Monitor

Release Notes Monitor #1

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@755da8c3cf115ac066823e79a1e1788f8940201b # pin@v3
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 ${{ matrix.pr }} PR"
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')
echo "release_notes=${rel_notes}" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # pin@v1
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')
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 }}\n"
}
},
{
"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