diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa481d4..4047d63 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,8 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 - - name: Create DB - run: ./create-qrank-db + # - name: Create DB + # run: ./create-qrank-db - # TODO: overwrite the existing release's binary with the new file + - name: Publish DB + run: ./publish-qrank-db diff --git a/README.md b/README.md index f5ee891..46f7ef4 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,4 @@ They publish the dataset as a gzipped CSV file, [qrank.csv.gz](https://qrank.wmc This repository republishes the data as a SQLite database with an index, so that random-access queries are fast. You can download [qrank.db here](https://github.com/hikeratlas/qrank/releases/download/latest/qrank.db). + diff --git a/create-qrank-db b/create-qrank-db index a758463..0d3cee3 100755 --- a/create-qrank-db +++ b/create-qrank-db @@ -37,7 +37,7 @@ vacuum; EOF } -ensure_qrank_csv +time ensure_qrank_csv rm -f qrank.db -do_the_thing | sqlite3 qrank.db +time ( do_the_thing | sqlite3 qrank.db ) diff --git a/publish-qrank-db b/publish-qrank-db new file mode 100755 index 0000000..ab9252d --- /dev/null +++ b/publish-qrank-db @@ -0,0 +1,39 @@ +#!/bin/bash +set -euo pipefail + +RELEASE_ID=137136562 + +list_existing() { + curl --silent --fail -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/hikeratlas/qrank/releases/${RELEASE_ID}/assets" | + jq .[].id +} + +delete_existing() { + while read -r asset_id; do + echo "deleting ${asset_id}" + curl --silent --fail -L \ + -X DELETE \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/hikeratlas/qrank/releases/assets/${asset_id}" + done < <(list_existing) +} + +publish() { + curl --silent --fail -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: application/octet-stream" \ + "https://uploads.github.com/repos/hikeratlas/qrank/releases/${RELEASE_ID}/assets?name=qrank.db" \ + --data-binary "@README.md" +} + +delete_existing +publish