From 9195176770405ff2fb44b6f4f1e0899e87fda73d Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 24 Jun 2024 14:05:11 -0700 Subject: [PATCH] First pass at CI and release process improvements (#1689) * First pass at CI and release process improvements Signed-off-by: Jeff Hodges * Update release-preview workflow Signed-off-by: Jeff Hodges * Rename PR labeler config file Signed-off-by: Jeff Hodges * Update config path for PR Tools Signed-off-by: Jeff Hodges * Tweak config path for labeler Signed-off-by: Jeff Hodges * Fix PR labeler config Signed-off-by: Jeff Hodges * Tweak labeler config Signed-off-by: Jeff Hodges * Update secrets key for the Slack webhook URL Signed-off-by: Jeff Hodges * Revise labeling rules Signed-off-by: Jeff Signed-off-by: Jeff Hodges * Tweak CI step names Signed-off-by: Jeff Hodges * Automatically included dependabot based dependencies under "maintenance" in the auto-generated changelogs Signed-off-by: Jeff Hodges * Add front-matter for triage label to new issues Signed-off-by: Jeff Hodges --------- Signed-off-by: Jeff Hodges Signed-off-by: Jeff --- .github/ISSUE_TEMPLATE.md | 4 + .github/labeler.yml | 28 ++++ .github/release-drafter.yml | 131 ++++++++++++++++++ .github/scripts/release-branch.sh | 15 ++ .github/workflows/pr-tools.yml | 35 +++++ .../{publish.yml => pypi-publish.yml} | 2 +- .github/workflows/release-preview.yml | 87 ++++++++++++ .github/workflows/release-publish.yml | 51 +++++++ 8 files changed, 352 insertions(+), 1 deletion(-) create mode 100644 .github/labeler.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/scripts/release-branch.sh create mode 100644 .github/workflows/pr-tools.yml rename .github/workflows/{publish.yml => pypi-publish.yml} (97%) create mode 100644 .github/workflows/release-preview.yml create mode 100644 .github/workflows/release-publish.yml diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 11028870d5..6e3e327572 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,3 +1,7 @@ +--- +labels: triage +--- + # Required: ------------ [ ] I believe this isn't a duplicate topic diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..4325617961 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,28 @@ +# https://github.com/actions/labeler#common-examples + +release-candidate: +- 'CHANGELOG.md' + +submodules: +- any: ['src/deps/**'] + +dependencies: +- any: ['pyproject.toml'] + +ci: +- '.github/**' + +documentation: +- any: ['docs/**'] + +opentime: +- any: ['src/opentime/**'] + +'time calculations': +- any: ['src/opentime/**'] + +otioview: +- any: ['src/opentimelineview/**'] + +python-bindings: +- any: ['src/py-opentimelineio/**'] diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000000..25b4677dbc --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,131 @@ +# https://github.com/release-drafter/release-drafter#configuration-options + +# The template for the body of the draft release +template: | + $CHANGES + +# The template to use for each merged pull request +change-template: '* $TITLE @$AUTHOR (#$NUMBER)' +# Characters to escape in $TITLE when inserting into change-template so that they are not interpreted as Markdown format characters +change-title-escapes: '\<*_&' # You can add # + +# The template for the name of the draft release +name-template: 'v$RESOLVED_VERSION 🌈' +# The template for the tag of the draft release +tag-template: 'v$RESOLVED_VERSION' + +# # Template used calculating the next version number for the release +# version-template: '$MAJOR.$MINOR' +# # Adjust the $RESOLVED_VERSION variable using labels. +# version-resolver: +# # every release is a whole version by default +# default: minor +# major: +# labels: +# - 'feature' +# - 'feat' +# - 'perf' +# minor: +# labels: +# - 'bug' +# - 'bugfix' +# - 'fix' +# - 'build' +# - 'refactor' +# - 'revert' +# - 'test' +# patch: +# labels: +# - 'chore' +# - 'ci' +# - 'docs' +# - 'style' + +# automatically a label into a pull request +# https://github.com/release-drafter/release-drafter#autolabeler +autolabeler: + - label: 'feat' + title: + - '/^feat.+/' + branch: + - '/feature\/.+/' + - '/feat\/.+/' + - label: 'fix' + title: + - '/^fix.+/' + branch: + - '/bugfix\/.+/' + - '/hotfix\/.+/' + - '/fix\/.+/' + - label: 'build' + title: + - '/^build.+/' + branch: + - '/build\/.+/' + - label: 'chore' + title: + - '/^chore.+/' + branch: + - '/chore\/.+/' + - label: 'ci' + title: + - '/^ci.+/' + branch: + - '/ci\/.+/' + - label: 'documentation' + title: + - '/^docs.+/' + branch: + - '/docs\/.+/' + - label: 'perf' + title: + - '/^perf.+/' + branch: + - '/perf\/.+/' + - label: 'refactor' + title: + - '/^refactor.+/' + branch: + - '/refactor\/.+/' + - label: 'revert' + title: + - '/^revert.+/' + branch: + - '/revert\/.+/' + - label: 'style' + title: + - '/^style.+/' + branch: + - '/style\/.+/' + - label: 'test' + title: + - '/^test.+/' + branch: + - '/test\/.+/' + +# Categorize pull requests using labels +# https://github.com/release-drafter/release-drafter#categorize-pull-requests +categories: + - title: '🚀 Features' + labels: + - 'feat' + - 'feature' + - 'perf' + - title: '📖 Documentation' + labels: + - 'documentation' + - title: '🐛 Bug Fixes' + labels: + - 'bug' + - 'bugfix' + - 'fix' + - title: '🧰 Maintenance' + labels: + - 'build' + - 'chore' + - 'dependencies' + - 'ci' + - 'refactor' + - 'revert' + - 'style' + - 'test' diff --git a/.github/scripts/release-branch.sh b/.github/scripts/release-branch.sh new file mode 100644 index 0000000000..d353a24357 --- /dev/null +++ b/.github/scripts/release-branch.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -e + +# +# entry script to create a release branch in ci +# generates a release branch named with a utc timestamp +# +echo 'CREATING A RELEASE BRANCH' + +# create a release branch locally and remotely +# normalize utc date to YYYY-MM-DD-HH-MM +NEW_BRANCH_NAME="release/$(date -u +%Y-%m-%d-%H-%M)" +echo "NEW BRANCH: $NEW_BRANCH_NAME" +git checkout -b $NEW_BRANCH_NAME +git push origin $NEW_BRANCH_NAME \ No newline at end of file diff --git a/.github/workflows/pr-tools.yml b/.github/workflows/pr-tools.yml new file mode 100644 index 0000000000..46bf84ee13 --- /dev/null +++ b/.github/workflows/pr-tools.yml @@ -0,0 +1,35 @@ +name: Pull Request Tools + +on: + workflow_dispatch: + pull_request: + types: [ + opened, # pr is created + reopened, # pr is reopened after being closed + synchronize, # pr is updated with new commits + ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + # label PRs based on the files that were changed + pr-labeler: + name: Label Pull Requests + runs-on: ubuntu-latest + timeout-minutes: 8 + permissions: + contents: read + pull-requests: write + steps: + - name: Checkout Repo + uses: actions/checkout@v3 # https://github.com/actions/checkout/tree/main#usage + + # https://github.com/actions/labeler#usage + - uses: actions/labeler@v4 + with: + # https://github.com/actions/labeler#inputs + configuration-path: .github/labeler.yml + sync-labels: true # remove labels when matching files are reverted or no longer changed by the PR + dot: true # auto-include paths starting with dot (e.g.; ~/.github) diff --git a/.github/workflows/publish.yml b/.github/workflows/pypi-publish.yml similarity index 97% rename from .github/workflows/publish.yml rename to .github/workflows/pypi-publish.yml index 5f22e1fc6a..8b130aa6de 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -1,4 +1,4 @@ -name: publish +name: Publish Release to PyPI on: release: diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml new file mode 100644 index 0000000000..de83563bba --- /dev/null +++ b/.github/workflows/release-preview.yml @@ -0,0 +1,87 @@ +name: Release Preview + +# Cancel other related workflows in-progress +concurrency: + group: release-preview-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + inputs: + create-new-branch: + description: 'Create branch' + type: boolean + required: true + default: true + notify: + description: 'Announce release' + type: boolean + required: true + default: true + +jobs: + release-branch: + # run if toggled on and not off an existing release branch + if: ${{github.event.inputs.create-new-branch && github.event.inputs.create-new-branch == 'true' && !startsWith(github.ref,'refs/heads/release/')}} + name: Release Branch + runs-on: ubuntu-latest + outputs: + branch-name: ${{ steps.get-branch-name.outputs.branch-name }} + steps: + - uses: actions/checkout@v3 + + - name: Create Branch + shell: bash + run: | + sh ./github/scripts/release-branch.sh + + - name: Get New Branch Name + id: get-branch-name + shell: bash + run: | + echo ::set-output name=branch-name::$(git rev-parse --abbrev-ref HEAD) + + release-preview: + needs: [release-branch] + if: ${{ always() }} + name: Release Preview + runs-on: ubuntu-latest + steps: + - name: Draft or Update a Release + # https://github.com/release-drafter/release-drafter + uses: release-drafter/release-drafter@v5 + id: draft-release + with: + publish: false + commitish: ${{needs.release-branch.outputs.branch-name || github.ref_name}} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Convert Github markdown to Slack markdown syntax + # https://github.com/LoveToKnow/slackify-markdown-action + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + if: ${{ github.event.inputs.notify == 'true' }} + id: slack-markdown + with: + text: | + [Release Notes](https://github.com/AcademySoftwareFoundation/OpenTimelineIO/releases/tag/${{ steps.draft-release.outputs.tag_name }}) + + ${{ steps.draft-release.outputs.body }} + + - name: 'Slack Notification to ##opentimelineio' + # https://github.com/rtCamp/action-slack-notify + uses: rtCamp/action-slack-notify@v2 + if: ${{ github.event.inputs.notify == 'true' }} + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASES_URL }} + SLACK_ICON: https://avatars.githubusercontent.com/u/40807682?s=512&v=4 + SLACK_LINK_NAMES: true + SLACK_USERNAME: 'OTIO Release Preview' + SLACK_CHANNEL: 'opentimelineio' + SLACK_COLOR: '#5b53ff' + SLACK_TITLE: 'Release Preview for ${{ github.repository }}' + SLACK_MESSAGE: | + ${{ steps.slack-markdown.outputs.text }} + SLACK_FOOTER: | + Release Preview of ${{ steps.draft-release.outputs.name }} + MSG_MINIMAL: commit diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml new file mode 100644 index 0000000000..a5843150e4 --- /dev/null +++ b/.github/workflows/release-publish.yml @@ -0,0 +1,51 @@ +name: Publish Release +# This workflow is called when a new release is published in GitHub. + + +# Cancel other related workflows in-progress +concurrency: + group: release-publish-${{ github.ref }} + cancel-in-progress: true + +on: + release: + types: [published] + +jobs: + load-repo: + name: Download GitHub repo + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v3 + + announce-release: + runs-on: ubuntu-latest + name: Announce successful release + needs: [load-repo] + steps: + - name: Convert markdown to slack markdown + # https://github.com/LoveToKnow/slackify-markdown-action + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: slack-markdown + with: + text: | + ${{ github.ref_name }} New version of OTIO released!. + [Release Notes](https://github.com/AcademySoftwareFoundation/OpenTimelineIO/releases/tag/${{ github.ref_name }}) + + - name: 'Slack Notification to #opentimelineio' + # https://github.com/rtCamp/action-slack-notify + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASES_URL }} + SLACK_ICON: https://avatars.githubusercontent.com/u/40807682?s=512&v=4 + SLACK_LINK_NAMES: true + SLACK_USERNAME: 'OTIO Release Bot' + SLACK_CHANNEL: 'opentimelineio' + SLACK_COLOR: '#5b53ff' + SLACK_TITLE: 'New OTIO version released!' + SLACK_MESSAGE: | + ${{ steps.slack-markdown.outputs.text }} + SLACK_FOOTER: | + Release Published: ${{ github.ref_name }} + MSG_MINIMAL: true \ No newline at end of file