Skip to content

Commit

Permalink
wip: generate release notes?
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyme committed Sep 30, 2024
1 parent b75fa33 commit 0c6fdaa
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/actions/generate-release-notes/action.yaml
Original file line number Diff line number Diff line change
@@ -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 '<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
38 changes: 38 additions & 0 deletions .github/workflows/print-release-notes.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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

0 comments on commit 0c6fdaa

Please sign in to comment.