2023-05-08 08:39:28 +00:00
|
|
|
name: Branch Created
|
|
|
|
|
|
|
|
on:
|
2023-12-07 04:58:41 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
branch-name:
|
|
|
|
description: Branch name (e.g. `29-x-y`)
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-05-08 08:39:28 +00:00
|
|
|
create:
|
|
|
|
|
|
|
|
permissions: {}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release-branch-created:
|
|
|
|
name: Release Branch Created
|
2023-12-07 04:58:41 +00:00
|
|
|
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.ref_type == 'branch' && endsWith(github.event.ref, '-x-y') && !startsWith(github.event.ref, 'roller')) }}
|
2023-05-08 08:39:28 +00:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
pull-requests: write
|
|
|
|
repository-projects: write # Required for labels
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-07-03 08:34:57 +00:00
|
|
|
- name: Determine Major Version
|
|
|
|
id: check-major-version
|
|
|
|
run: |
|
2023-12-07 04:58:41 +00:00
|
|
|
if [[ ${{ github.event.inputs.branch-name || github.event.ref }} =~ ^([0-9]+)-x-y$ ]]; then
|
2023-07-03 08:34:57 +00:00
|
|
|
echo "MAJOR=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
|
|
|
|
else
|
2023-12-07 04:58:41 +00:00
|
|
|
echo "Not a release branch: ${{ github.event.inputs.branch-name || github.event.ref }}"
|
2023-07-03 08:34:57 +00:00
|
|
|
fi
|
2023-05-08 08:39:28 +00:00
|
|
|
- name: New Release Branch Tasks
|
2023-07-03 08:34:57 +00:00
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
2023-05-08 08:39:28 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
GH_REPO: electron/electron
|
2023-07-03 08:34:57 +00:00
|
|
|
MAJOR: ${{ steps.check-major-version.outputs.MAJOR }}
|
2023-05-08 08:39:28 +00:00
|
|
|
NUM_SUPPORTED_VERSIONS: 3
|
|
|
|
run: |
|
2023-07-03 08:34:57 +00:00
|
|
|
PREVIOUS_MAJOR=$((MAJOR - 1))
|
|
|
|
UNSUPPORTED_MAJOR=$((MAJOR - NUM_SUPPORTED_VERSIONS - 1))
|
|
|
|
|
|
|
|
# Create new labels
|
|
|
|
gh label create $MAJOR-x-y --color 8d9ee8 || true
|
|
|
|
gh label create target/$MAJOR-x-y --color ad244f --description "PR should also be added to the \"${MAJOR}-x-y\" branch." || true
|
|
|
|
gh label create merged/$MAJOR-x-y --color 61a3c6 --description "PR was merged to the \"${MAJOR}-x-y\" branch." || true
|
|
|
|
gh label create in-flight/$MAJOR-x-y --color db69a6 || true
|
|
|
|
gh label create needs-manual-bp/$MAJOR-x-y --color 8b5dba || true
|
|
|
|
|
|
|
|
# Change color of old labels
|
|
|
|
gh label edit $UNSUPPORTED_MAJOR-x-y --color ededed || true
|
|
|
|
gh label edit target/$UNSUPPORTED_MAJOR-x-y --color ededed || true
|
|
|
|
gh label edit merged/$UNSUPPORTED_MAJOR-x-y --color ededed || true
|
|
|
|
gh label edit in-flight/$UNSUPPORTED_MAJOR-x-y --color ededed || true
|
|
|
|
gh label edit needs-manual-bp/$UNSUPPORTED_MAJOR-x-y --color ededed || true
|
|
|
|
|
|
|
|
# Add the new target label to any PRs which:
|
|
|
|
# * target the previous major
|
|
|
|
# * are in-flight for the previous major
|
|
|
|
# * need manual backport for the previous major
|
|
|
|
for PREVIOUS_MAJOR_LABEL in target/$PREVIOUS_MAJOR-x-y in-flight/$PREVIOUS_MAJOR-x-y needs-manual-bp/$PREVIOUS_MAJOR-x-y; do
|
|
|
|
PULL_REQUESTS=$(gh pr list --label $PREVIOUS_MAJOR_LABEL --jq .[].number --json number --limit 500)
|
|
|
|
if [[ $PULL_REQUESTS ]]; then
|
|
|
|
echo $PULL_REQUESTS | xargs -n 1 gh pr edit --add-label target/$MAJOR-x-y || true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
- name: Generate GitHub App token
|
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
2023-09-28 15:27:02 +00:00
|
|
|
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
|
2023-07-03 08:34:57 +00:00
|
|
|
id: generate-token
|
2023-08-30 15:09:33 +00:00
|
|
|
with:
|
|
|
|
creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
|
|
|
|
org: electron
|
2023-09-28 15:27:02 +00:00
|
|
|
- name: Generate Release Project Board Metadata
|
2023-07-03 08:34:57 +00:00
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
2024-02-14 10:13:03 +00:00
|
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
2023-09-28 15:27:02 +00:00
|
|
|
id: generate-project-metadata
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const major = ${{ steps.check-major-version.outputs.MAJOR }}
|
2023-11-13 18:37:26 +00:00
|
|
|
const nextMajor = major + 1
|
|
|
|
const prevMajor = major - 1
|
2023-07-03 08:34:57 +00:00
|
|
|
|
2023-11-13 18:37:26 +00:00
|
|
|
core.setOutput("major", major)
|
|
|
|
core.setOutput("next-major", nextMajor)
|
|
|
|
core.setOutput("prev-major", prevMajor)
|
|
|
|
core.setOutput("prev-prev-major", prevMajor - 1)
|
2023-09-28 15:27:02 +00:00
|
|
|
core.setOutput("template-view", JSON.stringify({
|
|
|
|
major,
|
2023-11-13 18:37:26 +00:00
|
|
|
"next-major": nextMajor,
|
|
|
|
"prev-major": prevMajor,
|
2023-09-28 15:27:02 +00:00
|
|
|
}))
|
|
|
|
- name: Create Release Project Board
|
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
2024-05-23 09:14:23 +00:00
|
|
|
uses: dsanders11/project-actions/copy-project@eb760c48894b5702398529cbb8f6e98378e315d0 # v1.3.0
|
2023-12-04 15:18:14 +00:00
|
|
|
id: create-release-board
|
2023-09-28 15:27:02 +00:00
|
|
|
with:
|
|
|
|
drafts: true
|
|
|
|
project-number: 64
|
|
|
|
# TODO - Set to public once GitHub fixes their GraphQL bug
|
|
|
|
# public: true
|
2023-12-07 04:58:41 +00:00
|
|
|
# TODO - Enable once GitHub doesn't require overly broad, read
|
|
|
|
# and write permission for repo "Contents" to link
|
|
|
|
# link-to-repository: electron/electron
|
2023-09-28 15:27:02 +00:00
|
|
|
template-view: ${{ steps.generate-project-metadata.outputs.template-view }}
|
2023-11-13 18:37:26 +00:00
|
|
|
title: ${{ steps.generate-project-metadata.outputs.major }}-x-y
|
2023-09-28 15:27:02 +00:00
|
|
|
token: ${{ steps.generate-token.outputs.token }}
|
2023-12-04 15:18:14 +00:00
|
|
|
- name: Dump Release Project Board Contents
|
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
|
|
|
run: gh project item-list ${{ steps.create-release-board.outputs.number }} --owner electron --format json | jq
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
|
2023-11-13 18:37:26 +00:00
|
|
|
- name: Find Previous Release Project Board
|
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
2024-05-23 09:14:23 +00:00
|
|
|
uses: dsanders11/project-actions/find-project@eb760c48894b5702398529cbb8f6e98378e315d0 # v1.3.0
|
2023-11-13 18:37:26 +00:00
|
|
|
id: find-prev-release-board
|
|
|
|
with:
|
|
|
|
title: ${{ steps.generate-project-metadata.outputs.prev-prev-major }}-x-y
|
2024-01-10 12:25:11 +00:00
|
|
|
token: ${{ steps.generate-token.outputs.token }}
|
2023-11-13 18:37:26 +00:00
|
|
|
- name: Close Previous Release Project Board
|
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
2024-05-23 09:14:23 +00:00
|
|
|
uses: dsanders11/project-actions/close-project@eb760c48894b5702398529cbb8f6e98378e315d0 # v1.3.0
|
2023-11-13 18:37:26 +00:00
|
|
|
with:
|
|
|
|
project-number: ${{ steps.find-prev-release-board.outputs.number }}
|
2024-01-10 12:25:11 +00:00
|
|
|
token: ${{ steps.generate-token.outputs.token }}
|