|
| 1 | +name: release-please |
| 2 | +run-name: crabcode release by @${{ github.actor }} |
| 3 | + |
| 4 | +concurrency: |
| 5 | + group: release-please-${{ github.ref }} |
| 6 | + cancel-in-progress: false |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + release-please: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + pull-requests: write |
| 20 | + outputs: |
| 21 | + release_created: ${{ steps.release.outputs.release_created }} |
| 22 | + tag_name: ${{ steps.release.outputs.tag_name }} |
| 23 | + version: ${{ steps.release.outputs.version }} |
| 24 | + steps: |
| 25 | + - uses: googleapis/release-please-action@v4 |
| 26 | + id: release |
| 27 | + with: |
| 28 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + - name: Check if PR exists |
| 31 | + id: check-pr |
| 32 | + run: | |
| 33 | + PR_OUTPUT='${{ steps.release.outputs.pr }}' |
| 34 | + if [ -n "$PR_OUTPUT" ] && [ "$PR_OUTPUT" != "null" ]; then |
| 35 | + echo "has_pr=true" >> $GITHUB_OUTPUT |
| 36 | + echo "pr_branch=$(echo '${{ steps.release.outputs.pr }}' | jq -r '.headBranchName')" >> $GITHUB_OUTPUT |
| 37 | + else |
| 38 | + echo "has_pr=false" >> $GITHUB_OUTPUT |
| 39 | + fi |
| 40 | +
|
| 41 | + - uses: actions/checkout@v6 |
| 42 | + if: steps.check-pr.outputs.has_pr == 'true' |
| 43 | + with: |
| 44 | + ref: ${{ steps.check-pr.outputs.pr_branch }} |
| 45 | + fetch-depth: 1 |
| 46 | + |
| 47 | + - name: Format CHANGELOG.md with Prettier |
| 48 | + if: steps.check-pr.outputs.has_pr == 'true' |
| 49 | + run: | |
| 50 | + echo "Formatting CHANGELOG.md on branch: ${{ steps.check-pr.outputs.pr_branch }}" |
| 51 | + npx --yes prettier@latest --write CHANGELOG.md |
| 52 | +
|
| 53 | + if git diff --quiet CHANGELOG.md; then |
| 54 | + echo "No formatting changes needed" |
| 55 | + else |
| 56 | + echo "Formatting changes detected, committing..." |
| 57 | + git config user.name "github-actions[bot]" |
| 58 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 59 | + git add CHANGELOG.md |
| 60 | + git commit -m "chore: format CHANGELOG.md with prettier" |
| 61 | + git push |
| 62 | + echo "Formatting committed and pushed" |
| 63 | + fi |
0 commit comments