2022-10-12 21:27:56 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Builds the final versions of the book and then upload the results to various
|
|
|
|
# locations.
|
|
|
|
|
|
|
|
# Set up logging.
|
|
|
|
log() { echo "️🚢 $(basename $0): $@"; }
|
|
|
|
|
|
|
|
# Move into the root folder.
|
|
|
|
cd $(dirname $(dirname $0))
|
|
|
|
|
|
|
|
# Perform the basic environment checks and setup.
|
|
|
|
./scripts/setup.sh || exit 1
|
|
|
|
./scripts/check-env-bucket.sh || exit 1
|
|
|
|
|
|
|
|
# Clean up old versions of the file.
|
2022-10-12 21:41:53 +00:00
|
|
|
log "cleaning up prior versions which may not match versions"
|
2022-10-12 21:27:56 +00:00
|
|
|
rm -f dmoonfire*
|
|
|
|
|
|
|
|
# Perform the release process.
|
|
|
|
log "performing semantic release"
|
2022-10-12 22:28:40 +00:00
|
|
|
export GIT_CREDENTIALS="dmoonfire:$GITEA_TOKEN"
|
2022-10-13 01:47:28 +00:00
|
|
|
npx semantic-release || exit 1
|
2022-10-12 21:27:56 +00:00
|
|
|
|
|
|
|
# Create a tarball of the output files and upload them to S3.
|
|
|
|
if ls dmoonfire* &> /dev/null
|
|
|
|
then
|
|
|
|
log "packaging output into a tarball"
|
|
|
|
tar -cjf i-will-hurt-you-only-once.tar.bz2 dmoonfire*
|
|
|
|
|
2022-10-12 22:28:40 +00:00
|
|
|
log "uploading tarball to bucket"
|
2022-10-13 02:53:42 +00:00
|
|
|
export AWS_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID
|
|
|
|
export AWS_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY
|
|
|
|
export AWS_ENDPOINT=$S3_ENDPOINT
|
|
|
|
export AWS_BUCKET=$S3_BUCKET
|
|
|
|
s3cmd --access_key=$S3_ACCESS_KEY_ID --access_token=$S3_SECRET_ACCESS_KEY --host=$S3_ENDPOINT --host-bucket=$S3_ENDPOINT -P put i-will-hurt-you-only-once.tar.bz2 s3://$S3_BUCKET || exit 1
|
2022-10-12 21:27:56 +00:00
|
|
|
else
|
|
|
|
log "no files to upload"
|
|
|
|
fi
|
|
|
|
|