2021-05-06 22:14:52 +00:00
|
|
|
name: guide
|
2020-08-11 21:32:59 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-03-16 22:14:57 +00:00
|
|
|
- main
|
2021-05-05 03:27:12 +00:00
|
|
|
pull_request:
|
2020-08-11 21:32:59 +00:00
|
|
|
release:
|
2020-09-16 21:25:43 +00:00
|
|
|
types: [published]
|
2020-08-11 21:32:59 +00:00
|
|
|
|
2020-09-01 19:59:28 +00:00
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
|
2020-08-11 21:32:59 +00:00
|
|
|
jobs:
|
2021-05-06 22:14:52 +00:00
|
|
|
build:
|
2020-08-11 21:32:59 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-16 19:43:44 +00:00
|
|
|
outputs:
|
|
|
|
tag_name: ${{ steps.prepare_tag.outputs.tag_name }}
|
2020-08-11 21:32:59 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
2021-05-05 03:26:03 +00:00
|
|
|
- uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2021-07-20 07:53:43 +00:00
|
|
|
toolchain: nightly
|
|
|
|
profile: minimal
|
2021-05-05 03:26:03 +00:00
|
|
|
|
2020-08-11 21:32:59 +00:00
|
|
|
- name: Setup mdBook
|
|
|
|
uses: peaceiris/actions-mdbook@v1
|
|
|
|
with:
|
2021-07-20 07:53:43 +00:00
|
|
|
mdbook-version: "0.4.10"
|
2021-04-02 14:38:49 +00:00
|
|
|
|
|
|
|
- name: Prepare tag
|
|
|
|
id: prepare_tag
|
|
|
|
run: |
|
|
|
|
TAG_NAME="${GITHUB_REF##*/}"
|
|
|
|
echo "::set-output name=tag_name::${TAG_NAME}"
|
2020-08-11 21:32:59 +00:00
|
|
|
|
2020-08-13 19:46:31 +00:00
|
|
|
# This builds the book in gh-pages-build. See https://github.com/rust-lang-nursery/mdBook/issues/698
|
2020-08-11 21:32:59 +00:00
|
|
|
- name: Build the guide
|
2020-08-13 19:46:31 +00:00
|
|
|
run: mdbook build -d ../gh-pages-build guide
|
2021-04-02 14:38:49 +00:00
|
|
|
env:
|
|
|
|
PYO3_VERSION_TAG: ${{ steps.prepare_tag.outputs.tag_name }}
|
2020-08-11 21:32:59 +00:00
|
|
|
|
2020-08-13 19:46:31 +00:00
|
|
|
# This adds the docs to gh-pages-build/doc
|
2020-08-11 21:32:59 +00:00
|
|
|
- name: Build the doc
|
|
|
|
run: |
|
2021-07-22 07:15:26 +00:00
|
|
|
cargo +nightly rustdoc --lib --no-default-features --features="macros num-bigint num-complex hashbrown indexmap serde multiple-pymethods" -- --cfg docsrs
|
2020-08-13 19:46:31 +00:00
|
|
|
cp -r target/doc gh-pages-build/doc
|
|
|
|
echo "<meta http-equiv=refresh content=0;url=pyo3/index.html>" > gh-pages-build/doc/index.html
|
2020-08-11 21:32:59 +00:00
|
|
|
|
|
|
|
- name: Deploy
|
2021-05-05 08:35:37 +00:00
|
|
|
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
|
2021-08-11 22:50:58 +00:00
|
|
|
uses: peaceiris/actions-gh-pages@v3
|
2020-08-11 21:32:59 +00:00
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
2020-08-13 19:46:31 +00:00
|
|
|
publish_dir: ./gh-pages-build/
|
2020-08-11 21:32:59 +00:00
|
|
|
destination_dir: ${{ steps.prepare_tag.outputs.tag_name }}
|
2021-07-20 07:53:43 +00:00
|
|
|
full_commit_message: "Upload documentation for ${{ steps.prepare_tag.outputs.tag_name }}"
|
2020-09-16 19:43:44 +00:00
|
|
|
|
|
|
|
release:
|
2021-05-06 22:14:52 +00:00
|
|
|
needs: build
|
2020-09-16 20:11:31 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: ${{ github.event_name == 'release' }}
|
2020-09-16 19:43:44 +00:00
|
|
|
steps:
|
2021-07-20 07:46:40 +00:00
|
|
|
- name: Create latest tag redirects
|
2020-09-16 19:43:44 +00:00
|
|
|
env:
|
2021-05-06 22:14:52 +00:00
|
|
|
TAG_NAME: ${{ needs.build.outputs.tag_name }}
|
2020-09-16 19:43:44 +00:00
|
|
|
run: |
|
|
|
|
mkdir public
|
|
|
|
echo "<meta http-equiv=refresh content=0;url='$TAG_NAME/'>" > public/index.html
|
2021-07-20 07:46:40 +00:00
|
|
|
ln -sfT $TAG_NAME public/latest
|
2020-09-16 19:43:44 +00:00
|
|
|
|
|
|
|
- name: Deploy
|
2021-08-11 22:50:58 +00:00
|
|
|
uses: peaceiris/actions-gh-pages@v3
|
2020-09-16 19:43:44 +00:00
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
publish_dir: ./public/
|
2021-07-20 07:53:43 +00:00
|
|
|
full_commit_message: "Release ${{ needs.build.outputs.tag_name }}"
|
2020-09-16 19:43:44 +00:00
|
|
|
keep_files: true
|