Skip to content

Commit

Permalink
convert release script to rust
Browse files Browse the repository at this point in the history
  • Loading branch information
rlane committed Jan 31, 2023
1 parent d5462e1 commit a9a5874
Show file tree
Hide file tree
Showing 8 changed files with 474 additions and 154 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ target/
/flamegraph.svg
perf.data*
/scratch
/.secrets
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Parallelized release process.

### 0.34.0

- Added more Discord integrations.
Expand Down
4 changes: 3 additions & 1 deletion scripts/deploy-compiler-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
cd $(realpath $(dirname $0))/..
PROJECT=us-west1-docker.pkg.dev/oort-319301
CONTAINER_IMAGE=$PROJECT/services/oort_compiler_service
ZONE=us-west1-b
docker tag oort_compiler_service:latest $CONTAINER_IMAGE
docker push $CONTAINER_IMAGE
gcloud run deploy oort-compiler-service \
Expand All @@ -14,7 +15,8 @@ gcloud run deploy oort-compiler-service \
--concurrency 1 \
--max-instances 3 \
--service-account=oort-compiler-service@oort-319301.iam.gserviceaccount.com
gcloud compute ssh server-1 --command="docker image prune --force" || true
gcloud compute ssh server-1 --zone $ZONE --command="docker image prune --force" || true
gcloud compute instances update-container \
server-1 \
--zone $ZONE \
--container-image $CONTAINER_IMAGE
14 changes: 0 additions & 14 deletions scripts/push.sh

This file was deleted.

138 changes: 1 addition & 137 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,138 +1,2 @@
#!/bin/bash -eu
cd $(realpath $(dirname $0))/..

function usage() {
echo "Usage: $0 -[wctldsnh]"
echo
echo " -w: Push app"
echo " -c: Push compiler service"
echo " -t: Push telemetry service"
echo " -l: Push leaderboard service"
echo " -d: Push docs"
echo " -s: Skip bumping version"
echo " -n: Dry run, skip deploying"
echo " -h: Display this message"
}

BUMP_VERSION=1
PUSH_ALL=1
PUSH_APP=0
PUSH_COMPILER_SERVICE=0
PUSH_TELEMETRY_SERVICE=0
PUSH_LEADERBOARD_SERVICE=0
PUSH_DOC=0
DRY_RUN=0
while getopts "wctldsnh" option; do
case $option in
w) PUSH_ALL=0; PUSH_APP=1;;
c) PUSH_ALL=0; PUSH_COMPILER_SERVICE=1;;
t) PUSH_ALL=0; PUSH_TELEMETRY_SERVICE=1;;
l) PUSH_ALL=0; PUSH_LEADERBOARD_SERVICE=1;;
d) PUSH_ALL=0; PUSH_DOC=1;;
s) BUMP_VERSION=0;;
n) DRY_RUN=1;;
h) usage; exit;;
\?) usage; exit;;
esac
done

if ! git diff HEAD --quiet; then
echo "Uncommitted changes, halting release"
git diff HEAD
exit 1
fi

[ -e scratch/secrets.sh ] && source scratch/secrets.sh

if [[ $BUMP_VERSION -eq 1 ]]; then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $BRANCH != master ]]; then
echo "Not on master branch, halting release"
exit 1
fi

if head -n1 CHANGELOG.md | grep -q '^#'; then
echo "Changelog empty, halting release"
exit 1
fi

echo 'Changelog:'
sed '/^#/Q' CHANGELOG.md

(cd frontend && cargo workspaces version --all --force='*' --no-git-commit --yes)
VERSION=$(egrep '^version = ".*"$' frontend/app/Cargo.toml | head -n1 | egrep -o '[0-9][^"]*')
sed -i "1s;^;### ${VERSION}\n\n;" CHANGELOG.md
for WS in tools shared services; do
(cd $WS && cargo workspaces version --all --force='*' --no-git-commit --yes custom $VERSION)
done
for WS in frontend tools shared services; do
(cd $WS && cargo update -w)
done
git commit -n -a -m "bump version to $VERSION"
git tag v$VERSION
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_APP -eq 1 ]]; then
echo "Building frontend"
(
set -x
cd frontend
cargo build --release --bins --target wasm32-unknown-unknown
cd app
rm -rf dist
trunk build --release
)
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_COMPILER_SERVICE -eq 1 ]]; then
scripts/build-compiler-service-docker-image.sh
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_TELEMETRY_SERVICE -eq 1 ]]; then
scripts/build-telemetry-service-docker-image.sh
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_LEADERBOARD_SERVICE -eq 1 ]]; then
scripts/build-leaderboard-service-docker-image.sh
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_DOC -eq 1 ]]; then
(cd shared && cargo doc -p oort_api)
fi

if [[ $DRY_RUN -eq 1 ]]; then
echo "Dry run, exiting"
exit 0
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_APP -eq 1 ]]; then
echo "Deploying frontend"
(
cd firebase
eval "$(fnm env)"
set -x
fnm use
npx firebase deploy
)
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_COMPILER_SERVICE -eq 1 ]]; then
scripts/deploy-compiler-service.sh
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_TELEMETRY_SERVICE -eq 1 ]]; then
scripts/deploy-telemetry-service.sh
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_LEADERBOARD_SERVICE -eq 1 ]]; then
scripts/deploy-leaderboard-service.sh
fi

if [[ $PUSH_ALL -eq 1 || $PUSH_DOC -eq 1 ]]; then
(cd shared && cargo publish -p oort_api)
fi

if [[ $BUMP_VERSION -eq 1 ]]; then
scripts/send-changelog-discord-message.sh
git push
fi
time cargo run --manifest-path tools/Cargo.toml --bin release -- "$@"
65 changes: 63 additions & 2 deletions tools/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ rand = "0.8.5"
rand_chacha = "0.3.1"
rand_seeder = "0.2.3"
rusqlite = { version = "0.28.0", features = ["bundled"] }
anyhow = "1.0.68"
shell-words = "1.1.0"
toml = "0.7.0"

[patch.crates-io]
rand_seeder = { git = "https://github.com/rlane/seeder", rev = "c39e58447f7c236fb98579a5d46e5668b92a3245" }
Expand Down
Loading

0 comments on commit a9a5874

Please sign in to comment.