Compare Mapping and Bump Version #4
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: Compare Mapping and Bump Version | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # Run once a month at midnight on the first day | |
| - cron: "0 0 1 * *" | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| compare-and-bump: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version: lts/* | |
| cache: npm | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Compare with npm package | |
| id: compare | |
| run: | | |
| # Create temp directory and set paths | |
| TMP_DIR=$(mktemp -d) | |
| # Fetch package from npm and extract index.js | |
| PACKAGE_URL=$(npm view unicode-case-folding dist.tarball) | |
| curl -sL "$PACKAGE_URL" -o "$TMP_DIR/package.tgz" | |
| tar -xzf "$TMP_DIR/package.tgz" -C "$TMP_DIR" | |
| # Compare files and set output | |
| if diff -q "index.js" "$TMP_DIR/package/index.js"; then | |
| echo "result=same" >> $GITHUB_OUTPUT | |
| else | |
| echo "result=different" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Bump patch version | |
| if: steps.compare.outputs.result == 'different' | |
| run: | | |
| # Configure Git | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| # Get current version and bump patch | |
| npm version patch -m "Bump version to %s" | |
| npm publish --provenance | |
| # Push changes back to the repository | |
| git push |