Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: marketplace action #83

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/bumpgen-core.yml
Original file line number Diff line number Diff line change
@@ -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 }}
51 changes: 51 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "bumpgen"
description: "handle breaking changes from dependency upgrades"
author: Xeol <xeol.io>

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
id: commit_changes
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
git add -u
if ! git diff-index --quiet HEAD; then
git commit -m "chore: run bumpgen"
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 }}
4 changes: 3 additions & 1 deletion apps/cli/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion packages/bumpgen-core/src/services/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ 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/@@'",
{
cwd,
},
)
).trim();

if (!mainBranch) {
return null;
}

return mainBranch;
},
};
};
Expand Down
Loading