Skip to content

Commit

Permalink
[ci] Make publish work
Browse files Browse the repository at this point in the history
  • Loading branch information
alvicsam committed Oct 14, 2024
1 parent 3fd4216 commit b66b2e9
Show file tree
Hide file tree
Showing 50 changed files with 237 additions and 99 deletions.
203 changes: 104 additions & 99 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,86 +13,86 @@ concurrency:
cancel-in-progress: true

jobs:
preflight:
if: contains(github.event.label.name, 'GHA-migration')
uses: ./.github/workflows/reusable-preflight.yml
# preflight:
# if: contains(github.event.label.name, 'GHA-migration')
# uses: ./.github/workflows/reusable-preflight.yml

test-rustdoc:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
if: ${{ needs.preflight.outputs.changes_rust }}
needs: [preflight]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- run: forklift cargo doc --workspace --all-features --no-deps
env:
SKIP_WASM_BUILD: 1
test-doc:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
needs: [preflight]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- run: forklift cargo test --doc --workspace
env:
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
# test-rustdoc:
# runs-on: ${{ needs.preflight.outputs.RUNNER }}
# if: ${{ needs.preflight.outputs.changes_rust }}
# needs: [preflight]
# container:
# image: ${{ needs.preflight.outputs.IMAGE }}
# steps:
# - uses: actions/checkout@v4
# - run: forklift cargo doc --workspace --all-features --no-deps
# env:
# SKIP_WASM_BUILD: 1
# test-doc:
# runs-on: ${{ needs.preflight.outputs.RUNNER }}
# needs: [preflight]
# container:
# image: ${{ needs.preflight.outputs.IMAGE }}
# steps:
# - uses: actions/checkout@v4
# - run: forklift cargo test --doc --workspace
# env:
# RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"

build-rustdoc:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
if: ${{ needs.preflight.outputs.changes_rust }}
needs: [preflight, test-rustdoc]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- run: forklift cargo doc --all-features --workspace --no-deps
env:
SKIP_WASM_BUILD: 1
RUSTDOCFLAGS: "-Dwarnings --default-theme=ayu --html-in-header ./docs/sdk/assets/header.html --extend-css ./docs/sdk/assets/theme.css --html-after-content ./docs/sdk/assets/after-content.html"
- run: rm -f ./target/doc/.lock
- run: mv ./target/doc ./crate-docs
- name: Inject Simple Analytics script
run: |
script_content="<script async defer src=\"https://apisa.parity.io/latest.js\"></script><noscript><img src=\"https://apisa.parity.io/latest.js\" alt=\"\" referrerpolicy=\"no-referrer-when-downgrade\" /></noscript>"
docs_dir="./crate-docs"
# build-rustdoc:
# runs-on: ${{ needs.preflight.outputs.RUNNER }}
# if: ${{ needs.preflight.outputs.changes_rust }}
# needs: [preflight, test-rustdoc]
# container:
# image: ${{ needs.preflight.outputs.IMAGE }}
# steps:
# - uses: actions/checkout@v4
# - run: forklift cargo doc --all-features --workspace --no-deps
# env:
# SKIP_WASM_BUILD: 1
# RUSTDOCFLAGS: "-Dwarnings --default-theme=ayu --html-in-header ./docs/sdk/assets/header.html --extend-css ./docs/sdk/assets/theme.css --html-after-content ./docs/sdk/assets/after-content.html"
# - run: rm -f ./target/doc/.lock
# - run: mv ./target/doc ./crate-docs
# - name: Inject Simple Analytics script
# run: |
# script_content="<script async defer src=\"https://apisa.parity.io/latest.js\"></script><noscript><img src=\"https://apisa.parity.io/latest.js\" alt=\"\" referrerpolicy=\"no-referrer-when-downgrade\" /></noscript>"
# docs_dir="./crate-docs"

