]> git.lizzy.rs Git - rust.git/blob - .github/deploy.sh
Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' 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 cp util/gh-pages/script.js out/master
12 cp util/gh-pages/lints.json out/master
13
14 if [[ -n $TAG_NAME ]]; then
15   echo "Save the doc for the current tag ($TAG_NAME) and point stable/ to it"
16   cp -Tr out/master "out/$TAG_NAME"
17   rm -f out/stable
18   ln -s "$TAG_NAME" out/stable
19 fi
20
21 if [[ $BETA = "true" ]]; then
22   echo "Update documentation for the beta release"
23   cp -r out/master/* out/beta
24 fi
25
26 # Generate version index that is shown as root index page
27 cp util/gh-pages/versions.html out/index.html
28
29 echo "Making the versions.json file"
30 python3 ./util/versions.py out
31
32 # Now let's go have some fun with the cloned repo
33 cd out
34 git config user.name "GHA CI"
35 git config user.email "gha@ci.invalid"
36
37 if [[ -n $TAG_NAME ]]; then
38   # track files, so that the following check works
39   git add --intent-to-add "$TAG_NAME"
40   if git diff --exit-code --quiet -- $TAG_NAME/; then
41     echo "No changes to the output on this push; exiting."
42     exit 0
43   fi
44   # Add the new dir
45   git add "$TAG_NAME"
46   # Update the symlink
47   git add stable
48   # Update versions file
49   git add versions.json
50   git commit -m "Add documentation for ${TAG_NAME} release: ${SHA}"
51 elif [[ $BETA = "true" ]]; then
52   if git diff --exit-code --quiet -- beta/; then
53     echo "No changes to the output on this push; exiting."
54     exit 0
55   fi
56   git add beta
57   git commit -m "Automatic deploy to GitHub Pages (beta): ${SHA}"
58 else
59   if git diff --exit-code --quiet; then
60     echo "No changes to the output on this push; exiting."
61     exit 0
62   fi
63   git add .
64   git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
65 fi
66
67 git push "$SSH_REPO" "$TARGET_BRANCH"