This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
146 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
pr_number: | ||
type: string | ||
description: PR number | ||
required: true | ||
main: | ||
type: string | ||
description: Main branch name | ||
default: main | ||
user: | ||
type: string | ||
description: User name | ||
default: github-actions[bot] | ||
|
||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
name: "Release Manager" | ||
|
||
jobs: | ||
merge: | ||
name: "Go Merge" | ||
runs-on: ubuntu-latest | ||
if: ${{ inputs.pr_number != '' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: git config | ||
run: | | ||
git config --local user.email "${{ inputs.user }}@users.noreply.github.com" | ||
git config --local user.name "${{ inputs.user }}" | ||
# pr_numberからPR情報を取得 | ||
- name: Get PR | ||
run: | | ||
pr_json=$(gh pr view ${{ inputs.pr_number }} --json isDraft,headRefName) | ||
echo "pr_is_draft=$(echo $pr_json | jq -r '.isDraft')" >> $GITHUB_OUTPUT | ||
echo "pr_head_ref=$(echo $pr_json | jq -r '.headRefName')" >> $GITHUB_OUTPUT | ||
id: get_pr | ||
# checkout PR | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ steps.get_pr.outputs.pr_head_ref }} | ||
# jqでpackage.jsonから現在のバージョンを取得 | ||
- name: Get current version | ||
run: | | ||
jq -r '.version' package.json | ||
echo "current_version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT | ||
id: get_current_version | ||
# current_versionを加工してtarget_versionを取得 | ||
- name: Get target version | ||
uses: actions/script@v7 | ||
env: | ||
CURRENT_VERSION: ${{ steps.get_current_version.outputs.current_version }} | ||
with: | ||
script: | | ||
return process.env.CURRENT_VERSION.split('-')[0]; | ||
result-encoding: string | ||
id: next_target_version | ||
|
||
# バージョンをpackage.jsonに書き込み | ||
- name: Write version | ||
run: | | ||
jq '.version = "${{ steps.next_target_version.outputs.result }}"' package.json > package.json.tmp && mv package.json.tmp package.json | ||
jq '.version = "${{ steps.next_target_version.outputs.result }}"' packages/misskey-js/package.json > packages/misskey-js/package.json.tmp && mv packages/misskey-js/package.json.tmp packages/misskey-js/package.json | ||
# release/ブランチとタグを作成 | ||
- name: Commit version | ||
run: | | ||
git commit -am "[skip ci] Release: ${{ steps.next_target_version.outputs.result }}" | ||
git push origin HEAD:release/${{ steps.next_target_version.outputs.result }} | ||
- name: Try Merge | ||
run: | | ||
gh pr merge ${{ inputs.pr_number }} --auto | ||
# CHANGELOG.mdの内容を取得 | ||
- name: Get changelog | ||
run: | | ||
{ | ||
echo 'changelog<<EOF' | ||
sed -n '/## ${{ steps.next_target_version.outputs.result }}/,/^## /p' CHANGELOG.md | sed -e 1d -e '$d' | ||
echo EOF | ||
} >> $GITHUB_OUTPUT | ||
id: changelog | ||
|
||
- name: Create tag | ||
run: | | ||
git tag "${{ steps.next_target_version.outputs.result }}" | ||
git push origin "${{ steps.next_target_version.outputs.result }}" | ||
# リリースを作成 | ||
- name: Create release | ||
run: | | ||
gh release create "${{ steps.next_target_version.outputs.result }}" --title "${{ steps.next_target_version.outputs.result }}" --notes "${{ steps.changelog.outputs.changelog }}" | ||
# CHANGELOG.mdにUnreleasedのテンプレートを追加 | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.main }} | ||
- name: Prepend CHANGELOG template | ||
env: | ||
CHANGES_TEMPLATE: | | ||
## 202x.x.x (Unreleased) | ||
### General | ||
- | ||
### Client | ||
- | ||
### Server | ||
- | ||
run: sed -i "1i $(echo "${CHANGES_TEMPLATE}" | sed -r 's/$/\\n/' | while IFS= read -r line; do echo -n "$line"; done)" CHANGELOG.md | ||
- name: Commit version | ||
run: | | ||
git commit -am "[skip ci] Update CHANGELOG.md (prepend template)" | ||
git push origin HEAD:${{ inputs.main }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters