diff --git a/.github/actions/generate-release-notes/action.yaml b/.github/actions/generate-release-notes/action.yaml new file mode 100644 index 000000000000..b4dfebb85ece --- /dev/null +++ b/.github/actions/generate-release-notes/action.yaml @@ -0,0 +1,82 @@ +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" + echo "$current_version" + current_version_base="$(echo "$current_version" | sed 's/-.*//')" + echo "$current_version_base" + + tag_list="$(gh release list --exclude-drafts --exclude-pre-releases --json tagName --jq '.[].tagName')" + echo "$tag_list" + previous_version="$(echo "$tag_list" | grep -x -A1 "$current_version" | tail -n1 || true)" + echo "$previous_version" + if [[ -z "$previous_version" ]]; then + previous_version="$(echo "$tag_list" | head -n1)" + fi + echo "$previous_version" + + { + 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/print-release-notes.yaml b/.github/workflows/print-release-notes.yaml new file mode 100644 index 000000000000..841717bbb34c --- /dev/null +++ b/.github/workflows/print-release-notes.yaml @@ -0,0 +1,38 @@ +name: Print release notes + +on: + workflow_dispatch: + inputs: + version: + type: string + required: true + default: "2024.8.0-taiyme.0" + +jobs: + create_release_notes: + name: Create release notes + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + with: + ref: ${{ github.sha }} + fetch-depth: 1 + + - name: Generate + id: generate-release-notes + uses: ./.github/actions/generate-release-notes + with: + version: ${{ inputs.version }} + + - name: Print + env: + release_notes: ${{ steps.generate-release-notes.outputs.release_notes }} + run: | + echo "$release_notes" + + - name: Summary + env: + release_notes: ${{ steps.generate-release-notes.outputs.release_notes }} + run: | + echo "$release_notes" >> $GITHUB_STEP_SUMMARY