Skip to content

Commit

Permalink
website, nuke build & publishing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lumi2021 committed Aug 9, 2024
1 parent 532cebd commit 97a5f5d
Show file tree
Hide file tree
Showing 67 changed files with 18,652 additions and 29 deletions.
60 changes: 33 additions & 27 deletions .github/workflows/publish-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,46 @@ on:
push:
branches:
- 'main'

workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

env:
NODE_OPTIONS: --max-old-space-size=6144

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.401
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.201
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.102
- name: Run Statiq
run: dotnet run -c Release --project src/Website/Silk.NET.Statiq/Silk.NET.Statiq.csproj -- -l debug --nocache
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: "docs"
Deploy:
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@v1
- name: Checkout
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: yarn

- name: Install dependencies
working-directory: ./website
run: yarn install --frozen-lockfile --non-interactive

- name: Build
working-directory: ./website
run: yarn build

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: build
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
"ValidateSolution",
"Vkd3d",
"VulkanLoader",
"Website",
"Wgpu"
]
}
Expand Down Expand Up @@ -216,6 +217,7 @@
"ValidateSolution",
"Vkd3d",
"VulkanLoader",
"Website",
"Wgpu"
]
}
Expand Down
2 changes: 1 addition & 1 deletion build/nuke/Build.Core.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.IO;
Expand Down
120 changes: 120 additions & 0 deletions build/nuke/Build.Website.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;
using System.Runtime.InteropServices;
using Nuke.Common;
using Nuke.Common.ProjectModel;
using Nuke.Common.Utilities.Collections;
using Nuke.Common.Tools.Npm;

partial class Build
{
static string workingDirectory = "./website";

Target Website => _ => _
.Executes(() =>
{
Console.WriteLine("Verifying dependences:\n");
Assert.True(VerifyDependences());
if (Configuration == "Debug")
{
Console.WriteLine("Running website in debug mode (it may take a while)");
NpmTasks.Npm("run docusaurus start", workingDirectory, null, null, false);
}
else
{
Console.WriteLine("Building website for production");
NpmTasks.Npm("run docusaurus build", workingDirectory);
}
});

static bool VerifyDependences()
{
Console.Write("Node.js ... ");

var nodePath = GetExecutablePath("node");
if (string.IsNullOrEmpty(nodePath))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\rNode.js not found!\n");
Console.ResetColor();
Console.WriteLine("Please, make sure node.js is installed on your machine!");
Console.WriteLine("Dowload node here => https://nodejs.org/en/download");
Console.WriteLine();
return false;
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK");
Console.ResetColor();
}

Console.Write("Node Package Mananger ... ");

var npmPath = GetExecutablePath("npm");
if (string.IsNullOrEmpty(nodePath))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\rNode Package Mananger not found!\n");
Console.ResetColor();
Console.WriteLine("Please, make sure node.js is working and updated on your machine!");
Console.WriteLine();
return false;
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK");
Console.ResetColor();
}

Console.Write("Node Modules ... ");

if (!Directory.Exists($"{workingDirectory}/node_modules"))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\rNode modules not found. Installing modules...\n");
Console.ResetColor();

NpmTasks.Npm("install", workingDirectory);

Console.Write("Node Modules ... ");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK");
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("OK");
Console.ResetColor();
}

return true;
}

static string GetExecutablePath(string execName)
{
var paths = Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator);

string[] extensions = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Environment.GetEnvironmentVariable("PATHEXT").Split(';')
: [""];

foreach (var path in paths)
{
foreach (var ext in extensions)
{
var fullPath = Path.Combine(path, execName + ext.ToLower());
if (File.Exists(fullPath)) return fullPath;
}
}

return null;
}
}
8 changes: 7 additions & 1 deletion build/nuke/Build.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Nuke.Common;
using Nuke.Common.Execution;

partial class Build : NukeBuild
{
Expand All @@ -24,6 +26,10 @@ partial class Build : NukeBuild
// Deployment
// ----------
// - Build.NuGet.cs - targets for pushing NuGet packages to the NuGet Gallery (or some other feed).
// ----------
// Website
// ----------
// - Build.Website.cs - targets for testing and building the docusaurus website.
// -------------
// Miscellaneous
// -------------
Expand Down
25 changes: 25 additions & 0 deletions build/nuke/nuke.generated.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Silk.NET.NUKE", "Silk.NET.NUKE.csproj", "{67DA7859-4BE8-425E-9C46-41842A134D0B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{67DA7859-4BE8-425E-9C46-41842A134D0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67DA7859-4BE8-425E-9C46-41842A134D0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67DA7859-4BE8-425E-9C46-41842A134D0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67DA7859-4BE8-425E-9C46-41842A134D0B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5FF51335-FB2D-46BD-AE9C-ED3C6113B513}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 3 additions & 0 deletions website/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
17 changes: 17 additions & 0 deletions website/blog/2024-02-14-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Still in development!
description: This is my first post on Docusaurus.
slug: welcome-docusaurus-v2
authors:
- name: Lumi
url: https://github.com/lumi2021
image_url: https://github.com/lumi2021.png

tags: [test, Silk.NET, .NET]
image: https://i.imgur.com/mErPwqL.png
hide_table_of_contents: false
---

Blogs will still be reinplemented! sorry!

<!-- truncate -->
8 changes: 8 additions & 0 deletions website/docs/getStarted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
sidebar_position: 1
---

# Get Started

# Coming soon! :sweat_smile:
This tutorial is currently work-in-progress.
Loading

0 comments on commit 97a5f5d

Please sign in to comment.