WannierDatasets / release.sh
qiaojunfeng's picture
Add newlines to output
341e86d
#!/bin/bash
# This script automates the process of releasing a new version of the dataset.
# Usage: ./release.sh <major|minor|patch>
set -e
# 1. Make sure you have git commit all the changes
if test -n "$(git status --porcelain)"; then
echo "Please commit all changes before running this script."
exit 1
fi
# and the git branch should be `main`
if [[ $(git branch --show-current) != "main" ]]; then
echo "Please run this script on the main branch."
exit 1
fi
# 2. Decide the next version number--which component to bump?
if [ -z "$1" ]; then
echo "Please provide the version component to bump (major, minor, patch)."
exit 2
fi
if [ "$1" != "major" ] && [ "$1" != "minor" ] && [ "$1" != "patch" ]; then
echo "Invalid version component. Use major, minor, or patch."
exit 2
fi
C=$1
OLD_VERSION=`bump-my-version show current_version`
NEW_VERSION=`bump-my-version show new_version --increment $C`
# bump-my-version bump --dry-run -v $C
echo -n "Bumping version $C, $OLD_VERSION → $NEW_VERSION. Are you sure? (y/N) "
read -r answer
if [[ ! $answer =~ ^[Yy]$ ]]; then
echo "Aborting."
exit 3
fi
# 3. Git fetch to make sure the `artifacts` branch is up to date
DEPLOY_BRANCH=artifacts
git fetch origin $DEPLOY_BRANCH:$DEPLOY_BRANCH
# Then make tarballs, which will compare against the `artifacts` branch
# and create tarballs only for the new/changed datasets
echo -n "Create artifacts tarballs. Are you sure? (y/N) "
read -r answer
if [[ ! $answer =~ ^[Yy]$ ]]; then
echo "Aborting."
exit 4
fi
# ./make_artifacts.jl dryrun
./make_artifacts.jl
mv Artifacts.toml artifacts/
# 4. Auto bump the version & create git tag with bump-my-version
# https://github.com/callowayproject/bump-my-version
bump-my-version bump $C
# 5. Upload tarballs to huggingface `artifacts` branch
echo -n "Upload artifacts to huggingface. Are you sure? (y/N) "
read -r answer
if [[ ! $answer =~ ^[Yy]$ ]]; then
echo "Aborting."
exit 5
fi
ARTIFACTS_DIR=artifacts
COMMIT_MSG="Update artifacts v$OLD_VERSION → v$NEW_VERSION"
# list of tarballs
COMMIT_DESC=`find "$ARTIFACTS_DIR" -type f -exec basename {} \;`
huggingface-cli upload \
atomology/WannierDatasets $ARTIFACTS_DIR . \
--repo-type dataset \
--revision $DEPLOY_BRANCH \
--include "*" \
--commit-message "$COMMIT_MSG" \
--commit-description "$COMMIT_DESC"
# also push tags
git push --tags
# and fetch the artifacts branch
git fetch origin $DEPLOY_BRANCH:$DEPLOY_BRANCH
# 6. Check results
echo -e "\n\n\n" # Add some newlines for readability
echo "Upload complete. Checking results at"
echo "https://huggingface.co/datasets/atomology/WannierDatasets/tree/$DEPLOY_BRANCH"
echo "https://huggingface.co/datasets/atomology/WannierDatasets/blob/$DEPLOY_BRANCH/Artifacts.toml"