Skip to content

Commit 5fa0c38

Browse files
authored
release: fix release-cli.yml for cli release (#320)
1 parent f7a649a commit 5fa0c38

File tree

1 file changed

+20
-55
lines changed

1 file changed

+20
-55
lines changed

.github/workflows/release-cli.yml

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ jobs:
173173
create-release:
174174
needs: build-and-package
175175
runs-on: ubuntu-latest
176+
permissions:
177+
contents: write
178+
pull-requests: write
176179
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
177180

178181
steps:
@@ -216,61 +219,23 @@ jobs:
216219
jq '.["cli-version"], .["cli-packages"]' package.json
217220
218221
- name: Create Pull Request for package.json update
219-
run: |
220-
CLI_VERSION="${{ needs.build-and-package.outputs.version }}"
221-
BRANCH_NAME="update-cli-version-$CLI_VERSION"
222-
223-
# Configure git
224-
git config user.name "github-actions[bot]"
225-
git config user.email "github-actions[bot]@users.noreply.github.com"
226-
227-
# Check if changes exist
228-
if git diff --quiet package.json; then
229-
echo "No changes to package.json, skipping PR creation"
230-
exit 0
231-
fi
232-
233-
# Create new branch
234-
git checkout -b "$BRANCH_NAME"
235-
236-
# Add and commit changes
237-
git add package.json
238-
git commit -m "chore: update cli-version to $CLI_VERSION and cli-packages array
239-
240-
- Updated cli-version to $CLI_VERSION
241-
- Updated cli-packages array with available package files
242-
243-
This PR was automatically created by the CLI release workflow to keep the root package.json in sync with the CLI version from pyproject.toml."
244-
245-
# Push branch
246-
git push origin "$BRANCH_NAME"
247-
248-
# Create PR (only if branch doesn't exist)
249-
if ! gh pr list --head "$BRANCH_NAME" --json number --jq '. | length' | grep -q "0"; then
250-
echo "PR already exists for branch $BRANCH_NAME"
251-
exit 0
252-
fi
253-
254-
gh pr create \
255-
--title "chore: update cli-version to $CLI_VERSION" \
256-
--body "This PR updates the \`cli-version\` field and \`cli-packages\` array in the root package.json to match the current CLI version ($CLI_VERSION) from the pyproject.toml file.
257-
258-
**Changes:**
259-
- Updated \`cli-version\` field to \`$CLI_VERSION\`
260-
- Updated \`cli-packages\` array with available package files
261-
262-
**Available Packages:**
263-
$(jq -r '.["cli-packages"][]' package.json | sed 's/^/- /')
264-
265-
**Download URLs:**
266-
$(jq -r '.["cli-packages"][]' package.json | sed "s|^|- https://github.com/raghavyuva/nixopus/releases/download/nixopus-$CLI_VERSION/|")
267-
268-
This PR was automatically created by the CLI release workflow." \
269-
--base master \
270-
--head "$BRANCH_NAME" || echo "Failed to create PR, but continuing with release"
271-
272-
env:
273-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222+
if: ${{ needs.build-and-package.outputs.version != '' }}
223+
uses: peter-evans/create-pull-request@v5
224+
with:
225+
token: ${{ secrets.GITHUB_TOKEN }}
226+
commit-message: "chore: update cli-version to ${{ needs.build-and-package.outputs.version }} and cli-packages array"
227+
title: "chore: update cli-version to ${{ needs.build-and-package.outputs.version }}"
228+
body: |
229+
This PR updates the `cli-version` field and `cli-packages` array in the root package.json to match the current CLI version (${{ needs.build-and-package.outputs.version }}) from the pyproject.toml file.
230+
231+
**Changes:**
232+
- Updated `cli-version` field to `${{ needs.build-and-package.outputs.version }}`
233+
- Updated `cli-packages` array with available package files
234+
235+
This PR was automatically created by the CLI release workflow.
236+
branch: "chore/update-cli-version-${{ needs.build-and-package.outputs.version }}"
237+
delete-branch: true
238+
base: "master"
274239

275240
- name: Create GitHub Release
276241
run: |

0 commit comments

Comments
 (0)