diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-asia-ratings-latest.yml new file mode 100644 index 000000000..e1ebeae35 --- /dev/null +++ b/.github/workflows/cd-asia-ratings-latest.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Latest + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --latest diff --git a/.github/workflows/cd-asia-ratings-leaderboards.yml b/.github/workflows/cd-asia-ratings-leaderboards.yml new file mode 100644 index 000000000..cba5f0734 --- /dev/null +++ b/.github/workflows/cd-asia-ratings-leaderboards.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Leaderboards + +on: + schedule: + - cron: '0 17 * * *' + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia diff --git a/.github/workflows/cd-docs.yml b/.github/workflows/cd-docs.yml index 0141cef17..4dffb3fc0 100644 --- a/.github/workflows/cd-docs.yml +++ b/.github/workflows/cd-docs.yml @@ -16,18 +16,14 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - strategy: - matrix: - node-version: [18.x] - steps: - - name: Get code + - name: Checkout uses: actions/checkout@v3 - name: Use node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: 18 cache: 'npm' - name: Install Yarn diff --git a/.github/workflows/cd-eu-ratings-latest.yml b/.github/workflows/cd-eu-ratings-latest.yml new file mode 100644 index 000000000..62171b2a9 --- /dev/null +++ b/.github/workflows/cd-eu-ratings-latest.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Latest + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --latest diff --git a/.github/workflows/cd-eu-ratings-leaderboards.yml b/.github/workflows/cd-eu-ratings-leaderboards.yml new file mode 100644 index 000000000..293a6365d --- /dev/null +++ b/.github/workflows/cd-eu-ratings-leaderboards.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Leaderboards + +on: + schedule: + - cron: '0 23 * * *' + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu diff --git a/.github/workflows/cd-host.yml b/.github/workflows/cd-host.yml index 8ed9ceb7b..066510672 100644 --- a/.github/workflows/cd-host.yml +++ b/.github/workflows/cd-host.yml @@ -12,15 +12,12 @@ concurrency: jobs: host: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] steps: - name: Use node uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node-version }} + node-version: 18 - name: Download release assets run: | diff --git a/.github/workflows/cd-na-ratings-latest.yml b/.github/workflows/cd-na-ratings-latest.yml new file mode 100644 index 000000000..ff7ab3470 --- /dev/null +++ b/.github/workflows/cd-na-ratings-latest.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Latest + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --latest diff --git a/.github/workflows/cd-na-ratings-leaderboards.yml b/.github/workflows/cd-na-ratings-leaderboards.yml new file mode 100644 index 000000000..414e143a3 --- /dev/null +++ b/.github/workflows/cd-na-ratings-leaderboards.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Leaderboards + +on: + schedule: + - cron: '0 5 * * *' + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na diff --git a/.github/workflows/cd-ratings-leaderboard-na.yml b/.github/workflows/cd-ratings-leaderboard-na.yml deleted file mode 100644 index 01d668990..000000000 --- a/.github/workflows/cd-ratings-leaderboard-na.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: CD Ratings Leaderboard North America - -on: - schedule: - - cron: '0 5 * * *' - -jobs: - host: - runs-on: ubuntu-latest - - steps: - - name: Get code - uses: actions/checkout@v3 - - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 156d57820..18a7f4427 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -11,10 +11,6 @@ jobs: name: Build runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] - steps: - name: Checkout uses: actions/checkout@v3 @@ -22,7 +18,7 @@ jobs: - name: Use node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: 18 cache: 'npm' - name: Install Yarn diff --git a/docs/changelogs/1.10.2.md b/docs/changelogs/1.10.2.md new file mode 100644 index 000000000..df1ef1637 --- /dev/null +++ b/docs/changelogs/1.10.2.md @@ -0,0 +1,10 @@ +# Blitzkrieg 1.10.2 + +The experiment in Blitzkrieg `1.10.1` was a bit of a failure so here are a few changes. + +## Fixes + +- North American leaderboards are now saved in the `na` directory instead of `asia` +- Dependencies are now installed before the script is ran +- Added leaderboards for all regions +- All regions now have their own separate cron timings diff --git a/package.json b/package.json index 7a8020c04..510aef5a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.10.0", + "version": "1.10.2", "description": "", "main": "src/server.ts", "type": "module", diff --git a/scripts/generateRatingsLeaderboard.js b/scripts/generateRatingsLeaderboard.js index e1d4c59c1..b39f732dd 100644 --- a/scripts/generateRatingsLeaderboard.js +++ b/scripts/generateRatingsLeaderboard.js @@ -4,12 +4,17 @@ import { argv, env } from 'process'; import commitMultipleFiles from './commitMultipleFiles.js'; /* -For Central North American Time (UTC-5), use 0 5 * * *. -For Central European Time (UTC+1), use 0 23 * * *. -For Central Asia Standard Time (UTC+7), use 0 17 * * *. -*/ + * Central North American Time (UTC-5): use 0 5 * * *. + * Central European Time (UTC+1): use 0 23 * * *. + * Central Asia Standard Time (UTC+7): use 0 17 * * *. + * + * :region/ratings/:season/info.json: season info like rewards, start & end time, etc. + * :region/ratings/:season/latest.json: the absolute latest leaderboard recorded at UTC+0 midnight + * :region/ratings/:season/leaderboards/:time.json: collection of all recorded leaderboards at local midnights + */ const publish = argv.includes('--publish'); +const latest = argv.includes('--latest'); const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1]; if (!server) throw new Error('Region parameter not specified'); @@ -96,8 +101,10 @@ if (publish) { const time = Math.round(Date.now() / 1000); const normalizedServer = server === 'na' ? 'com' : server; - const infoPath = `${normalizedServer}/ratings/seasons/${info.current_season}.json`; - const leaderboardPath = `${normalizedServer}/ratings/leaderboards/${info.current_season}/${time}.json`; + const infoPath = `${normalizedServer}/ratings/${info.current_season}/info.json`; + const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${ + latest ? 'latest.json' : `leaderboards/${time}.json` + }`; const infoJSON = JSON.stringify(info); console.log(`Publishing to season ${info.current_season}...`);