File size: 2,781 Bytes
2b20330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c692b0b
 
 
 
 
 
 
2b20330
 
 
 
 
 
 
 
02d43ae
 
 
 
c692b0b
02d43ae
2b20330
 
 
 
 
 
 
 
 
 
 
cae8b8d
 
 
 
2b20330
 
341e86d
2b20330
 
89221eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/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"