mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Auto-put PRs from release workflows in the proper milestone + minor things (#4862)
* Make workflow name use TitleCase * Indicate in the PR description that it's a multi-part workflow * Auto-put PRs from Prepare Release workflow in the proper milestone * Rename "Publish the release" workflow to "Publish Release" * Auto-put PR from Publish Release workflow in the proper milestone
This commit is contained in:
parent
bb90444979
commit
53c069a636
24
.github/workflows/prepare_release.yml
vendored
24
.github/workflows/prepare_release.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Prepare release
|
name: Prepare Release
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
@ -9,6 +9,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
crowdin_download_translations:
|
crowdin_download_translations:
|
||||||
|
needs: pr_stable_bump
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -42,11 +43,12 @@ jobs:
|
|||||||
commit-message: Automated Crowdin downstream
|
commit-message: Automated Crowdin downstream
|
||||||
title: "[i18n] Automated Crowdin downstream"
|
title: "[i18n] Automated Crowdin downstream"
|
||||||
body: |
|
body: |
|
||||||
This is an automated PR.
|
This is an automated PR that is part of Prepare Release automated workflow (2 out of 2).
|
||||||
Please ensure that there are no errors or invalid files are in the PR.
|
Please ensure that there are no errors or invalid files are in the PR.
|
||||||
labels: "Automated PR, Category: i18n, Changelog Entry: Skipped"
|
labels: "Automated PR, Category: i18n, Changelog Entry: Skipped"
|
||||||
branch: "automated/i18n"
|
branch: "automated/i18n"
|
||||||
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||||||
|
milestone: ${{ needs.pr_stable_bump.outputs.milestone_number }}
|
||||||
|
|
||||||
- name: Close and reopen the PR with different token to trigger CI
|
- name: Close and reopen the PR with different token to trigger CI
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v3
|
||||||
@ -63,6 +65,8 @@ jobs:
|
|||||||
|
|
||||||
pr_stable_bump:
|
pr_stable_bump:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
milestone_number: ${{ steps.get_milestone_number.outputs.result }}
|
||||||
steps:
|
steps:
|
||||||
# Checkout repository and install Python
|
# Checkout repository and install Python
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -80,6 +84,19 @@ jobs:
|
|||||||
PYTHONPATH: ${{ github.workspace }}:${{ env.PYTHONPATH }}
|
PYTHONPATH: ${{ github.workspace }}:${{ env.PYTHONPATH }}
|
||||||
NEW_STABLE_VERSION: ${{ github.event.inputs.new_stable_version }}
|
NEW_STABLE_VERSION: ${{ github.event.inputs.new_stable_version }}
|
||||||
|
|
||||||
|
# Get milestone number of the milestone for the new stable version
|
||||||
|
- name: Get milestone number
|
||||||
|
id: get_milestone_number
|
||||||
|
uses: actions/github-script@v3
|
||||||
|
env:
|
||||||
|
MILESTONE_TITLE: ${{ steps.bump_version_stable.outputs.new_version }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const script = require(
|
||||||
|
`${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/get_milestone_number_by_exact_title.js`
|
||||||
|
);
|
||||||
|
return await script({github, context});
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
id: cpr_bump_stable
|
id: cpr_bump_stable
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v3
|
||||||
@ -88,11 +105,12 @@ jobs:
|
|||||||
commit-message: Version bump to ${{ steps.bump_version_stable.outputs.new_version }}
|
commit-message: Version bump to ${{ steps.bump_version_stable.outputs.new_version }}
|
||||||
title: Version bump to ${{ steps.bump_version_stable.outputs.new_version }}
|
title: Version bump to ${{ steps.bump_version_stable.outputs.new_version }}
|
||||||
body: |
|
body: |
|
||||||
This is an automated PR.
|
This is an automated PR that is part of Prepare Release automated workflow (1 out of 2).
|
||||||
Please ensure that there are no errors or invalid files are in the PR.
|
Please ensure that there are no errors or invalid files are in the PR.
|
||||||
labels: "Automated PR, Changelog Entry: Skipped"
|
labels: "Automated PR, Changelog Entry: Skipped"
|
||||||
branch: "automated/pr_bumps/${{ steps.bump_version_stable.outputs.new_version }}"
|
branch: "automated/pr_bumps/${{ steps.bump_version_stable.outputs.new_version }}"
|
||||||
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||||||
|
milestone: ${{ steps.get_milestone_number.outputs.result }}
|
||||||
|
|
||||||
- name: Close and reopen the PR with different token to trigger CI
|
- name: Close and reopen the PR with different token to trigger CI
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v3
|
||||||
|
|||||||
16
.github/workflows/publish_release.yml
vendored
16
.github/workflows/publish_release.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Publish the release
|
name: Publish Release
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
@ -45,6 +45,19 @@ jobs:
|
|||||||
PYTHONPATH: ${{ github.workspace }}:${{ env.PYTHONPATH }}
|
PYTHONPATH: ${{ github.workspace }}:${{ env.PYTHONPATH }}
|
||||||
DEV_BUMP: '1'
|
DEV_BUMP: '1'
|
||||||
|
|
||||||
|
# Get milestone number of the milestone for the old version
|
||||||
|
- name: Get milestone number
|
||||||
|
id: get_milestone_number
|
||||||
|
uses: actions/github-script@v3
|
||||||
|
env:
|
||||||
|
MILESTONE_TITLE: ${{ steps.bump_version_dev.outputs.old_version }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const script = require(
|
||||||
|
`${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/get_milestone_number_by_exact_title.js`
|
||||||
|
);
|
||||||
|
return await script({github, context});
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
id: cpr_bump_dev
|
id: cpr_bump_dev
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v3
|
||||||
@ -58,6 +71,7 @@ jobs:
|
|||||||
labels: "Automated PR, Changelog Entry: Skipped"
|
labels: "Automated PR, Changelog Entry: Skipped"
|
||||||
branch: "automated/pr_bumps/${{ steps.bump_version_dev.outputs.new_version }}"
|
branch: "automated/pr_bumps/${{ steps.bump_version_dev.outputs.new_version }}"
|
||||||
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||||||
|
milestone: ${{ steps.get_milestone_number.outputs.result }}
|
||||||
|
|
||||||
- name: Close and reopen the PR with different token to trigger CI
|
- name: Close and reopen the PR with different token to trigger CI
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v3
|
||||||
|
|||||||
2
.github/workflows/scripts/bump_version.py
vendored
2
.github/workflows/scripts/bump_version.py
vendored
@ -12,6 +12,8 @@ version_info = None
|
|||||||
def repl(match: Match[str]) -> str:
|
def repl(match: Match[str]) -> str:
|
||||||
global version_info
|
global version_info
|
||||||
|
|
||||||
|
print(f"::set-output name=old_version::{match.group('version')}")
|
||||||
|
|
||||||
new_stable_version = os.environ.get("NEW_STABLE_VERSION", "auto")
|
new_stable_version = os.environ.get("NEW_STABLE_VERSION", "auto")
|
||||||
if new_stable_version == "auto":
|
if new_stable_version == "auto":
|
||||||
version_info = redbot.VersionInfo.from_str(match.group("version"))
|
version_info = redbot.VersionInfo.from_str(match.group("version"))
|
||||||
|
|||||||
49
.github/workflows/scripts/get_milestone_number_by_exact_title.js
vendored
Normal file
49
.github/workflows/scripts/get_milestone_number_by_exact_title.js
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
module.exports = (async function ({github, context}) {
|
||||||
|
const milestone_title = process.env.MILESTONE_TITLE;
|
||||||
|
const [repo_owner, repo_name] = process.env.GITHUB_REPOSITORY.split('/');
|
||||||
|
|
||||||
|
const {
|
||||||
|
repository: {
|
||||||
|
milestones: {
|
||||||
|
nodes: milestones,
|
||||||
|
pageInfo: {hasNextPage}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} = await github.graphql({
|
||||||
|
query: `
|
||||||
|
query getMilestoneNumberByTitle(
|
||||||
|
$repo_owner: String!
|
||||||
|
$repo_name: String!
|
||||||
|
$milestone_title: String!
|
||||||
|
) {
|
||||||
|
repository(owner:$repo_owner name:$repo_name) {
|
||||||
|
milestones(query:$milestone_title states:OPEN first:100) {
|
||||||
|
nodes {
|
||||||
|
number
|
||||||
|
title
|
||||||
|
}
|
||||||
|
pageInfo {
|
||||||
|
hasNextPage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
repo_owner: repo_owner,
|
||||||
|
repo_name: repo_name,
|
||||||
|
milestone_title: milestone_title,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasNextPage) {
|
||||||
|
// this should realistically never happen so let's just error
|
||||||
|
core.setFailed('Impossible happened! :)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const milestone of milestones)
|
||||||
|
if (milestone.title === milestone_title)
|
||||||
|
return milestone.number;
|
||||||
|
|
||||||
|
// if no exact match is found, assume the milestone doesn't exist
|
||||||
|
console.log('The milestone was not found. API returned the array: %o', milestones);
|
||||||
|
return null;
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user