Merge pull request #260 from kinode-dao/hf/output-a-single-md-file #260
This file contains 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
name: Deploy mdBook site to Pages and Create Release | |
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: write | |
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 | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Set up nvm, node, npm p0 | |
run: | | |
echo "$HOME" >> $GITHUB_PATH | |
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV | |
- name: Set up nvm, node, npm p1 | |
run: | | |
source $NVM_DIR/nvm.sh | |
nvm install 20.0.0 | |
nvm --version | |
- name: Set up cargo | |
run: | | |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh | |
rustup update | |
cargo install wasm-tools | |
rustup install nightly | |
rustup target add wasm32-wasip1 --toolchain nightly | |
cargo install cargo-wasi | |
#- name: Get latest release from foundry-rs/foundry | |
# id: get-latest-foundry-release | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# const repo = { | |
# owner: 'foundry-rs', | |
# repo: 'foundry', | |
# per_page: 1, | |
# page: 1, | |
# }; | |
# const releases = await github.rest.repos.listReleases(repo); | |
# const preReleases = releases.data.filter(release => release.prerelease); | |
# // Sort pre-releases by created_at date in descending order | |
# preReleases.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); | |
# if (preReleases.length === 0) { | |
# throw new Error('No pre-releases found'); | |
# } | |
# const latestPreRelease = preReleases[0]; | |
# const asset = latestPreRelease.assets.find(asset => asset.name.match(/foundry_nightly_linux_amd64\.tar\.gz/)); | |
# if (!asset) { | |
# throw new Error('Asset not found'); | |
# } | |
# return asset.browser_download_url; | |
# result-encoding: string | |
- name: Download the Foundry release | |
run: wget -q https://github.com/foundry-rs/foundry/releases/download/nightly-de596a4db781933f0c95805bd1c8c05e65f03d4f/foundry_nightly_linux_amd64.tar.gz -O foundry.tar.gz | |
#run: wget -q ${DOWNLOAD_URL} -O foundry.tar.gz | |
#env: | |
# DOWNLOAD_URL: ${{ steps.get-latest-foundry-release.outputs.result }} | |
- name: Untar the release | |
run: tar zxf foundry.tar.gz | |
- name: Add Foundry to path | |
run: echo "$PWD" >> $GITHUB_PATH | |
- name: Get latest release from kinode-dao/kit | |
id: get-latest-kit-release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const repo = { | |
owner: 'kinode-dao', | |
repo: 'kit', | |
}; | |
const release = await github.rest.repos.getLatestRelease(repo); | |
const asset = release.data.assets.find(asset => asset.name.match(/kit-x86_64-unknown-linux-gnu\.zip/)); | |
if (!asset) { | |
throw new Error('Asset not found'); | |
} | |
return asset.browser_download_url; | |
result-encoding: string | |
- name: Download the Kit release | |
run: wget -q ${DOWNLOAD_URL} -O kit.zip | |
env: | |
DOWNLOAD_URL: ${{ steps.get-latest-kit-release.outputs.result }} | |
- name: Unzip the release | |
run: unzip kit.zip | |
#- name: Get latest release from kinode-dao/kit | |
# id: get-latest-kit-release | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# const repo = { | |
# owner: 'kinode-dao', | |
# repo: 'kinode', | |
# }; | |
# const release = await github.rest.repos.getLatestRelease(repo); | |
# const asset = release.data.assets.find(asset => asset.name.match(/kinode-x86_64-unknown-linux-gnu\.zip/)); | |
# if (!asset) { | |
# throw new Error('Asset not found'); | |
# } | |
# return asset.browser_download_url; | |
# result-encoding: string | |
- name: Download the Kinode release | |
run: wget -q https://files.yael.solutions/240906/kinode-x86_64-unknown-linux-gnu-simulation-mode.zip -O kinode.zip | |
#run: wget -q ${DOWNLOAD_URL} -O kinode.zip | |
#env: | |
# DOWNLOAD_URL: ${{ steps.get-latest-kit-release.outputs.result }} | |
- name: Unzip the Kinode release | |
run: unzip kinode.zip | |
- name: Run Kit tests | |
#run: ./kit t code/tests.toml | |
run: | | |
{ ./kit t code/tests.toml; } 2>&1 | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install mdBook | |
run: | | |
cargo install --git https://github.com/nick1udwig/mdBook --branch hf/output-single-md-file --locked mdbook | |
cargo install mdbook-linkcheck | |
cargo install mdbook-webinclude | |
cargo install --git https://github.com/nick1udwig/mdbook-hide-feature --locked | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v4 | |
- name: Build with mdBook | |
run: mdbook build | |
- name: Upload artifact for deployment | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./book/html | |
- name: Archive built site | |
run: tar -czf book.tar.gz -C book/html . | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ github.run_number }} | |
release_name: Release ${{ github.run_number }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset (.tar.gz) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./book.tar.gz | |
asset_name: book.tar.gz | |
asset_content_type: application/gzip | |
- name: Upload Release Asset (.md) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./book/single-file/book.md | |
asset_name: book.md | |
asset_content_type: text/markdown | |
deploy: | |
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 |