File tree Expand file tree Collapse file tree 2 files changed +39
-9
lines changed Expand file tree Collapse file tree 2 files changed +39
-9
lines changed Original file line number Diff line number Diff line change 46
46
- uses : actions/checkout@v4
47
47
- name : Install Rust (rustup)
48
48
run : rustup update stable --no-self-update && rustup default stable
49
- - name : Build book
50
- run : cargo run -- build guide
51
49
- name : Deploy the User Guide to GitHub Pages using the gh-pages branch
52
- env :
53
- GITHUB_DEPLOY_KEY : ${{ secrets.GITHUB_DEPLOY_KEY }}
54
- run : |
55
- touch guide/book/.nojekyll
56
- curl -LsSf https://raw.githubusercontent.com/rust-lang/simpleinfra/master/setup-deploy-keys/src/deploy.rs | rustc - -o /tmp/deploy
57
- cd guide/book
58
- /tmp/deploy
50
+ run : ci/publish-guide.sh
59
51
publish :
60
52
name : Publish to crates.io
61
53
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # This publishes the user guide to GitHub Pages.
3
+ #
4
+ # If this is a pre-release, then it goes in a separate directory called "pre-release".
5
+ # Commits are amended to avoid keeping history which can balloon the repo size.
6
+ set -ex
7
+
8
+ cargo run --no-default-features -F search -- build guide
9
+
10
+ VERSION=$( cargo metadata --format-version 1 --no-deps | jq ' .packages[] | select(.name == "mdbook") | .version' )
11
+
12
+ if [[ " $VERSION " == * -* ]]; then
13
+ PRERELEASE=true
14
+ else
15
+ PRERELEASE=false
16
+ fi
17
+
18
+ git fetch origin gh-pages
19
+ git worktree add gh-pages gh-pages
20
+ git config user.name " Deploy from CI"
21
+ git config user.email " "
22
+ cd gh-pages
23
+ if [[ " $PRERELEASE " == " true" ]]
24
+ then
25
+ rm -rf pre-release
26
+ mv ../guide/book pre-release
27
+ git add pre-release
28
+ git commit --amend -m " Deploy $GITHUB_SHA pre-release to gh-pages"
29
+ else
30
+ # Delete everything except pre-release and .git.
31
+ find . -mindepth 1 -maxdepth 1 -not -name " pre-release" -not -name " .git" -exec rm -rf {} +
32
+ # Copy the guide here.
33
+ find ../guide/book/ -mindepth 1 -maxdepth 1 -exec mv {} . \;
34
+ git add .
35
+ git commit --amend -m " Deploy $GITHUB_SHA to gh-pages"
36
+ fi
37
+
38
+ git push --force origin +gh-pages
You can’t perform that action at this time.
0 commit comments