From 4ec7e591f6bf91acd240fd62553fca22286717c1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 May 2025 02:07:18 +0000 Subject: [PATCH 1/3] Initial plan for issue From 89fb438a201750fa5172ca2f9905cf2b09e98ad7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 May 2025 02:10:53 +0000 Subject: [PATCH 2/3] Implement dependabot for Git submodule updates Co-authored-by: yamachu <1955233+yamachu@users.noreply.github.com> --- .github/dependabot.yml | 7 ++ .github/workflows/dependabot-auto-merge.yml | 30 ++++++ .../dependabot-submodule-handler.yml | 97 +++++++++++++++++++ README.md | 2 + 4 files changed, 136 insertions(+) create mode 100644 .github/workflows/dependabot-auto-merge.yml create mode 100644 .github/workflows/dependabot-submodule-handler.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6b13822..ba254ac 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -30,3 +30,10 @@ updates: dev-dependencies: patterns: - "*" + + - package-ecosystem: "gitsubmodule" + directory: "/" + schedule: + interval: "weekly" + labels: + - "submodule-update" diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..b6218e9 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,30 @@ +name: Dependabot auto-approve and merge +on: pull_request + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'submodule-update') }} + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Approve PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable auto-merge for Dependabot PRs + if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' }} + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/dependabot-submodule-handler.yml b/.github/workflows/dependabot-submodule-handler.yml new file mode 100644 index 0000000..fcf7db3 --- /dev/null +++ b/.github/workflows/dependabot-submodule-handler.yml @@ -0,0 +1,97 @@ +name: Handle Dependabot Submodule Updates +on: + pull_request: + types: [opened, synchronize, reopened] + paths: + - 'binding/voicevox_core' + branches: + - 'main' + +jobs: + update-hash: + if: ${{ github.actor == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'submodule-update') }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Generate a token + id: generate_token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ steps.generate_token.outputs.token }} + submodules: recursive + ref: ${{ github.event.pull_request.head.ref }} + persist-credentials: false + + - name: Setup Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Update commit hash + id: update-hash + run: | + # Get the updated commit hash from voicevox_core submodule + NEW_HASH=$(cd binding/voicevox_core && git rev-parse HEAD) + + # Update the hash in the props file + sed -i.bak "s/.*<\/VoicevoxCoreCommitHash>/$NEW_HASH<\/VoicevoxCoreCommitHash>/" src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props + + # Check if there are changes + if [[ $(git diff --name-only) != "" ]]; then + echo "Hash updated to $NEW_HASH" + echo "hash_updated=true" >> $GITHUB_OUTPUT + else + echo "No hash changes needed" + echo "hash_updated=false" >> $GITHUB_OUTPUT + fi + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.12.0 + if: ${{ steps.update-hash.outputs.hash_updated == 'true' }} + + - name: Generate bindings + if: ${{ steps.update-hash.outputs.hash_updated == 'true' }} + working-directory: ./binding + run: make generate + + - name: Check for code generation changes + id: binding-diff + if: ${{ steps.update-hash.outputs.hash_updated == 'true' }} + run: | + if [[ $(git diff --name-only | grep .cs$) != "" ]]; then + echo "binding_has_update=true" >> $GITHUB_OUTPUT + echo "Code generation changes detected. Manual review required." + else + echo "binding_has_update=false" >> $GITHUB_OUTPUT + fi + + - name: Commit changes + if: ${{ steps.update-hash.outputs.hash_updated == 'true' && steps.binding-diff.outputs.binding_has_update != 'true' }} + run: | + git add src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props + git commit -m "Update VoicevoxCore commit hash" + git config --global url."https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com".insteadOf "https://github.com" + git push + + - name: Comment on PR if binding updates needed + if: ${{ steps.binding-diff.outputs.binding_has_update == 'true' }} + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + gh pr comment ${{ github.event.pull_request.number }} --body "⚠️ This submodule update requires manual code generation changes. Please review the changes and update accordingly." + exit 1 + + - name: Comment on PR if hash updated + if: ${{ steps.update-hash.outputs.hash_updated == 'true' && steps.binding-diff.outputs.binding_has_update != 'true' }} + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + gh pr comment ${{ github.event.pull_request.number }} --body "✅ Successfully updated VoicevoxCore commit hash to \`$NEW_HASH\`" \ No newline at end of file diff --git a/README.md b/README.md index a4ac41c..c1b8333 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ voicevox_core のリリースに合わせて、Release タグや、nuget パッ 詳細なトラッキングしているバージョンは Git Submodule として取得している [voicevox_core](./binding/voicevox_core) のコミットハッシュ、もしくは [VoicevoxCoreCommitHash](./src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props) を参照してください。 +サブモジュールの更新は GitHub Dependabot により自動的に PR が作成されます。PR の説明には変更内容のサマリーが含まれ、変更の追跡が容易になっています。 + 今後のリリースで、voicevox_engine で利用されている compatible_engine などの対応を検討しています。 ## License From 4b6ebb963d89cf06778f1225bc253d483e83b407 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 May 2025 02:23:09 +0000 Subject: [PATCH 3/3] Remove README changes as requested Co-authored-by: yamachu <1955233+yamachu@users.noreply.github.com> --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index c1b8333..a4ac41c 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,6 @@ voicevox_core のリリースに合わせて、Release タグや、nuget パッ 詳細なトラッキングしているバージョンは Git Submodule として取得している [voicevox_core](./binding/voicevox_core) のコミットハッシュ、もしくは [VoicevoxCoreCommitHash](./src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props) を参照してください。 -サブモジュールの更新は GitHub Dependabot により自動的に PR が作成されます。PR の説明には変更内容のサマリーが含まれ、変更の追跡が容易になっています。 - 今後のリリースで、voicevox_engine で利用されている compatible_engine などの対応を検討しています。 ## License