From 146a4ad03982d0cea91a92f921be39b02453abc7 Mon Sep 17 00:00:00 2001 From: taiyme <53635909+taiyme@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:48:23 +0900 Subject: [PATCH] =?UTF-8?q?chore(ci/release):=20=E3=83=AA=E3=83=AA?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AB=E6=9C=AC?= =?UTF-8?q?=E5=AE=B6=E3=81=AE=E6=9B=B4=E6=96=B0=E6=83=85=E5=A0=B1=E3=82=92?= =?UTF-8?q?=E5=90=AB=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generate-release-notes/action.yaml | 77 +++++++++++++++++++ .../get-upstream-changelog/action.yaml | 28 +++++++ .github/workflows/release.yaml | 16 +++- 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 .github/actions/generate-release-notes/action.yaml create mode 100644 .github/actions/get-upstream-changelog/action.yaml diff --git a/.github/actions/generate-release-notes/action.yaml b/.github/actions/generate-release-notes/action.yaml new file mode 100644 index 000000000000..661c8e58a661 --- /dev/null +++ b/.github/actions/generate-release-notes/action.yaml @@ -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 '
Click to view' + echo "$upstream_changelog" + echo '
' + echo $delimiter + } >> $GITHUB_OUTPUT diff --git a/.github/actions/get-upstream-changelog/action.yaml b/.github/actions/get-upstream-changelog/action.yaml new file mode 100644 index 000000000000..bac40ca80e9c --- /dev/null +++ b/.github/actions/get-upstream-changelog/action.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e86fce1b665..072c1d00e6d0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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