- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1
 
ci: add build script and configuration for Netlify deployment #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 1 commit
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| #!/usr/bin/env bash | ||
| set -euxo pipefail | ||
| 
     | 
||
| # 1. Install tools | ||
| 
     | 
||
| curl -sS https://webi.sh/sd | sh && source ~/.config/envman/PATH.env | ||
| curl https://mise.run | sh | ||
| 
     | 
||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| # 2. Install dependencies | ||
| 
     | 
||
| mise trust | ||
| mise install | ||
| mise exec -- bun install | ||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| # 3. Prepare common files | ||
| 
     | 
||
| mkdir _site | ||
| 
     | 
||
| # Prepare favicon | ||
| curl -L https://github.com/typst-community/org/raw/main/design/typst-community.icon.png \ | ||
| -o _site/favicon.png | ||
| cp _site/favicon.png public/favicon.png | ||
| 
     | 
||
| # Prepare the index page | ||
| REF=$(git rev-parse --short HEAD) | ||
| DATE=$(git log --max-count=1 --pretty='%cd' --date=iso) | ||
| cat << EOF > _site/index.html | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <title>typst-docs-web</title> | ||
| <style> | ||
| body { | ||
| display: grid; | ||
| place-items: center; | ||
| min-height: 100vh; | ||
| background: #eff0f3; | ||
| } | ||
| 
     | 
||
| body > main { | ||
| padding: 2em; | ||
| border-radius: 1em; | ||
| box-shadow: 0 0 1em #ccc; | ||
| background: white; | ||
| color: #565565; | ||
| 
     | 
||
| li { | ||
| margin-block: 0.5em; | ||
| } | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <main> | ||
| <h1><a href="https://github.com/typst-community/typst-docs-web/">typst-docs-web</a></h1> | ||
| <p>Build a website from the documentation JSON file generated by <a href="https://github.com/typst/typst/blob/main/docs/Cargo.toml#L2">typst-docs</a>.</p> | ||
| <p>This website is for developing typst-docs-web. Its contents might be changed at anytime.</p> | ||
| <ul> | ||
| <li><a href="./en-US-v0.14.0/">en-US, v0.14.0</a></li> | ||
| <li><a href="./en-US-v0.13.1/">en-US, v0.13.1</a></li> | ||
| <li><a href="./ja-JP/">ja-JP, v0.13.1</a></li> | ||
| </ul> | ||
| <p> | ||
| typst-docs-web version: | ||
| <a href="https://github.com/typst-community/typst-docs-web/tree/$REF"><code>$REF</code> ($DATE)</a> | ||
| </p> | ||
| </main> | ||
| </body> | ||
| </html> | ||
| EOF | ||
| 
     | 
||
| # 4. Build | ||
| # 4.1. Build en-US | ||
| 
     | 
||
| build_en_US() { | ||
| local VERSION="$1" | ||
| 
     | 
||
| BASE="en-US-$VERSION" | ||
| 
     | 
||
| # Prepare docs.json | ||
| curl -L https://github.com/typst-community/dev-builds/releases/download/docs-"$VERSION"/docs.json \ | ||
| -o public/docs.json | ||
| sd '/DOCS-BASE/' "/$BASE/" public/docs.json | ||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| # Prepare docs assets | ||
| curl -LO https://github.com/typst-community/dev-builds/releases/download/docs-"$VERSION"/docs-assets.zip | ||
| unzip docs-assets.zip && rm docs-assets.zip | ||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| mv assets public/assets | ||
| 
     | 
||
| # Configure metadata | ||
| cat << EOF > public/metadata.json | ||
| { | ||
| "\$schema": "../metadata.schema.json", | ||
| "language": "en-US", | ||
| "version": "${VERSION#v}", | ||
| "typstOfficialUrl": "https://typst.app", | ||
| "typstOfficialDocsUrl": "https://typst.app/docs/", | ||
| "githubOrganizationUrl": "https://github.com/typst-community", | ||
| "githubRepositoryUrl": "https://github.com/typst-community/typst-docs-web", | ||
| "discordServerUrl": "https://discord.gg/2uDybryKPe", | ||
| "originUrl": "$DEPLOY_URL/", | ||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| "basePath": "/$BASE/", | ||
| "displayTranslationStatus": false | ||
| } | ||
| EOF | ||
| # $DEPLOY_URL is set by netlify. | ||
| # https://docs.netlify.com/build/configure-builds/environment-variables/#deploy-urls-and-metadata | ||
| 
     | 
||
| # Build | ||
| mise exec -- bun run build | ||
| mv dist _site/"$BASE" | ||
| 
     | 
||
| # Clean | ||
| rm -r public/{docs.json,assets,metadata.json} | ||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| } | ||
| 
     | 
||
| build_en_US v0.14.0 | ||
| build_en_US v0.13.1 | ||
| 
     | 
||
| # 4.2. Build ja-JP | ||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| # Prepare files | ||
| mise exec -- bun run fetch-docs-ja-jp | ||
| sd '"/docs/' '"/ja-JP/' public/docs.json | ||
| sd --fixed-strings \ | ||
| '"basePath": "/docs/",' \ | ||
| '"basePath": "/ja-JP/",' \ | ||
| public/metadata.json | ||
| 
     | 
||
| # Build | ||
| mise exec -- bun run build | ||
| mv dist _site/ja-JP | ||
| 
     | 
||
| # Clean | ||
| rm -r public/{docs,metadata,translation-status}.json | ||
                
      
                  YDX-2147483647 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build] | ||
| command = "bash netlify-build.sh" | ||
| publish = "_site" | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.