-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (82 loc) · 2.84 KB
/
release.yml
File metadata and controls
95 lines (82 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Release
on:
push:
branches:
- main
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
inputs:
skip_scrape:
description: 'Skip scraping and just publish current version'
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@v6
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: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.skip_scrape != 'true') }}
id: scrape
run: |
bun run scrape:prod
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 patch 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.$((PATCH + 1))"
# 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 }}