2023-05-08 08:39:28 +00:00
|
|
|
name: Branch Created
|
|
|
|
|
|
|
|
on:
|
|
|
|
create:
|
|
|
|
|
|
|
|
permissions: {}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release-branch-created:
|
|
|
|
name: Release Branch Created
|
|
|
|
if: ${{ github.event.ref_type == 'branch' && endsWith(github.event.ref, '-x-y') }}
|
|
|
|
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: |
|
|
|
|
if [[ ${{ github.event.ref }} =~ ^([0-9]+)-x-y$ ]]; then
|
|
|
|
echo "MAJOR=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
|
|
|
|
else
|
|
|
|
echo "Not a release branch: ${{ github.event.ref }}"
|
|
|
|
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 }}
|
2023-09-28 15:27:02 +00:00
|
|
|
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
|
|
|
|
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 }}
|
2023-11-13 18:37:26 +00:00
|
|
|
uses: dsanders11/project-actions/copy-project@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0
|
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-11-13 18:37:26 +00:00
|
|
|
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-11-13 18:37:26 +00:00
|
|
|
- name: Find Previous Release Project Board
|
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
|
|
|
uses: dsanders11/project-actions/find-project@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0
|
|
|
|
id: find-prev-release-board
|
|
|
|
with:
|
|
|
|
title: ${{ steps.generate-project-metadata.outputs.prev-prev-major }}-x-y
|
|
|
|
- name: Close Previous Release Project Board
|
|
|
|
if: ${{ steps.check-major-version.outputs.MAJOR }}
|
|
|
|
uses: dsanders11/project-actions/close-project@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0
|
|
|
|
with:
|
|
|
|
project-number: ${{ steps.find-prev-release-board.outputs.number }}
|