Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,8 @@ jobs:
- uses: actions/checkout@v4
- name: Install Rust (rustup)
run: rustup update stable --no-self-update && rustup default stable
- name: Build book
run: cargo run -- build guide
- name: Deploy the User Guide to GitHub Pages using the gh-pages branch
env:
GITHUB_DEPLOY_KEY: ${{ secrets.GITHUB_DEPLOY_KEY }}
run: |
touch guide/book/.nojekyll
curl -LsSf https://raw.githubusercontent.com/rust-lang/simpleinfra/master/setup-deploy-keys/src/deploy.rs | rustc - -o /tmp/deploy
cd guide/book
/tmp/deploy
run: ci/publish-guide.sh
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
Expand Down
38 changes: 38 additions & 0 deletions ci/publish-guide.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# This publishes the user guide to GitHub Pages.
#
# If this is a pre-release, then it goes in a separate directory called "pre-release".
# Commits are amended to avoid keeping history which can balloon the repo size.
set -ex

cargo run --no-default-features -F search -- build guide

VERSION=$(cargo metadata --format-version 1 --no-deps | jq '.packages[] | select(.name == "mdbook") | .version')

if [[ "$VERSION" == *-* ]]; then
PRERELEASE=true
else
PRERELEASE=false
fi

git fetch origin gh-pages
git worktree add gh-pages gh-pages
git config user.name "Deploy from CI"
git config user.email ""
cd gh-pages
if [[ "$PRERELEASE" == "true" ]]
then
rm -rf pre-release
mv ../guide/book pre-release
git add pre-release
git commit --amend -m "Deploy $GITHUB_SHA pre-release to gh-pages"
else
# Delete everything except pre-release and .git.
find . -mindepth 1 -maxdepth 1 -not -name "pre-release" -not -name ".git" -exec rm -rf {} +
# Copy the guide here.
find ../guide/book/ -mindepth 1 -maxdepth 1 -exec mv {} . \;
git add .
git commit --amend -m "Deploy $GITHUB_SHA to gh-pages"
fi

git push --force origin +gh-pages
Loading