Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci/release): リリースノートに本家の更新情報を含める #276

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/actions/generate-release-notes/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Generate release notes
description: リリースノートを作成します

inputs:
version:
description: Version
required: true

outputs:
release_notes:
value: ${{ steps.generate-release-notes.outputs.release_notes }}
description: Release notes

runs:
using: composite
steps:
- name: Prepare
env:
INPUT_VERSION: ${{ inputs.version }}
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
current_version="$INPUT_VERSION"
current_version_base="$(echo "$current_version" | sed 's/-.*//')"

tag_list="$(gh release list --exclude-drafts --exclude-pre-releases --json tagName --jq '.[].tagName')"
previous_version="$(echo "$tag_list" | grep -x -A1 "$current_version" | tail -n1 || true)"
if [[ -z "$previous_version" ]]; then
previous_version="$(echo "$tag_list" | head -n1)"
fi

{
echo "current_version=${current_version}"
echo "previous_version=${previous_version}"
echo "current_version_base=${current_version_base}"
} >> $GITHUB_ENV

- name: Get upstream changelog
id: get-upstream-changelog
uses: ./.github/actions/get-upstream-changelog
with:
current_version_base: ${{ env.current_version_base }}

- name: Generate notes
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
delimiter="$(openssl rand -hex 8)"
{
echo "generated_notes<<${delimiter}"
gh api repos/taiyme/misskey/releases/generate-notes \
-f "tag_name=${current_version}" \
-f "previous_tag_name=${previous_version}" \
--jq '.body'
echo $delimiter
} >> $GITHUB_ENV

- name: Generate release notes
id: generate-release-notes
env:
generated_notes: ${{ env.generated_notes }}
upstream_changelog: ${{ steps.get-upstream-changelog.outputs.upstream_changelog }}
shell: bash
run: |
delimiter="$(openssl rand -hex 8)"
{
echo "release_notes<<${delimiter}"
echo "$generated_notes"
echo ''
echo "## ${current_version_base} (Merged upstream)"
echo ''
echo '<details><summary>Click to view</summary>'
echo "$upstream_changelog"
echo '</details>'
echo $delimiter
} >> $GITHUB_OUTPUT
28 changes: 28 additions & 0 deletions .github/actions/get-upstream-changelog/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Get upstream changelog
description: upstreamのchangelogを取得します

inputs:
current_version_base:
description: Current version base
required: true

outputs:
upstream_changelog:
value: ${{ steps.get-upstream-changelog.outputs.upstream_changelog }}
description: Changelog

runs:
using: composite
steps:
- name: Get upstream changelog
id: get-upstream-changelog
env:
current_version_base: ${{ inputs.current_version_base }}
shell: bash
run: |
delimiter="$(openssl rand -hex 8)"
{
echo "upstream_changelog<<${delimiter}"
sed -n "/## ${current_version_base}/,/^## /p" CHANGELOG.md | sed -e 1d -e '$d'
echo $delimiter
} >> $GITHUB_OUTPUT
16 changes: 15 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,22 @@ jobs:
ref: ${{ vars.RELEASE_BRANCH }}
fetch-depth: 0

- name: Generate release notes
id: generate-release-notes
uses: ./.github/actions/generate-release-notes
with:
version: ${{ needs.parse_version.outputs.NEW_VERSION }}

- name: Set release notes
env:
release_notes: ${{ steps.generate-release-notes.outputs.release_notes }}
run: |
echo "$release_notes" > /tmp/release-notes.md

- name: Create Release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh release create ${{ needs.parse_version.outputs.NEW_VERSION }} --generate-notes
gh release create ${{ needs.parse_version.outputs.NEW_VERSION }} \
--title ${{ needs.parse_version.outputs.NEW_VERSION }} \
--notes-file /tmp/release-notes.md