diff --git a/.github/workflows/gen-docs.yml b/.github/workflows/gen-docs.yml index a1d257aa2..8f5ec973a 100644 --- a/.github/workflows/gen-docs.yml +++ b/.github/workflows/gen-docs.yml @@ -6,35 +6,47 @@ on: branches: - master paths: - - 'docs/hugo/**' + - 'docs/**' + - 'src/builtins/**' jobs: deploy: runs-on: ubuntu-22.04 + env: + ZIG_VERSION: 0.11.0 steps: - - uses: actions/checkout@v3 + - name: Clone repo. + uses: actions/checkout@v3 with: submodules: false fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod - - name: Install theme. + - name: Install zig. run: | - git clone --depth=1 https://github.com/alex-shpak/hugo-book docs/hugo/themes/hugo-book + wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin - - name: Install Hugo. - uses: peaceiris/actions-hugo@v2 + - name: Cache. + uses: actions/cache@v2 with: - hugo-version: 'latest' - # Needed to build SCSS/SASS with transpiler set to 'libsass' - extended: true + path: |- + ~/.cache/zig + zig-cache + key: + build-1 + restore-keys: + build-1 - - name: Generate. + - name: Build Cyber. + run: zig build cli + + - name: Generate docs. run: | - cd docs/hugo - hugo --minify + zig-out/bin/cyber docs/gen-docs.cy + mkdir -p docs/public + mv docs/docs.html docs/public/index.html - name: Deploy. uses: peaceiris/actions-gh-pages@v3 if: github.ref == 'refs/heads/master' with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/hugo/public \ No newline at end of file + publish_dir: ./docs/public \ No newline at end of file diff --git a/.github/workflows/latest-build.yml b/.github/workflows/latest-build.yml index 898799e79..9049a5eba 100644 --- a/.github/workflows/latest-build.yml +++ b/.github/workflows/latest-build.yml @@ -14,7 +14,6 @@ on: paths-ignore: - '.github/**' - '**.md' - - 'docs/hugo/**' - '.gitattributes' - 'examples/**.cy' - 'examples/**/*.cy' @@ -295,8 +294,86 @@ jobs: short_version: ${{ env.SHORT_VERSION }} # version: ${{ env.BUILD_VERSION }} + docs: + runs-on: ubuntu-22.04 + env: + ZIG_VERSION: 0.11.0 + steps: + - name: Clone repo. + uses: actions/checkout@v3 + with: + submodules: false + fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + + - name: Install zig. + run: | + wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin + + - name: Setup script. + uses: actions/github-script@v5 + with: + script: | + async function execCmd(name, args) { + const opts = {}; + let out = ''; + let err = ''; + opts.listeners = { + stdout: (data) => { + out += data.toString(); + }, + stderr: (data) => { + process.stderr.write(data.toString()); + } + }; + // opt.cwd = './lib'; + await exec.exec(name, args, opts); + return out; + } + const version = await execCmd('zig', ['build', 'version']); + core.exportVariable('SHORT_VERSION', version); + await execCmd('git', ['fetch', '--all', '--tags']); + const build = await execCmd('git', ['rev-list', '--count', `${version}..${context.sha}`]) + core.exportVariable('BUILD', build.trim()); + core.exportVariable('COMMIT', context.sha.substring(0, 7)); + + - name: Cache. + uses: actions/cache@v2 + with: + path: |- + ~/.cache/zig + zig-cache + key: + build-1 + restore-keys: + build-1 + + - name: Build Cyber. + run: zig build cli + + - name: Generate docs. (Release) + if: startsWith(github.ref, 'refs/tags/') + run: | + zig-out/bin/cyber docs/gen-docs.cy -version ${{'v' + env.SHORT_VERSION}} + mv docs/docs-modules.md docs.md + mv docs/docs.html docs.html + + - name: Generate docs. (Dev) + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + run: | + zig-out/bin/cyber docs/gen-docs.cy -version "${{'v' + env.SHORT_VERSION + '-dev ' + env.BUILD + '-' + env.COMMIT}}" + mv docs/docs-modules.md docs.md + mv docs/docs.html docs.html + + - name: Save artifact. + uses: actions/upload-artifact@v2 + with: + name: bin + path: | + docs.html + docs.md + release: - needs: build + needs: [build, docs] name: Release runs-on: ubuntu-22.04 steps: @@ -312,7 +389,7 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} automatic_release_tag: latest prerelease: false - title: v${{ needs.build.outputs.short_version }}-Latest + title: v${{ needs.build.outputs.short_version }}-dev files: | cyber-linux-x64.tar.gz cyber-selinux-x64.tar.gz @@ -325,6 +402,8 @@ jobs: libcyber-macos-arm64.a cyber-web.wasm cyber-wasi.wasm + docs.html + docs.md # Auto dispatch. - name: Github Release. @@ -344,3 +423,5 @@ jobs: libcyber-macos-arm64.a cyber-web.wasm cyber-wasi.wasm + docs.html + docs.md diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 662231c1d..6387d7d3c 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -11,7 +11,6 @@ on: pull_request: paths-ignore: - '.github/**' - - 'docs/hugo/**' - '**.md' concurrency: group: pr-${{ github.ref }} diff --git a/docs/gen-docs.cy b/docs/gen-docs.cy index 2b82be4c1..7cc147013 100644 --- a/docs/gen-docs.cy +++ b/docs/gen-docs.cy @@ -11,7 +11,7 @@ import os import md '../src/tools/md4c.cy' var args = os.parseArgs([ - [ name: 'version', type: string, default: 'v0.4-dev' ], + [ name: 'version', type: string, default: 'dev' ], ]) genDocsModules()