inject_simple_analytics() {
find "$1" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'file="{}"; echo "Adding Simple Analytics script to $file"; sed -i "s|</head>|'"$2"'</head>|" "$file";'
}
# inject_simple_analytics() {
# find "$1" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'file="{}"; echo "Adding Simple Analytics script to $file"; sed -i "s|</head>|'"$2"'</head>|" "$file";'
# }

inject_simple_analytics "$docs_dir" "$script_content"
- run: echo "<meta http-equiv=refresh content=0;url=polkadot_sdk_docs/index.html>" > ./crate-docs/index.html
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-doc
path: ./crate-docs/
retention-days: 1
if-no-files-found: error
# inject_simple_analytics "$docs_dir" "$script_content"
# - run: echo "<meta http-equiv=refresh content=0;url=polkadot_sdk_docs/index.html>" > ./crate-docs/index.html
# - uses: actions/upload-artifact@v4
# with:
# name: ${{ github.sha }}-doc
# path: ./crate-docs/
# retention-days: 1
# if-no-files-found: error

build-implementers-guide:
runs-on: ubuntu-latest
container:
image: paritytech/mdbook-utils:e14aae4a-20221123
options: --user root
steps:
- uses: actions/checkout@v4
- run: mdbook build ./polkadot/roadmap/implementers-guide
- run: mkdir -p artifacts
- run: mv polkadot/roadmap/implementers-guide/book artifacts/
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-guide
path: ./artifacts/
retention-days: 1
if-no-files-found: error
# build-implementers-guide:
# runs-on: ubuntu-latest
# container:
# image: paritytech/mdbook-utils:e14aae4a-20221123
# options: --user root
# steps:
# - uses: actions/checkout@v4
# - run: mdbook build ./polkadot/roadmap/implementers-guide
# - run: mkdir -p artifacts
# - run: mv polkadot/roadmap/implementers-guide/book artifacts/
# - uses: actions/upload-artifact@v4
# with:
# name: ${{ github.sha }}-guide
# path: ./artifacts/
# retention-days: 1
# if-no-files-found: error

