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
93 lines (90 loc) · 3.82 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
on:
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHANGES_TEMPLATE: |
## 202x.x.x (Unreleased)\
\
### General\
-\
\
### Client\
-\
\
### Server\
-\
name: "Release Manager"
jobs:
get-prs:
runs-on: ubuntu-latest
outputs:
pr_number: ${{ steps.get_prs.outputs.value }}
steps:
- uses: actions/checkout@v4
# headがrelease/かつopenのPRを1つ取得
- name: Get PRs
run: "gh pr list --state open --head release/ --json number --jq '.[] | .number'"
id: get_prs
create-release:
needs: get-prs
runs-on: ubuntu-latest
if: ${{ needs.get-prs.outputs.pr_number == '' }}
# 日付ベースでリリースを作成
name: "Create Release"
steps:
- uses: actions/checkout@v4
# jqでpackage.jsonから現在のバージョンを取得
- name: Get current version
run: echo "current_version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
id: get_current_version
# バージョンをインクリメント
- name: Increment version
uses: actions/script@v7
env:
CURRENT_VERSION: ${{ steps.get_current_version.outputs.current_version }}
with:
script: |
const now = new Date();
const year = now.toLocaleDateString('en-US', { year: 'numeric', timeZone: 'Asia/Tokyo' });
const month = now.toLocaleDateString('en-US', { month: 'numeric', timeZone: 'Asia/Tokyo' });
const [major, minor, patch] = process.env.CURRENT_VERSION.split('.');
if (year !== major || month !== minor) {
return `${year}.${month}.0`;
} else {
return `${major}.${minor}.${Number(patch) + 1}`;
}
result-encoding: string
id: increment_version
# バージョンをpackage.jsonに書き込み
- name: Write version
run: |
jq '.version = "${{ steps.increment_version.outputs.result }}-beta.0"' package.json > package.json.tmp && mv package.json.tmp package.json
jq '.version = "${{ steps.increment_version.outputs.result }}-beta.0"' packages/misskey-js/package.json > packages/misskey-js/package.json.tmp && mv packages/misskey-js/package.json.tmp packages/misskey-js/package.json
# CHANGELOG.mdのUnreleasedの内容を後で使うために取得
- name: Get changelog
run: |
sed -n '/## 202x.x.x (Unreleased)/,/^## /p' CHANGELOG.md | sed -e 1d -e '$d'
id: changelog
# CHANGELOG.mdのバージョンの書き換え
- name: Modify CHANGELOG.md
run: |
echo "${{ env.CHANGES_TEMPLATE }}\n"
sed -i 's/## 202x.x.x (Unreleased)/## ${{ steps.increment_version.outputs.result }}/' CHANGELOG.md
sed "1i ${{ env.CHANGES_TEMPLATE }}\n" CHANGELOG.md > CHANGELOG.md.tmp && mv CHANGELOG.md.tmp CHANGELOG.md
# バージョンをコミット
- name: Commit version
run: |
git config --local user.email "[email protected]"
git config --local user.name "LuckyBeast"
git commit -am "Bump version to ${{ steps.increment_version.outputs.result }}-beta.0"
# バージョンをタグ付け
- name: Tag version
run: |
git tag -a v${{ steps.increment_version.outputs.result }}-beta.0 -m "Bump version to ${{ steps.increment_version.outputs.result }}-beta.0"
# バージョンをpush
- name: Push version
run: "git push origin HEAD:release/${{ steps.increment_version.outputs.result }}-beta.0 --tags"
# リリースを作成
- name: Create release
run: |
gh release create ${{ steps.increment_version.outputs.result }}-beta.0 --prerelease --title "${{ steps.increment_version.outputs.result }}-beta.0" --notes "${{ steps.changelog.outputs.stdout }}"