From 6ee42c4c4fc88b4c5569006213f19474f037e085 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Sun, 24 Nov 2024 17:25:31 +0530 Subject: [PATCH 1/5] Better Docs --- .github/workflows/doc.yml | 74 ++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 416cfb20b..00a632299 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -1,45 +1,61 @@ -name: Doc +name: Generate Documentation on: push: - branches: - - main workflow_dispatch: - permissions: contents: write - pages: write - id-token: write - -concurrency: - group: "pages" - cancel-in-progress: true jobs: deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + + - name: Install Rust Toolchain + uses: rs-workspace/rust-toolchain@v0.1.0 with: toolchain: nightly - - run: cargo doc --workspace --no-deps - - uses: "finnp/create-file-action@master" - env: - FILE_NAME: "./target/doc/index.html" - FILE_DATA: '' # Redirect to default page - - - name: Setup Pages - uses: actions/configure-pages@v2 - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - path: './target/doc/' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 + + - name: Generate Documentation + run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo doc --workspace --no-deps + + - name: Prepare Documentation + run: | + BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '/' '_') # Get branch name safely + mkdir -p versioned_docs/$BRANCH_NAME + cp -r target/doc/* versioned_docs/$BRANCH_NAME + + - name: Checkout to Docs Branch + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git fetch origin docs || git checkout --orphan docs + git checkout docs + cp -r versioned_docs/* ./ # Copy docs to branch root + rm -rf versioned_docs # Clean up + rm -rf target # Clean up + + - name: Generate README.md + run: | + VERSIONS=$(ls -d */ | sed 's#/##' | sort -r) # Get all version directories and sort them (latest first) + rm README.md # Delete README.md and generate a new one + echo "# Azalea Docs" > README.md + echo "Welcome to the documentation for Azalea Crate." >> README.md + echo "" >> README.md + + # Update README.md with available versions + echo "## Available Versions" >> README.md + for VERSION in $VERSIONS; do + echo "- [$VERSION](./$VERSION/index.html)" >> README.md + done + + echo "README.md updated successfully." + + - name: Deploy Documentation to Docs Branch + run: | + git add . + git commit -m "Update documentation for $GITHUB_REF_NAME" || echo "No changes to commit" + git push origin docs From 047ecea79bd14eb41770aacd35d856006103048f Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 27 Nov 2024 17:03:51 +0530 Subject: [PATCH 2/5] Made action only to run on `main` or version branch --- .github/workflows/doc.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 00a632299..b9cdd378f 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -2,6 +2,9 @@ name: Generate Documentation on: push: + branches: + - main + - '*.*.*' workflow_dispatch: permissions: From 9a2384c8598c8ebf29aa566d703a8bda48c2c359 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 27 Nov 2024 17:06:30 +0530 Subject: [PATCH 3/5] Moved README.md to BRANCHES.md --- .github/workflows/doc.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index b9cdd378f..9aee73282 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -41,18 +41,18 @@ jobs: rm -rf versioned_docs # Clean up rm -rf target # Clean up - - name: Generate README.md + - name: Generate BRANCHES.md run: | VERSIONS=$(ls -d */ | sed 's#/##' | sort -r) # Get all version directories and sort them (latest first) rm README.md # Delete README.md and generate a new one - echo "# Azalea Docs" > README.md - echo "Welcome to the documentation for Azalea Crate." >> README.md - echo "" >> README.md + echo "# Azalea Docs" > BRANCHES.md + echo "Welcome to the documentation for Azalea Crate." >> BRANCHES.md + echo "" >> BRANCHES.md # Update README.md with available versions - echo "## Available Versions" >> README.md + echo "## Available Versions" >> BRANCHES.md for VERSION in $VERSIONS; do - echo "- [$VERSION](./$VERSION/index.html)" >> README.md + echo "- [$VERSION](https://azalea.matdoes.dev/$VERSION/index.html)" >> BRANCHES.md done echo "README.md updated successfully." From a29be536d5755020c6f0b1f4b3698fb57b3412aa Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 27 Nov 2024 17:07:47 +0530 Subject: [PATCH 4/5] Redirect to main branch by default --- .github/workflows/doc.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 9aee73282..eedc84f3e 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -56,6 +56,12 @@ jobs: done echo "README.md updated successfully." + + - name: Create Index Page + run: | + if [ ! -f index.html ]; then + echo "" > index.html + fi - name: Deploy Documentation to Docs Branch run: | From f1fb20be8149c873af511df9471badd1e535978a Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 27 Nov 2024 17:20:01 +0530 Subject: [PATCH 5/5] Moved Branches.md to branches.html --- .github/workflows/doc.yml | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index eedc84f3e..737f176df 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -41,21 +41,32 @@ jobs: rm -rf versioned_docs # Clean up rm -rf target # Clean up - - name: Generate BRANCHES.md + - name: Generate branches.html run: | VERSIONS=$(ls -d */ | sed 's#/##' | sort -r) # Get all version directories and sort them (latest first) - rm README.md # Delete README.md and generate a new one - echo "# Azalea Docs" > BRANCHES.md - echo "Welcome to the documentation for Azalea Crate." >> BRANCHES.md - echo "" >> BRANCHES.md + echo "" > branches.html + echo "" >> branches.html + echo "" >> branches.html + echo " " >> branches.html + echo " " >> branches.html + echo " Azalea Docs" >> branches.html + echo "" >> branches.html + echo "" >> branches.html + echo "

Azalea Docs

" >> branches.html + echo "

Welcome to the documentation for Azalea Crate.

" >> branches.html + echo "

Available Versions

" >> branches.html + echo "
    " >> branches.html - # Update README.md with available versions - echo "## Available Versions" >> BRANCHES.md + # Update branches.html with available versions for VERSION in $VERSIONS; do - echo "- [$VERSION](https://azalea.matdoes.dev/$VERSION/index.html)" >> BRANCHES.md - done + echo "
  • $VERSION
  • " >> branches.html + done - echo "README.md updated successfully." + echo "
" >> branches.html + echo "" >> branches.html + echo "" >> branches.html + + echo "branches.html generated successfully." - name: Create Index Page run: |