publish-rustdoc:
if: github.ref == 'refs/heads/master'
# if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment: subsystem-benchmarks
needs: [build-rustdoc, build-implementers-guide]
# needs: [preflight]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -102,32 +102,37 @@ jobs:
with:
app-id: ${{ secrets.POLKADOTSDK_GHPAGES_APP_ID }}
private-key: ${{ secrets.POLKADOTSDK_GHPAGES_APP_KEY }}
- name: Ensure destination dir does not exist
- name: Create test file
run: |
rm -rf book/
rm -rf ${REF_NAME}
env:
REF_NAME: ${{ github.head_ref || github.ref_name }}
- name: Download rustdocs
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}-doc
path: ${{ github.head_ref || github.ref_name }}
- name: Download guide
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}-guide
path: /tmp
- run: mkdir -p book
- name: Move book files
run: mv /tmp/book/html/* book/
- name: Push to GH-Pages branch
uses: github-actions-x/[email protected]
with:
github-token: ${{ steps.app-token.outputs.token }}
push-branch: "gh-pages"
commit-message: "___Updated docs for ${{ github.head_ref || github.ref_name }}___"
force-add: "true"
files: ${{ github.head_ref || github.ref_name }}/ book/
name: devops-parity
email: [email protected]
ls -la
echo ${{ github.sha }} > ${{ github.sha }}.txt
git status
# - name: Ensure destination dir does not exist
# run: |
# rm -rf book/
# rm -rf ${REF_NAME}
# env:
# REF_NAME: ${{ github.head_ref || github.ref_name }}
# - name: Download rustdocs
# uses: actions/download-artifact@v4
# with:
# name: ${{ github.sha }}-doc
# path: ${{ github.head_ref || github.ref_name }}
# - name: Download guide
# uses: actions/download-artifact@v4
# with:
# name: ${{ github.sha }}-guide
# path: /tmp
# - run: mkdir -p book
# - name: Move book files
# run: mv /tmp/book/html/* book/
# - name: Push to GH-Pages branch
# uses: github-actions-x/[email protected]
# with:
# github-token: ${{ steps.app-token.outputs.token }}
# push-branch: "gh-pages"
# commit-message: "___Updated docs for ${{ github.head_ref || github.ref_name }}___"
# force-add: "true"
# files: ${{ github.head_ref || github.ref_name }}/ book/
# name: devops-parity
# email: [email protected]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
133 changes: 133 additions & 0 deletions .github/workflows/tmp/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Docs

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
preflight:
if: contains(github.event.label.name, 'GHA-migration')
uses: ./.github/workflows/reusable-preflight.yml

test-rustdoc:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
if: ${{ needs.preflight.outputs.changes_rust }}
needs: [preflight]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- run: forklift cargo doc --workspace --all-features --no-deps
env:
SKIP_WASM_BUILD: 1
test-doc:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
needs: [preflight]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- run: forklift cargo test --doc --workspace
env:
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"

build-rustdoc:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
if: ${{ needs.preflight.outputs.changes_rust }}
needs: [preflight, test-rustdoc]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- run: forklift cargo doc --all-features --workspace --no-deps
env:
SKIP_WASM_BUILD: 1
RUSTDOCFLAGS: "-Dwarnings --default-theme=ayu --html-in-header ./docs/sdk/assets/header.html --extend-css ./docs/sdk/assets/theme.css --html-after-content ./docs/sdk/assets/after-content.html"
- run: rm -f ./target/doc/.lock
- run: mv ./target/doc ./crate-docs
- name: Inject Simple Analytics script
run: |
script_content="<script async defer src=\"https://apisa.parity.io/latest.js\"></script><noscript><img src=\"https://apisa.parity.io/latest.js\" alt=\"\" referrerpolicy=\"no-referrer-when-downgrade\" /></noscript>"
docs_dir="./crate-docs"
inject_simple_analytics() {
find "$1" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'file="{}"; echo "Adding Simple Analytics script to $file"; sed -i "s|</head>|'"$2"'</head>|" "$file";'
}
inject_simple_analytics "$docs_dir" "$script_content"
- run: echo "<meta http-equiv=refresh content=0;url=polkadot_sdk_docs/index.html>" > ./crate-docs/index.html
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-doc
path: ./crate-docs/
retention-days: 1
if-no-files-found: error

build-implementers-guide:
runs-on: ubuntu-latest
container:
image: paritytech/mdbook-utils:e14aae4a-20221123
options: --user root
steps:
- uses: actions/checkout@v4
- run: mdbook build ./polkadot/roadmap/implementers-guide
- run: mkdir -p artifacts
- run: mv polkadot/roadmap/implementers-guide/book artifacts/
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-guide
path: ./artifacts/
retention-days: 1
if-no-files-found: error

publish-rustdoc:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment: subsystem-benchmarks
needs: [build-rustdoc, build-implementers-guide]
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.POLKADOTSDK_GHPAGES_APP_ID }}
private-key: ${{ secrets.POLKADOTSDK_GHPAGES_APP_KEY }}
- name: Ensure destination dir does not exist
run: |
rm -rf book/
rm -rf ${REF_NAME}
env:
REF_NAME: ${{ github.head_ref || github.ref_name }}
- name: Download rustdocs
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}-doc
path: ${{ github.head_ref || github.ref_name }}
- name: Download guide
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}-guide
path: /tmp
- run: mkdir -p book
- name: Move book files
run: mv /tmp/book/html/* book/
- name: Push to GH-Pages branch
uses: github-actions-x/[email protected]
with:
github-token: ${{ steps.app-token.outputs.token }}
push-branch: "gh-pages"
commit-message: "___Updated docs for ${{ github.head_ref || github.ref_name }}___"
force-add: "true"
files: ${{ github.head_ref || github.ref_name }}/ book/
name: devops-parity
email: [email protected]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b66b2e9

Please sign in to comment.