]> git.lizzy.rs Git - rust.git/blob - .github/deploy.sh
Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup
[rust.git] / .github / deploy.sh
1 #!/bin/bash
2
3 set -ex
4
5 echo "Removing the current docs for master"
6 rm -rf out/master/ || exit 0
7
8 echo "Making the docs for master"
9 mkdir out/master/
10 cp util/gh-pages/index.html out/master
11 python3 ./util/export.py out/master/lints.json
12
13 if [[ -n $TAG_NAME ]]; then
14   echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"
15   cp -r out/master "out/$TAG_NAME"
16   rm -f out/stable
17   ln -s "$TAG_NAME" out/stable
18 fi
19
20 if [[ $BETA = "true" ]]; then
21   echo "Update documentation for the beta release"
22   cp -r out/master out/beta
23 fi
24
25 # Generate version index that is shown as root index page
26 cp util/gh-pages/versions.html out/index.html
27
28 echo "Making the versions.json file"
29 python3 ./util/versions.py out
30
31 cd out
32 # Now let's go have some fun with the cloned repo
33 git config user.name "GHA CI"
34 git config user.email "gha@ci.invalid"
35
36 if git diff --exit-code --quiet; then
37   echo "No changes to the output on this push; exiting."
38   exit 0
39 fi
40
41 if [[ -n $TAG_NAME ]]; then
42   # Add the new dir
43   git add "$TAG_NAME"
44   # Update the symlink
45   git add stable
46   # Update versions file
47   git add versions.json
48   git commit -m "Add documentation for ${TAG_NAME} release: ${SHA}"
49 elif [[ $BETA = "true" ]]; then
50   git add beta
51   git commit -m "Automatic deploy to GitHub Pages (beta): ${SHA}"
52 else
53   git add .
54   git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
55 fi
56
57 git push "$SSH_REPO" "$TARGET_BRANCH"