From e04ae3aec5e97f4e810c6a60ea74fb8d7cb686bb Mon Sep 17 00:00:00 2001 From: Zaran Lalvani Date: Fri, 10 May 2024 22:13:37 -0400 Subject: [PATCH 1/5] feat: marketplace action --- .github/workflows/bumpgen-core.yml | 26 ++++++++++++++++++ action.yml | 42 ++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/bumpgen-core.yml create mode 100644 action.yml diff --git a/.github/workflows/bumpgen-core.yml b/.github/workflows/bumpgen-core.yml new file mode 100644 index 0000000..0dab179 --- /dev/null +++ b/.github/workflows/bumpgen-core.yml @@ -0,0 +1,26 @@ +name: "Bumpgen (core)" + +on: + pull_request: + types: + - opened + - labeled + +permissions: + pull-requests: read + +jobs: + main: + name: Run Bumpgen + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' || contains( github.event.pull_request.labels.*.name, 'run bumpgen') }} + steps: + - uses: actions/checkout@v4 + - name: Setup + uses: ./tooling/github/setup + - name: Bumpgen + uses: ./ + with: + path: "./packages/bumpgen-core/" + llm_key: ${{ secrets.LLM_API_KEY }} + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..64f9468 --- /dev/null +++ b/action.yml @@ -0,0 +1,42 @@ +name: "bumpgen" +description: "handle breaking changes from dependency upgrades" +author: Xeol + +inputs: + path: + description: Repository path + required: false + default: "./" + llm_key: + description: "LLM API key" + required: true + github_token: + description: "GitHub token" + required: true + +runs: + using: "composite" + steps: + - shell: bash + env: + LLM_API_KEY: ${{ inputs.llm_key }} + run: | + npm install -g bumpgen + bumpgen --simple --dir ${{ inputs.path }} --no-upgrade --auto-detect + - shell: bash + name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + - shell: bash + name: Check for changes and commit + env: + GITHUB_TOKEN: ${{ inputs.github_token }} + run: | + git add -A + if ! git diff-index --quiet HEAD; then + git commit -m "chore: run bumpgen" + git push origin HEAD:${GITHUB_REF#refs/heads/} + else + echo "No changes to commit" + fi From 08e2376f60bfb33c5d814f4866b45f995989441b Mon Sep 17 00:00:00 2001 From: Zaran Lalvani Date: Mon, 13 May 2024 18:22:02 -0400 Subject: [PATCH 2/5] fix autodetect logic --- packages/bumpgen-core/src/services/git/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/bumpgen-core/src/services/git/index.ts b/packages/bumpgen-core/src/services/git/index.ts index 145918c..604d9c9 100644 --- a/packages/bumpgen-core/src/services/git/index.ts +++ b/packages/bumpgen-core/src/services/git/index.ts @@ -12,7 +12,7 @@ export const createGitService = ( raw: git, getMainBranch: async (cwd: string) => { await git.cwd(cwd); - return ( + const mainBranch = ( await subprocess.exec( "git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'", { @@ -20,6 +20,12 @@ export const createGitService = ( }, ) ).trim(); + + if (!mainBranch) { + return null; + } + + return mainBranch; }, }; }; From 97fabcc0e2a75ef93b80039f3aca4553db1a5100 Mon Sep 17 00:00:00 2001 From: Zaran Lalvani Date: Mon, 13 May 2024 23:38:35 -0400 Subject: [PATCH 3/5] workflow tweaks --- .github/workflows/bumpgen-core.yml | 1 - action.yml | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bumpgen-core.yml b/.github/workflows/bumpgen-core.yml index 0dab179..e654858 100644 --- a/.github/workflows/bumpgen-core.yml +++ b/.github/workflows/bumpgen-core.yml @@ -23,4 +23,3 @@ jobs: with: path: "./packages/bumpgen-core/" llm_key: ${{ secrets.LLM_API_KEY }} - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/action.yml b/action.yml index 64f9468..1b83391 100644 --- a/action.yml +++ b/action.yml @@ -10,9 +10,6 @@ inputs: llm_key: description: "LLM API key" required: true - github_token: - description: "GitHub token" - required: true runs: using: "composite" @@ -31,9 +28,9 @@ runs: - shell: bash name: Check for changes and commit env: - GITHUB_TOKEN: ${{ inputs.github_token }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git add -A + git add -u if ! git diff-index --quiet HEAD; then git commit -m "chore: run bumpgen" git push origin HEAD:${GITHUB_REF#refs/heads/} From 9bdb6a127bde8c48e778ec6711dff47488a7bbc7 Mon Sep 17 00:00:00 2001 From: Zaran Lalvani Date: Tue, 14 May 2024 19:54:13 -0400 Subject: [PATCH 4/5] fixes --- apps/cli/src/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/cli/src/index.tsx b/apps/cli/src/index.tsx index f40a4c5..747eafb 100644 --- a/apps/cli/src/index.tsx +++ b/apps/cli/src/index.tsx @@ -78,7 +78,9 @@ const available = await bumpFinder.list(); if (!pkg) { if (autoDetect) { - const detected = await bumpFinder.detect(); + const detected = await bumpFinder.detect( + autoDetect === true ? undefined : autoDetect, + ); if (detected.length > 0) { if (detected.length > 1) { From 318a19926ac5a5274e8d090309ce3b104cfec4b1 Mon Sep 17 00:00:00 2001 From: Zaran Lalvani Date: Tue, 14 May 2024 20:40:21 -0400 Subject: [PATCH 5/5] use push action --- .github/workflows/bumpgen-core.yml | 1 + action.yml | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bumpgen-core.yml b/.github/workflows/bumpgen-core.yml index e654858..0dab179 100644 --- a/.github/workflows/bumpgen-core.yml +++ b/.github/workflows/bumpgen-core.yml @@ -23,3 +23,4 @@ jobs: with: path: "./packages/bumpgen-core/" llm_key: ${{ secrets.LLM_API_KEY }} + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/action.yml b/action.yml index 1b83391..226b469 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,9 @@ inputs: llm_key: description: "LLM API key" required: true + github_token: + description: "GitHub token" + required: true runs: using: "composite" @@ -27,13 +30,22 @@ runs: git config user.email "github-actions[bot]@users.noreply.github.com" - shell: bash name: Check for changes and commit + id: commit_changes env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ inputs.github_token }} run: | git add -u if ! git diff-index --quiet HEAD; then git commit -m "chore: run bumpgen" - git push origin HEAD:${GITHUB_REF#refs/heads/} + echo "::set-output name=changes_detected::true" else echo "No changes to commit" + echo "::set-output name=changes_detected::false" fi + + - name: Push changes + if: steps.commit_changes.outputs.changes_detected == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ inputs.github_token }} + branch: ${{ github.ref }}