2019-12-22 16:23:11 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2019-12-26 15:25:43 +00:00
|
|
|
|
2020-02-07 04:04:39 +00:00
|
|
|
CRATES_INDEX_PATH="/tmp/index.js"
|
2020-02-27 13:08:30 +00:00
|
|
|
CRATES_DATABASE_PATH="/tmp/db-dump.tar.gz"
|
2020-01-04 16:17:28 +00:00
|
|
|
BRANCH="now"
|
2019-12-22 16:23:11 +00:00
|
|
|
|
|
|
|
build() {
|
|
|
|
echo "Starting building crates-index..."
|
2020-02-25 07:24:07 +00:00
|
|
|
cd rust
|
2020-12-02 03:12:41 +00:00
|
|
|
RUST_BACKTRACE=full cargo run --release crates -p ${CRATES_DATABASE_PATH} -d ${CRATES_INDEX_PATH}
|
2019-12-22 16:23:11 +00:00
|
|
|
echo "{\"version\": $(date +%s)}" > /tmp/version.json
|
2020-02-25 07:24:07 +00:00
|
|
|
cd ..
|
2019-12-22 16:23:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
upload() {
|
|
|
|
echo "Starting uploading crates-index..."
|
2019-12-27 10:14:21 +00:00
|
|
|
git config --global url."https://".insteadOf git://
|
|
|
|
git config --global url."https://github.com/".insteadOf git@github.com:
|
2019-12-22 16:23:11 +00:00
|
|
|
|
2019-12-27 10:14:21 +00:00
|
|
|
git checkout ${BRANCH}
|
2019-12-26 15:25:43 +00:00
|
|
|
if [[ ! -d "crates" ]]
|
2019-12-22 16:23:11 +00:00
|
|
|
then
|
|
|
|
mkdir crates
|
|
|
|
fi
|
2019-12-31 07:46:23 +00:00
|
|
|
cp -vr "${CRATES_INDEX_PATH}" /tmp/version.json crates/
|
2019-12-22 16:23:11 +00:00
|
|
|
|
|
|
|
git config user.name "GitHub Actions"
|
|
|
|
git config user.email "github-actions-bot@users.noreply.github.com"
|
|
|
|
git add crates/
|
2020-01-13 13:31:02 +00:00
|
|
|
git commit --amend -m "Upload latest crates index"
|
2019-12-31 07:46:23 +00:00
|
|
|
git push --force "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" ${BRANCH}
|
2019-12-22 16:23:11 +00:00
|
|
|
|
|
|
|
echo "Upload complete"
|
|
|
|
}
|
|
|
|
|
|
|
|
build
|
|
|
|
upload
|