diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 121214a..32d4ced 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,6 +53,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + pull-requests: write steps: - name: Checkout dev uses: actions/checkout@v4 @@ -60,17 +61,26 @@ jobs: ref: dev fetch-depth: 0 - - name: Sync package.json version from main + - name: Sync package.json version from main via PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | MAIN_VERSION=$(git show origin/main:package.json | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version") DEV_VERSION=$(node -p "require('./package.json').version") if [ "$MAIN_VERSION" != "$DEV_VERSION" ]; then - npm version "$MAIN_VERSION" --no-git-tag-version --allow-same-version + BRANCH="chore/sync-version-${MAIN_VERSION}" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + git checkout -b "$BRANCH" + npm version "$MAIN_VERSION" --no-git-tag-version --allow-same-version git add package.json package-lock.json git commit -m "chore: sync package.json version to $MAIN_VERSION from main" - git push + git push origin "$BRANCH" + gh pr create \ + --base dev \ + --head "$BRANCH" \ + --title "chore: sync package.json version to $MAIN_VERSION from main" \ + --body "Automated version sync from main after release." fi dev-release: