forked from misskey-dev/misskey
-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
8 changed files
with
260 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ insert_final_newline = true | |
|
||
[*.yml] | ||
indent_style = space | ||
|
||
[*.yaml] | ||
indent_style = space |
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
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,189 @@ | ||
name: Release | ||
on: | ||
pull_request: | ||
branches: | ||
- release | ||
types: | ||
- labeled | ||
|
||
jobs: | ||
check_label: | ||
name: Check release label | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check PR actor | ||
if: github.actor != github.repository_owner | ||
run: exit 1 | ||
|
||
- name: Throw an error if PR has no release tags | ||
if: github.event.label.name != 'release-patch' && github.event.label.name != 'release-patch' && github.event.label.name != 'release-patch' | ||
run: | | ||
echo "::error::PR has no release tags!! (release-major, release-minor, release-patch)" | ||
exit 1 | ||
get_diff: | ||
name: Get diff | ||
runs-on: ubuntu-latest | ||
needs: [check_label] | ||
outputs: | ||
package_diff: ${{ steps.get_diff.outputs.package_diff }} | ||
compose_diff: ${{ steps.get_diff.outputs.compose_diff }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get release branch | ||
run: git fetch origin ${{ github.base_ref }} --depth 1 | ||
|
||
- name: Get diff | ||
id: get_diff | ||
run: | | ||
echo "package_diff=$(git diff origin/${{ github.base_ref }} HEAD --relative "./package.json" | grep "^+.\+version" | wc -l)" >> $GITHUB_OUTPUT | ||
echo "compose_diff=$(git diff origin/${{ github.base_ref }} HEAD --relative "./docker-compose.yml" | grep "^+.\+image" | wc -l)" >> $GITHUB_OUTPUT | ||
update_version: | ||
name: Update version | ||
runs-on: ubuntu-latest | ||
needs: [get_diff] | ||
outputs: | ||
version: ${{ steps.version.outputs.result }} | ||
steps: | ||
- name: Check if updates are needed | ||
if: needs.get_diff.outputs.package_diff != '0' && needs.get_diff.outputs.compose_diff != '0' | ||
run: exit 0 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Update package.json | ||
uses: actions/github-script@v6 | ||
id: version | ||
with: | ||
result-encoding: string | ||
script: | | ||
const fs = require('fs') | ||
const json = JSON.parse(fs.readFileSync('${{ github.workspace }}/package.json')) | ||
let version = json.version | ||
if (${{ needs.get_diff.outputs.package_diff == '0' }}) { | ||
const isPatch = ${{ github.event.label.name == 'release-patch' }} | ||
const isMinor = ${{ github.event.label.name == 'release-minor' }} | ||
const isMajor = ${{ github.event.label.name == 'release-major' }} | ||
const versionSplit = version.split('-taiyme-v') | ||
const versionMMP = versionSplit[1].split('.') | ||
if (isPatch) | ||
versionMMP[2] = Number(versionMMP[2]) + 1; | ||
if (isMinor) { | ||
versionMMP[1] = Number(versionMMP[1]) + 1; | ||
versionMMP[2] = 0; | ||
} | ||
if (isMajor) { | ||
versionMMP[0] = Number(versionMMP[0]) + 1; | ||
versionMMP[1] = 0; | ||
versionMMP[2] = 0; | ||
} | ||
versionSplit[1] = versionMMP.join('.'); | ||
version = versionSplit.join('-taiyme-v') | ||
json.version = version | ||
fs.writeFileSync('${{ github.workspace }}/package.json', JSON.stringify(json, null, '\t')) | ||
} | ||
return version | ||
- name: Update docker-compose.yml | ||
if: needs.get_diff.outputs.compose_diff == '0' | ||
run: | | ||
yq -r eval '.services.web.image = "ghcr.io/${{ github.repository }}:${{ steps.version.outputs.result }}"' -i "${{ github.workspace }}/docker-compose.yml" | ||
- name: Commit and Push | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
git add . | ||
git commit --author=. -m "${{ steps.version.outputs.result }}" | ||
git push | ||
docker_build: | ||
name: Build Docker image and Push to Github Container Registry | ||
needs: [update_version] | ||
uses: ./.github/workflows/docker.yaml | ||
with: | ||
tag: ${{ needs.update_version.outputs.version }} | ||
|
||
release: | ||
name: Release | ||
needs: [update_version, docker_build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Get changelog title | ||
id: get_changelog_title | ||
run: echo "changelog_title=${{ needs.update_version.outputs.version }} ($(date "+%Y/%m/%d"))" >> $GITHUB_OUTPUT | ||
|
||
- name: Get changelog body | ||
id: get_changelog_body | ||
uses: actions/github-script@v6 | ||
with: | ||
result-encoding: string | ||
script: return `${{ github.event.pull_request.body }}` | ||
|
||
- name: Add new changelog | ||
uses: actions/github-script@v6 | ||
with: | ||
result-encoding: string | ||
script: | | ||
const fs = require('fs') | ||
const changelog = fs.readFileSync('${{ github.workspace }}/CHANGELOG.md').toString() | ||
const changelogSplit = changelog.split('-->\n\n##') | ||
const changelogAdded = `## ${{ steps.get_changelog_title.outputs.changelog_title }}\n\n${{ steps.get_changelog_body.outputs.result }}\n\n` | ||
const chnagelogArray = [changelogSplit[0] + "-->\n\n", changelogAdded, "##" + changelogSplit[1]] | ||
const newChangelog = chnagelogArray.join('') | ||
fs.writeFileSync('${{ github.workspace }}/CHANGELOG.md', newChangelog) | ||
- name: Commit and Push | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
git add . | ||
git commit --author=. -m "update CHANGELOG.md" | ||
git push | ||
- name: merge PR | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: gh pr merge ${{ github.event.pull_request.number }} --merge | ||
|
||
- name: Checkout release branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.base_ref }} | ||
|
||
- name: Commit and Push | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
git tag "${{ needs.update_version.outputs.version }}" | ||
git push --tags | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ needs.update_version.outputs.version }} | ||
body: ${{ steps.get_changelog_body.outputs.result }} |
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,22 @@ | ||
# taiyme/misskeyのリリース手順 | ||
|
||
## Pull Requestの作成 | ||
|
||
`release`ブランチに対するPRを作成する。 | ||
このとき、PRの本文にチェンジログを書く。 | ||
タイトルは影響しない。 | ||
|
||
## Pull Requestにラベルを付与 | ||
|
||
作成したPRに`release-major`, `release-minor`, `release-patch`のいずれかのラベルを付与する。 | ||
被せて付与することも可能だが、最上位のバージョン更新のみが適用される。 | ||
|
||
## Github Actionsの完了を待つ | ||
|
||
待ちましょう。 | ||
Githubに障害等がなければ10分程度で終わる。 | ||
|
||
## リリース完了 | ||
|
||
リリース完了。 | ||
`https://github.com/taiyme/misskey/releases/latest`から最新のリリースを確認できる。 |
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