From 08dd69297cc8d84846f279bb2feaf31853fd3976 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Tue, 25 Mar 2025 13:15:03 +0900 Subject: [PATCH 01/12] feat(ci): run mdbook on pull requests Signed-off-by: Victor Adossi --- .github/workflows/deploy.yml | 85 ++++++++++++++++++++++++++++++++++++ .github/workflows/mdbook.yml | 79 ++++++++------------------------- 2 files changed, 104 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..c88b11a3 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,85 @@ +name: Deploy mdBook site to Pages + +on: + push: + branches: ["main"] + + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +env: + MDBOOK_VERSION: 0.4.21 + MDBOOK_ALERTS_VERSION: 0.6.7 + MDBOOK_LINKCHECK_VERSION: 0.7.7 + PUBLISH_DOMAIN: component-model.bytecodealliance.org + ARTIFACT_PATH: ./component-model/book/html + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: mdbook@${{ env.MDBOOK_VERSION }} + + - uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: mdbook-alerts@${{ env.MDBOOK_ALERTS_VERSION }} + + - uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: mdbook-linkcheck@${{ env.MDBOOK_LINKCHECK_VERSION }} + + - name: Build with mdBook + run: mdbook build component-model + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Ensure build outputs are present + shell: bash + run: | + if [[ ! -f "${{ env.ARTIFACT_PATH }}/index.html" ]]; then + echo "[error] index.html @ [${{ env.ARTIFACT_PATH }}] is missing. Build or path misconfigured"; + exit 1; + fi + + - name: Generate sitemap + shell: bash + run: | + cd ${{ env.ARTIFACT_PATH }} + python3 ../../../scripts/generate_sitemap.py --domain "component-model.bytecodealliance.org" --higher-priority "design" --output-path sitemap.xml + cd ../../../ + + - name: Setup Pages + id: pages + uses: actions/configure-pages@v3 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ${{ env.ARTIFACT_PATH }} + + deploy: + if: ${{ github.repository_owner == 'bytecodealliance' }} + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml index 200dcce1..08a7f15c 100644 --- a/.github/workflows/mdbook.yml +++ b/.github/workflows/mdbook.yml @@ -1,58 +1,34 @@ -# Sample workflow for building and deploying a mdBook site to GitHub Pages -# -# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html -# -name: Deploy mdBook site to Pages +name: mdbook on: - # Runs on pushes targeting the default branch - push: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false + pull_request: env: MDBOOK_VERSION: 0.4.21 MDBOOK_ALERTS_VERSION: 0.6.7 MDBOOK_LINKCHECK_VERSION: 0.7.7 - PUBLISH_DOMAIN: component-model.bytecodealliance.org - ARTIFACT_PATH: ./component-model/book/html jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install mdBook - run: | - curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh - rustup update - cargo install --version ${{ env.MDBOOK_VERSION }} mdbook - cargo install --version ${{ env.MDBOOK_ALERTS_VERSION }} mdbook-alerts - cargo install --version ${{ env.MDBOOK_LINKCHECK_VERSION }} mdbook-linkcheck - - name: Build with mdBook - run: mdbook build component-model + - uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: mdbook@${{ env.MDBOOK_VERSION }} - - name: Setup Python - uses: actions/setup-python@v5 + - uses: taiki-e/cache-cargo-install-action@v2 with: - python-version: '3.13' + tool: mdbook-alerts@${{ env.MDBOOK_ALERTS_VERSION }} + + - uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: mdbook-linkcheck@${{ env.MDBOOK_LINKCHECK_VERSION }} + + - name: Build with mdBook + run: mdbook build component-model - # Ensure the build generated properly - name: Ensure build outputs are present shell: bash run: | @@ -61,31 +37,14 @@ jobs: exit 1; fi + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + - name: Generate sitemap shell: bash run: | cd ${{ env.ARTIFACT_PATH }} python3 ../../../scripts/generate_sitemap.py --domain "component-model.bytecodealliance.org" --higher-priority "design" --output-path sitemap.xml cd ../../../ - - - name: Setup Pages - id: pages - uses: actions/configure-pages@v3 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: ${{ env.ARTIFACT_PATH }} - - # Deployment job - deploy: - if: ${{ github.repository_owner == 'bytecodealliance' }} - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 From c6e447899d6e86ef5d0c2bb9bb44fab6339d2b79 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Wed, 26 Mar 2025 22:17:40 +0900 Subject: [PATCH 02/12] refactor(ci): use reusable action Signed-off-by: Victor Adossi --- .github/actions/mdbook/action.yml | 113 ++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 52 ++------------ .github/workflows/mdbook.yml | 41 +---------- justfile | 19 +++++ scripts/generate_sitemap.py | 28 ++++++-- 5 files changed, 162 insertions(+), 91 deletions(-) create mode 100644 .github/actions/mdbook/action.yml create mode 100644 justfile diff --git a/.github/actions/mdbook/action.yml b/.github/actions/mdbook/action.yml new file mode 100644 index 00000000..ac81c7b7 --- /dev/null +++ b/.github/actions/mdbook/action.yml @@ -0,0 +1,113 @@ +name: mdbook + +description: | + Run the mdbook build, optionally outputting a pages artifact + +inputs: + publish-pages-artifact: + type: boolean + required: false + default: false + description: | + Whether to publish a pages artifact + + publish-domain: + type: string + required: false + default: "component-model.bytecodealliance.org" + description: | + Path to which to store the artifac + + mdbook-version: + type: string + required: false + default: "0.4.21" + description: | + Version of mdbook to use (ex. '0.4.21') + + mdbook-alerts-version: + type: string + required: false + default: "0.6.7" + description: | + Version of mdbook-alerts to use (ex. '0.6.7') + + mdbook-linkcheck-version: + type: string + required: false + default: "0.7.7" + description: | + Version of mdbook-linkcheck to use (ex. '0.7.7') + +env: + ARTIFACT_PATH: ./component-model/book/html + +runs: + using: composite + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - uses: extractions/setup-just@v2 + + - uses: taiki-e/cache-cargo-install-action@4d586f211d9b0bca9e7b59e57e2a0febf36c0929 # v2.1.1 + with: + tool: "just" + + - uses: taiki-e/cache-cargo-install-action@4d586f211d9b0bca9e7b59e57e2a0febf36c0929 # v2.1.1 + with: + tool: "mdbook@${{ inputs.mdbook-version }}" + + - uses: taiki-e/cache-cargo-install-action@4d586f211d9b0bca9e7b59e57e2a0febf36c0929 # v2.1.1 + with: + tool: "mdbook-alerts@${{ inputs.mdbook-alerts-version }}" + + - uses: taiki-e/cache-cargo-install-action@4d586f211d9b0bca9e7b59e57e2a0febf36c0929 # v2.1.1 + with: + tool: "mdbook-linkcheck@${{ inputs.mdbook-linkcheck-version }}" + + - name: Build with mdBook + shell: bash + run: mdbook build component-model + + - name: Setup Python + uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 + with: + python-version: '3.13' + + - name: Ensure build outputs are present + shell: bash + run: | + if [[ ! -f "${{ env.ARTIFACT_PATH }}/index.html" ]]; then + echo "[error] index.html @ [${{ env.ARTIFACT_PATH }}] is missing. Build or path misconfigured"; + exit 1; + fi + + - name: Generate sitemap + shell: bash + run: | + cd ${{ env.ARTIFACT_PATH }} + python3 ../../../scripts/generate_sitemap.py \ + --domain "${{ inputs.publish-domain }}" \ + --higher-priority "design" \ + --output-path sitemap.xml + cd ../../../ + + - name: Ensure publish-domain was provided + if: ${{ inputs.publish-pages-artifact }} + shell: bash + run: | + if [ -z "${{ inputs.publish-domain }}" ]; then + echo "[error] publish-domain input is required when publishing"; + exit 1; + fi + + - name: Setup Pages + if: ${{ inputs.publish-pages-artifact }} + id: pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + + - name: Upload artifact + if: ${{ inputs.publish-pages-artifact }} + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 + with: + path: ${{ env.ARTIFACT_PATH }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c88b11a3..03ca0780 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,60 +26,20 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: taiki-e/cache-cargo-install-action@v2 + - uses: ./.github/actions/mdbook with: - tool: mdbook@${{ env.MDBOOK_VERSION }} - - - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: mdbook-alerts@${{ env.MDBOOK_ALERTS_VERSION }} - - - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: mdbook-linkcheck@${{ env.MDBOOK_LINKCHECK_VERSION }} - - - name: Build with mdBook - run: mdbook build component-model - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - - name: Ensure build outputs are present - shell: bash - run: | - if [[ ! -f "${{ env.ARTIFACT_PATH }}/index.html" ]]; then - echo "[error] index.html @ [${{ env.ARTIFACT_PATH }}] is missing. Build or path misconfigured"; - exit 1; - fi - - - name: Generate sitemap - shell: bash - run: | - cd ${{ env.ARTIFACT_PATH }} - python3 ../../../scripts/generate_sitemap.py --domain "component-model.bytecodealliance.org" --higher-priority "design" --output-path sitemap.xml - cd ../../../ - - - name: Setup Pages - id: pages - uses: actions/configure-pages@v3 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: ${{ env.ARTIFACT_PATH }} + publish-pages: true deploy: if: ${{ github.repository_owner == 'bytecodealliance' }} + needs: + - build environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml index 08a7f15c..1807592c 100644 --- a/.github/workflows/mdbook.yml +++ b/.github/workflows/mdbook.yml @@ -3,48 +3,13 @@ name: mdbook on: pull_request: -env: - MDBOOK_VERSION: 0.4.21 - MDBOOK_ALERTS_VERSION: 0.6.7 - MDBOOK_LINKCHECK_VERSION: 0.7.7 - jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: mdbook@${{ env.MDBOOK_VERSION }} - - - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: mdbook-alerts@${{ env.MDBOOK_ALERTS_VERSION }} - - - uses: taiki-e/cache-cargo-install-action@v2 - with: - tool: mdbook-linkcheck@${{ env.MDBOOK_LINKCHECK_VERSION }} - - - name: Build with mdBook - run: mdbook build component-model - - - name: Ensure build outputs are present - shell: bash - run: | - if [[ ! -f "${{ env.ARTIFACT_PATH }}/index.html" ]]; then - echo "[error] index.html @ [${{ env.ARTIFACT_PATH }}] is missing. Build or path misconfigured"; - exit 1; - fi + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Setup Python - uses: actions/setup-python@v5 + - uses: ./.github/actions/mdbook with: - python-version: '3.13' + publish-pages: true - - name: Generate sitemap - shell: bash - run: | - cd ${{ env.ARTIFACT_PATH }} - python3 ../../../scripts/generate_sitemap.py --domain "component-model.bytecodealliance.org" --higher-priority "design" --output-path sitemap.xml - cd ../../../ diff --git a/justfile b/justfile new file mode 100644 index 00000000..fddddd7b --- /dev/null +++ b/justfile @@ -0,0 +1,19 @@ +just := env_var_or_default("JUST", "just") +just_dir := env_var_or_default("JUST_DIR", justfile_directory()) + +python := env_var_or_default("PYTHON", "python3") +cargo := env_var_or_default("CARGO", "cargo") + +publish_domain := env_var_or_default("PUBLISH_DOMAIN", "component-model.bytecodealliance.org") + +scripts_dir := env_var_or_default("SCRIPTS_DIR", "scripts") + +sitemap_output_path := absolute_path("./component-model/book/html/sitemap.xml") + +@_default: + {{just}} --list + +# Build the sitemap +@build-sitemap: + {{python}} {{scripts_dir}}/generate_sitemap.py --domain "{{publish_domain}}" --higher-priority "design" --output-path {{sitemap_output_path}} + diff --git a/scripts/generate_sitemap.py b/scripts/generate_sitemap.py index b729de56..b490e612 100644 --- a/scripts/generate_sitemap.py +++ b/scripts/generate_sitemap.py @@ -1,11 +1,13 @@ import os from urllib.parse import urljoin from datetime import datetime +from pathlib import Path + import argparse -def parse_summary(): +def parse_summary(summary_file_path): """Parse URLs from the SUMMARY.md file.""" - with open("../../src/SUMMARY.md", "r") as file: + with open(summary_file_path, "r") as file: for line in file: if "](" in line: url = line.split("](")[1].split(")")[0] @@ -23,10 +25,10 @@ def determine_priority(url_path, higher_priority_section): else: return "0.5" # All other pages -def generate_sitemap(domain, output_path, higher_priority_section): +def generate_sitemap(domain, output_path, summary_file_path, higher_priority_section): """Generate a sitemap XML file from SUMMARY.md structure.""" domain = "https://" + domain - urls = parse_summary() # Add base URL to the list of URLs + urls = parse_summary(summary_file_path) # Add base URL to the list of URLs urls = [""] + list(urls) sitemap = '\n' @@ -48,11 +50,23 @@ def generate_sitemap(domain, output_path, higher_priority_section): with open(output_path, "w") as file: file.write(sitemap) +DEFAULT_SUMMARY_MD_PATH = (Path(__file__).parent / "../component-model/src/SUMMARY.md").resolve() +DEFAULT_SITEMAP_XML_PATH = (Path(__file__).parent / "../component-model/book/html/sitemap.sml").resolve() + if __name__ == "__main__": parser = argparse.ArgumentParser(description="Generate a sitemap for mdBook") - parser.add_argument("-d", "--domain", required=True, help="Domain for the mdBook site (e.g., component-model.bytecodealliance.org)") - parser.add_argument("-o", "--output-path", default="sitemap.xml", help="Output path for the sitemap file") + parser.add_argument("-d", "--domain", required=True, help="Domain for the mdBook site (e.g., 'component-model.bytecodealliance.org')") + parser.add_argument("-o", "--output-path", default=DEFAULT_SITEMAP_XML_PATH, help="Output path for the sitemap file") + parser.add_argument("-s", "--summary-md-path", default=DEFAULT_SUMMARY_MD_PATH, help="Path to SUMMARY.md") parser.add_argument("-p", "--higher-priority", help="Subsection path (e.g., 'design') to assign a higher priority of 0.8") args = parser.parse_args() - generate_sitemap(args.domain, args.output_path, args.higher_priority) + summary_file_path = Path(args.summary_md_path).resolve() + if not summary_file_path.exists(): + raise FileNotFoundError(f"failed to find summary file [{summary_file_path}]") + + output_path = Path(args.output_path).resolve() + if not output_path.parent.exists(): + raise FileNotFoundError(f"failed to find output dir [{output_path.parent}]") + + generate_sitemap(args.domain, output_path, summary_file_path, args.higher_priority) From 9038e01b74c922db24502d3a6cacb5ae3cb08f1f Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Wed, 26 Mar 2025 23:34:35 +0900 Subject: [PATCH 03/12] fix: use build-sitemap Signed-off-by: Victor Adossi --- .github/actions/mdbook/action.yml | 16 +--------------- justfile | 10 ++++++++-- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/actions/mdbook/action.yml b/.github/actions/mdbook/action.yml index ac81c7b7..235df5c0 100644 --- a/.github/actions/mdbook/action.yml +++ b/.github/actions/mdbook/action.yml @@ -38,7 +38,6 @@ inputs: default: "0.7.7" description: | Version of mdbook-linkcheck to use (ex. '0.7.7') - env: ARTIFACT_PATH: ./component-model/book/html @@ -74,23 +73,10 @@ runs: with: python-version: '3.13' - - name: Ensure build outputs are present - shell: bash - run: | - if [[ ! -f "${{ env.ARTIFACT_PATH }}/index.html" ]]; then - echo "[error] index.html @ [${{ env.ARTIFACT_PATH }}] is missing. Build or path misconfigured"; - exit 1; - fi - - name: Generate sitemap shell: bash run: | - cd ${{ env.ARTIFACT_PATH }} - python3 ../../../scripts/generate_sitemap.py \ - --domain "${{ inputs.publish-domain }}" \ - --higher-priority "design" \ - --output-path sitemap.xml - cd ../../../ + just build-sitemap - name: Ensure publish-domain was provided if: ${{ inputs.publish-pages-artifact }} diff --git a/justfile b/justfile index fddddd7b..3e1ae808 100644 --- a/justfile +++ b/justfile @@ -8,12 +8,18 @@ publish_domain := env_var_or_default("PUBLISH_DOMAIN", "component-model.bytecode scripts_dir := env_var_or_default("SCRIPTS_DIR", "scripts") -sitemap_output_path := absolute_path("./component-model/book/html/sitemap.xml") +sitemap_output_path := env_var_or_default("SITEMAP_OUTPUT_PATH", absolute_path("./component-model/book/html/sitemap.xml")) +book_output_dir := env_var_or_default("BOOK_OUTPUT_DIR", "./component-model/book/html") @_default: {{just}} --list # Build the sitemap @build-sitemap: - {{python}} {{scripts_dir}}/generate_sitemap.py --domain "{{publish_domain}}" --higher-priority "design" --output-path {{sitemap_output_path}} + {{python}} {{scripts_dir}}/generate_sitemap.py --domain "{{publish_domain}}" --higher-priority "design" --output-path {{sitemap_output_path}} + if [[ ! -f "{{book_output_dir}}/index.html" ]]; then \ + echo "[error] index.html @ [{{book_output_dir}}] is missing. Build or path misconfigured"; \ + exit 1; \ + fi + From df5e7474979bcf91ac18dfacd43c7b0b5bc8b669 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Wed, 26 Mar 2025 23:42:05 +0900 Subject: [PATCH 04/12] feat(ci): add ability to use pre-existing ref Signed-off-by: Victor Adossi --- .github/workflows/deploy.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 03ca0780..c72ab1d7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,6 +5,13 @@ on: branches: ["main"] workflow_dispatch: + inputs: + ref: + required: false + type: string + default: main + description: | + The git ref to deploy (ex. 'main', 'branch', '') permissions: contents: read @@ -27,6 +34,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ inputs.ref || 'main' }} - uses: ./.github/actions/mdbook with: From 35e401711c776e4bfd1bd9dfb9705f5cf96f72bc Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Wed, 26 Mar 2025 23:43:28 +0900 Subject: [PATCH 05/12] refactor(ci): ensure to not publish on PR builds Signed-off-by: Victor Adossi --- .github/workflows/deploy.yml | 3 ++- .github/workflows/mdbook.yml | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c72ab1d7..ca02ddc9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,7 +37,8 @@ jobs: with: ref: ${{ inputs.ref || 'main' }} - - uses: ./.github/actions/mdbook + - name: build mdbook + uses: ./.github/actions/mdbook with: publish-pages: true diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml index 1807592c..64ed56a5 100644 --- a/.github/workflows/mdbook.yml +++ b/.github/workflows/mdbook.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: ./.github/actions/mdbook + - name: build mdbook + uses: ./.github/actions/mdbook with: - publish-pages: true - + publish-pages: false From 82bbaefa716d2a65624647a0d37131aeb9382baf Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Wed, 26 Mar 2025 23:48:14 +0900 Subject: [PATCH 06/12] fix(ci): setting for reusable action Signed-off-by: Victor Adossi --- .github/workflows/deploy.yml | 2 +- .github/workflows/mdbook.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca02ddc9..e9328156 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,7 +40,7 @@ jobs: - name: build mdbook uses: ./.github/actions/mdbook with: - publish-pages: true + publish-pages-artifact: true deploy: if: ${{ github.repository_owner == 'bytecodealliance' }} diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml index 64ed56a5..1ce1e8ba 100644 --- a/.github/workflows/mdbook.yml +++ b/.github/workflows/mdbook.yml @@ -12,4 +12,4 @@ jobs: - name: build mdbook uses: ./.github/actions/mdbook with: - publish-pages: false + publish-pages-artifact: true From ac849e705d6e28e5d2f9782bd578cc3c2504a4da Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Wed, 26 Mar 2025 23:51:27 +0900 Subject: [PATCH 07/12] fix(ci): justfile, extra just install Signed-off-by: Victor Adossi --- .github/actions/mdbook/action.yml | 4 ---- justfile | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/actions/mdbook/action.yml b/.github/actions/mdbook/action.yml index 235df5c0..196ac662 100644 --- a/.github/actions/mdbook/action.yml +++ b/.github/actions/mdbook/action.yml @@ -48,10 +48,6 @@ runs: - uses: extractions/setup-just@v2 - - uses: taiki-e/cache-cargo-install-action@4d586f211d9b0bca9e7b59e57e2a0febf36c0929 # v2.1.1 - with: - tool: "just" - - uses: taiki-e/cache-cargo-install-action@4d586f211d9b0bca9e7b59e57e2a0febf36c0929 # v2.1.1 with: tool: "mdbook@${{ inputs.mdbook-version }}" diff --git a/justfile b/justfile index 3e1ae808..da9aeb9a 100644 --- a/justfile +++ b/justfile @@ -17,7 +17,7 @@ book_output_dir := env_var_or_default("BOOK_OUTPUT_DIR", "./component-model/book # Build the sitemap @build-sitemap: {{python}} {{scripts_dir}}/generate_sitemap.py --domain "{{publish_domain}}" --higher-priority "design" --output-path {{sitemap_output_path}} - if [[ ! -f "{{book_output_dir}}/index.html" ]]; then \ + if [ ! -f "{{book_output_dir}}/index.html" ]; then \ echo "[error] index.html @ [{{book_output_dir}}] is missing. Build or path misconfigured"; \ exit 1; \ fi From 470026e3a87636db5b601a1339dbc51b7c9e5be4 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Wed, 26 Mar 2025 23:54:27 +0900 Subject: [PATCH 08/12] refactor(ci): use artifact output path Signed-off-by: Victor Adossi --- .github/actions/mdbook/action.yml | 15 ++++++++------- justfile | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/actions/mdbook/action.yml b/.github/actions/mdbook/action.yml index 196ac662..9dc1420f 100644 --- a/.github/actions/mdbook/action.yml +++ b/.github/actions/mdbook/action.yml @@ -38,8 +38,6 @@ inputs: default: "0.7.7" description: | Version of mdbook-linkcheck to use (ex. '0.7.7') -env: - ARTIFACT_PATH: ./component-model/book/html runs: using: composite @@ -60,15 +58,18 @@ runs: with: tool: "mdbook-linkcheck@${{ inputs.mdbook-linkcheck-version }}" - - name: Build with mdBook - shell: bash - run: mdbook build component-model - - name: Setup Python uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 with: python-version: '3.13' + - name: Build with mdBook + shell: bash + id: book-build + run: | + just build-book + echo "output-path=$(just print-book-dir)" >> $GITHUB_OUTPUT + - name: Generate sitemap shell: bash run: | @@ -92,4 +93,4 @@ runs: if: ${{ inputs.publish-pages-artifact }} uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: - path: ${{ env.ARTIFACT_PATH }} + path: ${{ steps.book-build.outputs.output-path }} diff --git a/justfile b/justfile index da9aeb9a..2166f5a7 100644 --- a/justfile +++ b/justfile @@ -3,6 +3,7 @@ just_dir := env_var_or_default("JUST_DIR", justfile_directory()) python := env_var_or_default("PYTHON", "python3") cargo := env_var_or_default("CARGO", "cargo") +mdbook := env_var_or_default("MDBOOK", "mdbook") publish_domain := env_var_or_default("PUBLISH_DOMAIN", "component-model.bytecodealliance.org") @@ -14,12 +15,21 @@ book_output_dir := env_var_or_default("BOOK_OUTPUT_DIR", "./component-model/book @_default: {{just}} --list +# Print the directory the book was output to +[group('meta')] +@print-book-dir: + echo -n {{book_output_dir}} + +# Build the book +[group('build')] +@build-book: + {{mdbook}} build component-model + # Build the sitemap +[group('build')] @build-sitemap: {{python}} {{scripts_dir}}/generate_sitemap.py --domain "{{publish_domain}}" --higher-priority "design" --output-path {{sitemap_output_path}} if [ ! -f "{{book_output_dir}}/index.html" ]; then \ echo "[error] index.html @ [{{book_output_dir}}] is missing. Build or path misconfigured"; \ exit 1; \ fi - - From b04082b3d9918f91e9c158931b2560192cdf39c1 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Thu, 27 Mar 2025 00:03:21 +0900 Subject: [PATCH 09/12] feat(ci): pass through publish domain during deploy Signed-off-by: Victor Adossi --- .github/workflows/deploy.yml | 9 ++++++++- justfile | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e9328156..3e4a5f02 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,6 +13,13 @@ on: description: | The git ref to deploy (ex. 'main', 'branch', '') + publish-domain: + required: false + type: string + default: "component-model.bytecodealliance.org" + description: | + The domain to which to publish (ex. 'component-model.bytecodealliance.org') + permissions: contents: read pages: write @@ -26,7 +33,6 @@ env: MDBOOK_VERSION: 0.4.21 MDBOOK_ALERTS_VERSION: 0.6.7 MDBOOK_LINKCHECK_VERSION: 0.7.7 - PUBLISH_DOMAIN: component-model.bytecodealliance.org ARTIFACT_PATH: ./component-model/book/html jobs: @@ -41,6 +47,7 @@ jobs: uses: ./.github/actions/mdbook with: publish-pages-artifact: true + publish-domain: ${{ inputs.publish-domain || 'component-model.bytecodealliance.org' }} deploy: if: ${{ github.repository_owner == 'bytecodealliance' }} diff --git a/justfile b/justfile index 2166f5a7..baa84b1d 100644 --- a/justfile +++ b/justfile @@ -15,7 +15,7 @@ book_output_dir := env_var_or_default("BOOK_OUTPUT_DIR", "./component-model/book @_default: {{just}} --list -# Print the directory the book was output to +# Print the directory the book is/would be output to [group('meta')] @print-book-dir: echo -n {{book_output_dir}} From e2364935823b16cb744b4d371c677ed018477536 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Thu, 27 Mar 2025 00:06:02 +0900 Subject: [PATCH 10/12] fix(ci): use publish domain Signed-off-by: Victor Adossi --- .github/actions/mdbook/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/mdbook/action.yml b/.github/actions/mdbook/action.yml index 9dc1420f..f3861dd7 100644 --- a/.github/actions/mdbook/action.yml +++ b/.github/actions/mdbook/action.yml @@ -66,6 +66,8 @@ runs: - name: Build with mdBook shell: bash id: book-build + env: + PUBLISH_DOMAIN: ${{ inputs.publish-domain }} run: | just build-book echo "output-path=$(just print-book-dir)" >> $GITHUB_OUTPUT From ef8908e1402d3be754bbbe355a613bf5af5e2294 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Thu, 27 Mar 2025 00:07:46 +0900 Subject: [PATCH 11/12] fix(ci): missing runs-on Signed-off-by: Victor Adossi --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3e4a5f02..22de48af 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -51,6 +51,7 @@ jobs: deploy: if: ${{ github.repository_owner == 'bytecodealliance' }} + runs-on: ubuntu-latest needs: - build environment: From 9267bbb2c9b984a30abedfd77c5d1c89927817b7 Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Thu, 27 Mar 2025 00:08:41 +0900 Subject: [PATCH 12/12] refactor(ci): branches listing Signed-off-by: Victor Adossi --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22de48af..e6af4e85 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,8 @@ name: Deploy mdBook site to Pages on: push: - branches: ["main"] + branches: + - main workflow_dispatch: inputs: