Release #10
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 | |
| on: | |
| schedule: | |
| - cron: '0 0 1 * *' # Run monthly | |
| workflow_dispatch: | |
| inputs: | |
| skip_scrape: | |
| description: 'Skip scraping and just publish current version' | |
| type: boolean | |
| default: false | |
| force_scrape: | |
| description: 'Force scrape without using cache' | |
| type: boolean | |
| default: false | |
| force_release: | |
| description: 'Force release even if no changes' | |
| type: boolean | |
| default: false | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Check if current version is released | |
| id: check_release | |
| run: | | |
| VERSION=$(jq -r .version package.json) | |
| if gh release view v$VERSION &>/dev/null; then | |
| echo "version_exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "version_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Scrape for updates | |
| if: | | |
| inputs.skip_scrape != true && | |
| (steps.check_release.outputs.version_exists == 'true' || | |
| github.event_name == 'workflow_dispatch') | |
| id: scrape | |
| run: | | |
| if [ "${{ inputs.force_scrape }}" = "true" ]; then | |
| bun run scrape:force | |
| else | |
| bun run scrape:prod | |
| fi | |
| if git diff --quiet data/; then | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Bump version and commit | |
| if: | | |
| steps.scrape.outputs.has_changes == 'true' || | |
| (github.event_name == 'workflow_dispatch' && | |
| inputs.force_release == 'true') | |
| run: | | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| # Bump minor version | |
| VERSION=$(jq -r .version package.json) | |
| MAJOR=$(echo $VERSION | cut -d. -f1) | |
| MINOR=$(echo $VERSION | cut -d. -f2) | |
| PATCH=$(echo $VERSION | cut -d. -f3) | |
| NEW_VERSION="$MAJOR.$((MINOR + 1)).0" | |
| # Update version in package.json | |
| jq ".version = \"$NEW_VERSION\"" package.json > temp.json && mv temp.json package.json | |
| git add data/ package.json | |
| git commit -m "chore: update dataset to version $NEW_VERSION" | |
| git tag "v$NEW_VERSION" | |
| git push --follow-tags | |
| - name: Publish to GitHub Packages | |
| if: | | |
| steps.scrape.outputs.has_changes == 'true' || | |
| steps.check_release.outputs.version_exists == 'false' || | |
| (github.event_name == 'workflow_dispatch' && | |
| inputs.force_release == 'true') | |
| run: | | |
| bun publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |