2021-08-25 17:56:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
DRY_RUN=true
|
2021-08-25 19:04:06 +02:00
|
|
|
SKIP_CRATE_PUBLISH=false
|
2021-08-25 17:56:25 +02:00
|
|
|
|
|
|
|
POSITIONAL=()
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
--execute)
|
|
|
|
DRY_RUN=false
|
|
|
|
shift # past argument
|
|
|
|
;;
|
|
|
|
--bump)
|
|
|
|
BUMP="$2"
|
|
|
|
shift # past argument
|
|
|
|
shift # past value
|
|
|
|
;;
|
2021-08-25 19:04:06 +02:00
|
|
|
--skip-publish)
|
|
|
|
SKIP_CRATE_PUBLISH=true
|
|
|
|
shift # past argument
|
|
|
|
;;
|
2021-08-25 17:56:25 +02:00
|
|
|
*) # unknown option
|
|
|
|
POSITIONAL+=("$1") # save it in an array for later
|
|
|
|
shift # past argument
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2022-12-05 17:50:37 +01:00
|
|
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
|
|
|
|
if [[ "$current_branch" != "master" ]]; then
|
|
|
|
echo "You must be on the master branch to run this script"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
git pull
|
|
|
|
|
2021-08-25 17:56:25 +02:00
|
|
|
echo """
|
|
|
|
This will do everything needed to release a new version:
|
|
|
|
- bump the version number
|
|
|
|
- create a git tag
|
|
|
|
- build all artifacts
|
|
|
|
- publish crates on crates.io
|
|
|
|
- upload artifacts to a new release on github
|
|
|
|
"""
|
|
|
|
if [ "$DRY_RUN" = true ]; then
|
2021-11-14 17:44:29 +01:00
|
|
|
echo "This is a dry run, nothing will be done. Artifacts will be built, but not published. Use --execute to do it for real."
|
2021-08-25 17:56:25 +02:00
|
|
|
else
|
|
|
|
echo "This is not a dry run. This is the real deal!"
|
|
|
|
fi
|
|
|
|
echo "Press any key to continue..."
|
|
|
|
read -n 1 -s -r
|
|
|
|
|
|
|
|
params=()
|
|
|
|
if [[ $DRY_RUN == false ]]; then
|
|
|
|
params+=(--execute)
|
|
|
|
fi
|
|
|
|
if [[ $BUMP != "" ]]; then
|
|
|
|
params+=(--bump "$BUMP")
|
2022-06-25 17:24:26 +02:00
|
|
|
params+=(--bump-dependencies "$BUMP")
|
2021-08-25 17:56:25 +02:00
|
|
|
fi
|
2021-08-25 19:04:06 +02:00
|
|
|
if [[ $SKIP_CRATE_PUBLISH == true ]]; then
|
2022-06-25 17:24:26 +02:00
|
|
|
params+=(--no-publish)
|
2021-08-25 19:04:06 +02:00
|
|
|
fi
|
2023-06-29 23:50:14 +02:00
|
|
|
cargo smart-release --update-crates-index --no-changelog --no-publish --no-push "${params[@]}"
|
2021-08-25 17:56:25 +02:00
|
|
|
|
2023-06-29 14:33:34 +02:00
|
|
|
#echo "Verify that the publish succeeded, and Press any key to continue..."
|
|
|
|
# read -n 1 -s -r
|
2022-06-25 15:01:00 +02:00
|
|
|
|
2022-06-12 15:46:44 +02:00
|
|
|
if ! which cross; then
|
|
|
|
echo "cross not found, installing..."
|
|
|
|
cargo install cross
|
|
|
|
fi
|
|
|
|
|
2022-06-25 15:01:00 +02:00
|
|
|
BUILD_TARGET="x86_64-unknown-linux-musl"
|
2023-06-22 22:42:44 +02:00
|
|
|
BUILD_TARGET2="x86_64-pc-windows-gnu"
|
2022-06-25 15:01:00 +02:00
|
|
|
cross build --release "--target=$BUILD_TARGET"
|
2023-06-22 22:42:44 +02:00
|
|
|
cross build --release "--target=$BUILD_TARGET2"
|
2021-11-14 17:44:29 +01:00
|
|
|
|
2021-08-25 17:56:25 +02:00
|
|
|
./scripts/package-deb.sh
|
|
|
|
|
2023-06-23 21:21:46 +02:00
|
|
|
BIN_PATH="target/$BUILD_TARGET/release/steamguard"
|
|
|
|
BIN_PATH2="target/$BUILD_TARGET2/release/steamguard.exe"
|
2021-08-25 17:56:25 +02:00
|
|
|
RAW_VERSION="$("$BIN_PATH" --version | cut -d " " -f 2)"
|
2021-09-01 14:44:23 +02:00
|
|
|
TAGGED_VERSION="$(git tag | grep "^v" | tail -n 1 | tr -d v)"
|
|
|
|
if [[ "v$RAW_VERSION" != "v$TAGGED_VERSION" ]]; then
|
|
|
|
echo "Version mismatch: $RAW_VERSION != $TAGGED_VERSION"
|
|
|
|
fi
|
2021-08-25 17:56:25 +02:00
|
|
|
VERSION="v$RAW_VERSION"
|
|
|
|
|
|
|
|
if [[ $DRY_RUN == false ]]; then
|
2021-08-25 18:18:27 +02:00
|
|
|
if [[ $(gh release list | grep -i "Draft" | grep -i "$VERSION" && echo "true" || echo "false") == "true" ]]; then
|
|
|
|
gh release delete --yes "$VERSION"
|
|
|
|
fi
|
2023-06-22 22:42:44 +02:00
|
|
|
gh release create "$VERSION" --title "$VERSION" --draft "$BIN_PATH" "$BIN_PATH2" "./steamguard-cli_$RAW_VERSION-0.deb"
|
2021-08-25 17:56:25 +02:00
|
|
|
fi
|
2023-06-29 14:33:34 +02:00
|
|
|
|
|
|
|
echo "It's now safe to run cargo publish for the affected crates."
|