Skip to content

Commit

Permalink
Update ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubark committed Jan 6, 2024
1 parent 9226b9f commit e4ac628
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 18 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/gen-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
publish_dir: ./docs/public
87 changes: 84 additions & 3 deletions .github/workflows/latest-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ on:
paths-ignore:
- '.github/**'
- '**.md'
- 'docs/hugo/**'
- '.gitattributes'
- 'examples/**.cy'
- 'examples/**/*.cy'
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -325,6 +402,8 @@ jobs:
libcyber-macos-arm64.a
cyber-web.wasm
cyber-wasi.wasm
docs.html
docs.md
# Auto dispatch.
- name: Github Release.
Expand All @@ -344,3 +423,5 @@ jobs:
libcyber-macos-arm64.a
cyber-web.wasm
cyber-wasi.wasm
docs.html
docs.md
1 change: 0 additions & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
pull_request:
paths-ignore:
- '.github/**'
- 'docs/hugo/**'
- '**.md'
concurrency:
group: pr-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion docs/gen-docs.cy
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e4ac628

Please sign in to comment.