Bump pkg-fetch #51
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: Bump pkg-fetch | |
| on: | |
| schedule: | |
| - cron: '0 8 * * *' # Daily at 8am UTC | |
| workflow_dispatch: {} | |
| jobs: | |
| bump: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js 22 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.x | |
| cache: 'yarn' | |
| - name: Check for new version | |
| id: check | |
| run: | | |
| CURRENT=$(node -p "require('./package.json').dependencies['@yao-pkg/pkg-fetch']") | |
| LATEST=$(npm info @yao-pkg/pkg-fetch version) | |
| echo "current=$CURRENT" >> $GITHUB_OUTPUT | |
| echo "latest=$LATEST" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT" != "$LATEST" ]; then | |
| echo "needs_update=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "needs_update=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get Node.js versions from changelog | |
| if: steps.check.outputs.needs_update == 'true' | |
| id: nodejs | |
| run: | | |
| VERSION="${{ steps.check.outputs.latest }}" | |
| # Fetch CHANGELOG.md from pkg-fetch repo | |
| CHANGELOG=$(curl -sL "https://raw.githubusercontent.com/yao-pkg/pkg-fetch/main/CHANGELOG.md") | |
| # Extract the section for this version and get Node.js patch versions | |
| ALL_VERSIONS=$(echo "$CHANGELOG" | \ | |
| sed -n "/## \[$VERSION\]/,/## \[/p" | \ | |
| grep -oP 'add v\K[0-9]+\.[0-9]+\.[0-9]+' | \ | |
| sort -t. -k1,1n -k2,2n -k3,3n | \ | |
| uniq) | |
| if [ -z "$ALL_VERSIONS" ]; then | |
| echo "pr_title=feat: bump fetch $VERSION" >> $GITHUB_OUTPUT | |
| echo "body_versions=No new Node.js patches in this release." >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Keep only the highest version per Node.js major | |
| LATEST_PER_MAJOR=$(echo "$ALL_VERSIONS" | \ | |
| awk -F. '{major[$1]=$0} END {for (m in major) print major[m]}' | \ | |
| sort -t. -k1,1n) | |
| TITLE_VERSIONS=$(echo "$LATEST_PER_MAJOR" | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g') | |
| echo "pr_title=feat: bump fetch $VERSION with nodejs $TITLE_VERSIONS" >> $GITHUB_OUTPUT | |
| { | |
| echo "body_versions<<EOF" | |
| echo "$ALL_VERSIONS" | sed 's/^/- /' | |
| echo "EOF" | |
| } >> $GITHUB_OUTPUT | |
| - name: Update dependency | |
| if: steps.check.outputs.needs_update == 'true' | |
| run: yarn add @yao-pkg/pkg-fetch@${{ steps.check.outputs.latest }} --exact | |
| - name: Create Pull Request | |
| if: steps.check.outputs.needs_update == 'true' | |
| id: cpr | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: '${{ steps.nodejs.outputs.pr_title }}' | |
| branch: 'bump-pkg-fetch-${{ steps.check.outputs.latest }}' | |
| delete-branch: true | |
| title: '${{ steps.nodejs.outputs.pr_title }}' | |
| body: | | |
| Bump `@yao-pkg/pkg-fetch` from ${{ steps.check.outputs.current }} to ${{ steps.check.outputs.latest }} | |
| ### Node.js patches included | |
| ${{ steps.nodejs.outputs.body_versions }} | |
| [Full changelog](https://github.com/yao-pkg/pkg-fetch/blob/main/CHANGELOG.md) | |
| labels: | | |
| dependencies | |
| workflow-bump | |
| base: main | |
| draft: false | |
| - name: Check outputs | |
| if: steps.check.outputs.needs_update == 'true' | |
| run: | | |
| echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
| echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |