rust-search-extension/scripts/deploy-crates-index.sh

38 lines
984 B
Bash
Raw Normal View History

2019-12-22 16:23:11 +00:00
#!/usr/bin/env bash
set -e
CRATES_INDEX_PATH="/tmp/index.js"
2020-02-27 13:08:30 +00:00
CRATES_DATABASE_PATH="/tmp/db-dump.tar.gz"
BRANCH="now"
2019-12-22 16:23:11 +00:00
build() {
echo "Starting building crates-index..."
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
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}
if [[ ! -d "crates" ]]
2019-12-22 16:23:11 +00:00
then
mkdir crates
fi
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"
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