Skip to content

Commit

Permalink
try building website
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnite committed Nov 1, 2024
1 parent 03a313d commit 89430b2
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 259 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/publish-github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish Github Pages
on:
push:
branches: [main]

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0

- name: Build
run: zig build

- name: Upload Artifact
uses: actions/upload-pages-artifact
id: deployment
with:
path: zig-out/www


# Deploy job
deploy:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
92 changes: 0 additions & 92 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ pub fn build(b: *Build) void {
const package_step = b.step("package", "Package monorepo using boxzer");
package_step.dependOn(&boxzer_run.step);

//const website_dep = b.dependency("website", .{});
//const website_step = b.step("website", "Build website");
//website_step.dependOn(website_dep.builder.getInstallStep());

const parts_db = generate_parts_db(b) catch @panic("OOM");
const parts_db_json = b.addInstallFile(parts_db, "parts-db.json");
package_step.dependOn(&parts_db_json.step);

const test_ports_step = b.step("run-port-tests", "Run all platform agnostic tests for Ports");
inline for (ports) |port| {
const port_dep = b.dependency(port[0], .{});
Expand All @@ -63,87 +55,3 @@ pub fn build(b: *Build) void {
}
}
}

const PartsDb = struct {
chips: []const Chip,
boards: []const Board,

const Chip = struct {
identifier: []const u8,
port_package: []const u8,
url: ?[]const u8,
cpu: []const u8,
has_hal: bool,
memory: struct {
flash: u64,
ram: u64,
},
output_format: ?[]const u8,
};
const Board = struct {
identifier: []const u8,
port_package: []const u8,
chip_idx: u32,
url: ?[]const u8,
output_format: ?[]const u8,
};
};

fn generate_parts_db(b: *Build) !Build.LazyPath {
var chips = std.ArrayList(PartsDb.Chip).init(b.allocator);
var boards = std.ArrayList(PartsDb.Board).init(b.allocator);

@setEvalBranchQuota(20000);
inline for (ports) |port| {
const chips_start_idx = chips.items.len;
inline for (@typeInfo(@field(port[1], "chips")).Struct.decls) |decl| {
if (@typeInfo(@TypeOf(@field(@field(port[1], "chips"), decl.name))) != .Struct)
continue;

const target = @field(@field(port[1], "chips"), decl.name);
try chips.append(.{
.identifier = decl.name,
.port_package = port[0],
.url = target.chip.url,
.cpu = target.chip.cpu.name,
.has_hal = target.hal != null,
.memory = .{
.flash = 0,
.ram = 0,
},
.output_format = null,
});
}

inline for (@typeInfo(@field(port[1], "boards")).Struct.decls) |decl| {
const target = @field(@field(port[1], "boards"), decl.name);
_ = target;
_ = chips_start_idx;

//const chip_idx = inline for (@typeInfo(@field(port[1], "chips")).Struct.decls, 0..) |chip_decl, idx| {
// const chip = @field(@field(port[1], "chips"), chip_decl.name);
// if (std.mem.eql(u8, chip.chip.name, target.chip.name))
// break chips_start_idx + idx;
//} else @compileError("failed to get chip_idx");

try boards.append(.{
.identifier = decl.name,
.port_package = port[0],
.chip_idx = 0,
.url = "",
.output_format = null,
});
}
}

const parts_db = PartsDb{
.chips = chips.items,
.boards = boards.items,
};

const parts_db_str = try std.json.stringifyAlloc(b.allocator, parts_db, .{
.whitespace = .indent_4,
});
const write_file_step = b.addWriteFiles();
return write_file_step.add("parts-db.json", parts_db_str);
}
31 changes: 0 additions & 31 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
# Zig Embedded Group - Website and Articles

This project both contains the contents and the generation of the ZEG website.

## Folder Structure

```
.
├── build.zig
├── deps Contains submodule dependencies
│ └── …
├── LICENCE
├── README.md
├── render Not included in the repo, will contain the rendered website
│ └── …
├── src Source of the website generator and other tools
│ └── main.zig
└── website Contains the raw input data for the website
├── articles Contains all articles in the format `YYYY-MM-dd - ${TITLE}.md`
│ └── …
├── img Contains the images used on the website.
│ └── …
├── index.md Index page of the website
└── tutorials Contains the raw tutorial files
└── …
```

## Markdown

The website uses basic markdown that allows GFM style tables and also supports *some* placeholders:

- `<!-- TOC -->` will insert a table of contents if alone in a single line. The ToC will be rendered in the same depth as the next heading, so everything higher in the hierarchy will be ignored.
- `<!-- ARTICLES -->` renders a list of all available articles
- `<!-- ARTICLES10 -->` renders a list of the 10 latest articles
42 changes: 0 additions & 42 deletions website/WIP.md

This file was deleted.

10 changes: 5 additions & 5 deletions website/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const std = @import("std");
const zine = @import("zine");

pub fn build(b: *std.Build) void {
// zine.scriptyReferenceDocs(b, "content/documentation/scripty/index.md");
zine.website(b, .{
.layouts_dir_path = "layouts",
.content_dir_path = "content",
.static_dir_path = "static",
.host_url = "https://microzig.tech",
.title = "Zig Embedded Group",
.host_url = "https://ZigEmbeddedGroup/github.io/microzig",
.content_dir_path = "content",
.layouts_dir_path = "layouts",
.assets_dir_path = "assets",
.output_path_prefix = "www",
});
}
4 changes: 2 additions & 2 deletions website/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
.paths = .{"."},
.dependencies = .{
.zine = .{
.url = "git+https://github.com/kristoff-it/zine#e21b179b78de54ab48efe38d2378e87a56cb3542",
.hash = "1220781f118454bbc87d7efbd244b4d1ef029e76a6113ddf4752a6f3cd85879dbb3b",
.url = "git+https://github.com/kristoff-it/zine.git#afebddd2aa1ac284d2d514c7eb5ebf03b01c5678",
.hash = "1220c3950d2e36fe1e64cc6c9694c38f20c54cf82842b0f5a1fb8d2c446feeed9e01",
},
},
}
Empty file removed website/content/articles/.keep
Empty file.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 89430b2

Please sign in to comment.