fix: repair release-please workflow YAML #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Please | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.RELEASE_PLEASE_TOKEN }} | |
| - uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1 | |
| id: rp | |
| with: | |
| skip-github-release: true | |
| token: ${{ secrets.RELEASE_PLEASE_TOKEN }} | |
| - name: Create GitHub Release | |
| # release_created is still set to true with skip-github-release: true | |
| # (the action creates the tag but skips the GitHub release API call). | |
| # Also check tag_name as a guard against future behavior changes. | |
| if: ${{ steps.rp.outputs.release_created == 'true' && steps.rp.outputs.tag_name != '' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }} | |
| TAG: ${{ steps.rp.outputs.tag_name }} | |
| run: | | |
| set -e | |
| VERSION="${TAG#v}" | |
| ESCAPED_VERSION=$(printf '%s' "${VERSION}" | sed 's/\./\\./g') | |
| NOTES='' | |
| if [ -f CHANGELOG.md ]; then | |
| NOTES=$(awk "/^## \[${ESCAPED_VERSION}\]/{found=1; next} /^## \[/{if(found) exit} found{print}" CHANGELOG.md || true) | |
| fi | |
| INSTALL=$(printf '%s\n' \ | |
| '# Installation' \ | |
| '' \ | |
| '```bash' \ | |
| '# Homebrew (macOS)' \ | |
| 'brew install --cask thedavidweng/tap/money' \ | |
| '' \ | |
| '# Go (cross-platform)' \ | |
| "go install github.com/thedavidweng/money/cmd/money@${TAG}" \ | |
| '```') | |
| FULL_NOTES=$(printf '%s\n\n%s' "${NOTES:-Release $TAG}" "$INSTALL") | |
| if gh release view "$TAG" &>/dev/null; then | |
| gh release edit "$TAG" --notes "${FULL_NOTES}" | |
| else | |
| gh release create "$TAG" \ | |
| --title "$TAG" \ | |
| --notes "${FULL_NOTES}" | |
| fi |