Skip to content

Commit 9834801

Browse files
authored
chore: Automated release (#13075)
* chore: Automated release * follow
1 parent 38837bd commit 9834801

File tree

3 files changed

+200
-0
lines changed

3 files changed

+200
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Release Manager: sync changelog with PR"
2+
3+
on:
4+
push:
5+
branches:
6+
- release/**
7+
paths:
8+
- 'CHANGELOG.md'
9+
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
permissions:
14+
contents: write
15+
issues: write
16+
pull-requests: write
17+
18+
jobs:
19+
edit:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
# headがrelease/かつopenのPRを1つ取得
24+
- name: Get PR
25+
run: |
26+
echo "pr_number=$(gh pr list --limit 1 --head "${{ github.ref_name }}" --json number --jq '.[] | .number')" >> $GITHUB_OUTPUT
27+
id: get_pr
28+
- name: Get target version
29+
uses: misskey-dev/release-manager-actions/.github/actions/get-target-version@v1
30+
id: v
31+
# CHANGELOG.mdの内容を取得
32+
- name: Get changelog
33+
uses: misskey-dev/release-manager-actions/.github/actions/get-changelog@v1
34+
with:
35+
version: ${{ steps.v.outputs.target_version }}
36+
id: changelog
37+
# PRのnotesを更新
38+
- name: Update PR
39+
run: |
40+
gh pr edit ${{ steps.get_pr.outputs.pr_number }} --body "${{ steps.changelog.outputs.changelog }}"
+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: "Release Manager [Dispatch]"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
## Specify the type of the next release.
7+
#version_increment_type:
8+
# type: choice
9+
# description: 'VERSION INCREMENT TYPE'
10+
# default: 'patch'
11+
# required: false
12+
# options:
13+
# - 'major'
14+
# - 'minor'
15+
# - 'patch'
16+
merge:
17+
type: boolean
18+
description: 'MERGE RELEASE BRANCH TO MAIN'
19+
default: false
20+
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
permissions:
25+
contents: write
26+
issues: write
27+
pull-requests: write
28+
29+
jobs:
30+
get-pr:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
pr_number: ${{ steps.get_pr.outputs.pr_number }}
34+
steps:
35+
- uses: actions/checkout@v4
36+
# headがrelease/かつopenのPRを1つ取得
37+
- name: Get PRs
38+
run: |
39+
echo "pr_number=$(gh pr list --limit 1 --search "head:release/ is:open" --json number --jq '.[] | .number')" >> $GITHUB_OUTPUT
40+
id: get_pr
41+
42+
merge:
43+
uses: misskey-dev/release-manager-actions/.github/workflows/merge.yml@v1
44+
needs: get-pr
45+
if: ${{ needs.get-pr.outputs.pr_number != '' && inputs.merge == true }}
46+
with:
47+
pr_number: ${{ needs.get-pr.outputs.pr_number }}
48+
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
49+
# Text to prepend to the changelog
50+
# The first line must be `## Unreleased`
51+
changes_template: |
52+
## Unreleased
53+
54+
### General
55+
-
56+
57+
### Client
58+
-
59+
60+
### Server
61+
-
62+
63+
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
64+
secrets:
65+
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
66+
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
67+
RULESET_EDIT_APP_ID: ${{ secrets.RULESET_EDIT_APP_ID }}
68+
RULESET_EDIT_APP_PRIVATE_KEY: ${{ secrets.RULESET_EDIT_APP_PRIVATE_KEY }}
69+
70+
create-prerelease:
71+
uses: misskey-dev/release-manager-actions/.github/workflows/create-prerelease.yml@v1
72+
needs: get-pr
73+
if: ${{ needs.get-pr.outputs.pr_number != '' && inputs.merge != true }}
74+
with:
75+
pr_number: ${{ needs.get-pr.outputs.pr_number }}
76+
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
77+
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
78+
secrets:
79+
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
80+
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
81+
82+
create-target:
83+
uses: misskey-dev/release-manager-actions/.github/workflows/create-target.yml@v1
84+
needs: get-pr
85+
if: ${{ needs.get-pr.outputs.pr_number == '' }}
86+
with:
87+
# The script for version increment.
88+
# process.env.CURRENT_VERSION: The current version.
89+
#
90+
# Misskey calender versioning (yyyy.MM.patch) example
91+
version_increment_script: |
92+
const now = new Date();
93+
const year = now.toLocaleDateString('en-US', { year: 'numeric', timeZone: 'Asia/Tokyo' });
94+
const month = now.toLocaleDateString('en-US', { month: 'numeric', timeZone: 'Asia/Tokyo' });
95+
const [major, minor, _patch] = process.env.CURRENT_VERSION.split('.');
96+
const patch = Number(_patch.split('-')[0]);
97+
if (Number.isNaN(patch)) {
98+
console.error('Invalid patch version', year, month, process.env.CURRENT_VERSION, major, minor, _patch);
99+
throw new Error('Invalid patch version');
100+
}
101+
if (year !== major || month !== minor) {
102+
return `${year}.${month}.0`;
103+
} else {
104+
return `${major}.${minor}.${patch + 1}`;
105+
}
106+
##Semver example
107+
#version_increment_script: |
108+
# const [major, minor, patch] = process.env.CURRENT_VERSION.split('.');
109+
# if ("${{ inputs.version_increment_type }}" === "major") {
110+
# return `${Number(major) + 1}.0.0`;
111+
# } else if ("${{ inputs.version_increment_type }}" === "minor") {
112+
# return `${major}.${Number(minor) + 1}.0`;
113+
# } else {
114+
# return `${major}.${minor}.${Number(patch) + 1}`;
115+
# }
116+
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
117+
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
118+
secrets:
119+
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
120+
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
121+
RULESET_EDIT_APP_ID: ${{ secrets.RULESET_EDIT_APP_ID }}
122+
RULESET_EDIT_APP_PRIVATE_KEY: ${{ secrets.RULESET_EDIT_APP_PRIVATE_KEY }}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Release Manager: release RC when ready for review"
2+
3+
on:
4+
pull_request:
5+
types: [ready_for_review]
6+
7+
env:
8+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
10+
permissions:
11+
contents: write
12+
issues: write
13+
pull-requests: write
14+
15+
jobs:
16+
check:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
ref: ${{ steps.get_pr.outputs.ref }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
# PR情報を取得
23+
- name: Get PR
24+
run: |
25+
pr_json=$(gh pr view ${{ github.event.pull_request.number }} --json isDraft,headRefName)
26+
echo "ref=$(echo $pr_json | jq -r '.headRefName')" >> $GITHUB_OUTPUT
27+
id: get_pr
28+
release:
29+
uses: misskey-dev/release-manager-actions/.github/workflows/create-prerelease.yml@v1
30+
needs: check
31+
if: startsWith(needs.check.outputs.ref, 'release/')
32+
with:
33+
pr_number: ${{ github.event.pull_request.number }}
34+
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
35+
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
36+
secrets:
37+
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
38+
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}

0 commit comments

Comments
 (0)