Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ on:
branches: [main]
paths:
- 'docs/**'
- 'tools/publisher/**'
- 'README*.md'
- 'mkdocs.yml'
- '.github/workflows/docs.yml'
pull_request:
paths:
- 'docs/**'
- 'tools/publisher/**'
- 'README*.md'
- 'mkdocs.yml'
- '.github/workflows/docs.yml'
workflow_dispatch:
Expand All @@ -32,6 +36,15 @@ jobs:
with:
fetch-depth: 0

- name: Set up Node for publisher tooling
uses: actions/setup-node@v4
with:
node-version: 22
- name: Check shared publisher attribution
run: |
npm ci --prefix tools/publisher --ignore-scripts
npm run check --prefix tools/publisher

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/publisher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publisher attribution
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci --prefix tools/publisher --ignore-scripts
- run: npm run check --prefix tools/publisher
6 changes: 5 additions & 1 deletion README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<a href="https://devslab.kr/brand/open-source/"><img src=".github/assets/readme-header.png" alt="devslab-kit - DevsLab 오픈소스" width="100%" /></a>
</p>

**[DevsLab](https://devslab.kr/) 오픈소스** · [OSS 브랜드 가이드](https://devslab.kr/brand/open-source/) · 레지스트리 O10
<!-- publisher:start -->
Open source by [데브스랩(DevsLab)](https://devslab.kr/).
<!-- publisher:end -->

[OSS 브랜드 가이드](https://devslab.kr/brand/open-source/) · 레지스트리 O10

[![Maven Central](https://img.shields.io/maven-central/v/kr.devslab/devslab-kit-spring-boot-starter?logo=apachemaven)](https://central.sonatype.com/artifact/kr.devslab/devslab-kit-spring-boot-starter)
[![Build](https://github.com/devslab-kr/devslab-kit/actions/workflows/build.yml/badge.svg)](https://github.com/devslab-kr/devslab-kit/actions/workflows/build.yml)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<a href="https://devslab.kr/brand/open-source/"><img src=".github/assets/readme-header.png" alt="devslab-kit - Open source by DevsLab" width="100%" /></a>
</p>

**Open source by [DevsLab](https://devslab.kr/)** · [OSS brand guide](https://devslab.kr/brand/open-source/) · Registry O10
<!-- publisher:start -->
Open source by [데브스랩(DevsLab)](https://devslab.kr/).
<!-- publisher:end -->

[OSS brand guide](https://devslab.kr/brand/open-source/) · Registry O10

[![Maven Central](https://img.shields.io/maven-central/v/kr.devslab/devslab-kit-spring-boot-starter?logo=apachemaven)](https://central.sonatype.com/artifact/kr.devslab/devslab-kit-spring-boot-starter)
[![Build](https://github.com/devslab-kr/devslab-kit/actions/workflows/build.yml/badge.svg)](https://github.com/devslab-kr/devslab-kit/actions/workflows/build.yml)
Expand Down
5 changes: 5 additions & 0 deletions docs/overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
<meta name="twitter:image" content="https://devslab-kit.devslab.kr/assets/social-preview.png">
<meta name="twitter:image:alt" content="devslab-kit, Open source by DevsLab">
{% endblock %}

{% block footer %}
<div class="md-grid">{% include "publisher.html" %}</div>
{{ super() }}
{% endblock %}
5 changes: 5 additions & 0 deletions docs/overrides/publisher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- publisher:start -->
<p class="publisher-attribution">Open source by <a href="https://devslab.kr/">데브스랩(DevsLab)</a>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Organization","@id":"https://devslab.kr/#organization","name":"DevsLab","url":"https://devslab.kr/","alternateName":["데브스랩","devslab"],"sameAs":["https://github.com/devslab-kr","https://devslab-kr.github.io/"]}</script></p>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"SoftwareSourceCode","@id":"https://github.com/devslab-kr/devslab-kit#software","name":"devslab-kit","url":"https://devslab-kit.devslab.kr/","codeRepository":"https://github.com/devslab-kr/devslab-kit","publisher":{"@id":"https://devslab.kr/#organization"}}</script>
<!-- publisher:end -->
4 changes: 2 additions & 2 deletions scripts/check-brand-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ assert(!logo.includes('M7 6H21V20H7Z'), 'docs logo must not use the O08 geometry
assert(!logo.includes('M5 8H13V14H5Z'), 'docs logo must not use the O09 geometry');

for (const [file, endorsement] of [
['README.md', 'Open source by [DevsLab](https://devslab.kr/)'],
['README.ko.md', '[DevsLab](https://devslab.kr/) 오픈소스'],
['README.md', 'Open source by [데브스랩(DevsLab)](https://devslab.kr/)'],
['README.ko.md', 'Open source by [데브스랩(DevsLab)](https://devslab.kr/)'],
['docs/index.md', 'Open source by DevsLab'],
['docs/index.ko.md', 'DevsLab 오픈소스'],
]) {
Expand Down
1 change: 1 addition & 0 deletions tools/publisher/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
9 changes: 9 additions & 0 deletions tools/publisher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Publisher attribution

Documentation-only tooling; this dependency is not shipped with the library.

`npm ci --prefix tools/publisher` installs the pinned shared publisher helper.
`npm run sync --prefix tools/publisher` regenerates the marked README and public HTML attribution from `@devslab/site-kit/devslab`.
`npm run check --prefix tools/publisher` detects drift without writing files.

Edit the product URL or repository in `config.json`; update the shared preset in site-kit for company-wide identity changes. Do not hand-edit generated publisher blocks.
7 changes: 7 additions & 0 deletions tools/publisher/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "devslab-kit",
"kind": "mkdocs",
"url": "https://devslab-kit.devslab.kr/",
"repository": "https://github.com/devslab-kr/devslab-kit",
"pages": []
}
118 changes: 118 additions & 0 deletions tools/publisher/package-lock.json

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

12 changes: 12 additions & 0 deletions tools/publisher/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "devslab-kit-publisher-docs",
"private": true,
"type": "module",
"scripts": {
"sync": "node sync.mjs",
"check": "node sync.mjs --check"
},
"devDependencies": {
"@devslab/site-kit": "0.8.0"
}
}
50 changes: 50 additions & 0 deletions tools/publisher/sync.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { readFile, writeFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { buildPublisher, renderPublisherHtml, serializeJsonLd } from "@devslab/site-kit";
import { DEVSLAB_PUBLISHER } from "@devslab/site-kit/devslab";

const root = new URL("../../", import.meta.url);
const config = JSON.parse(await readFile(new URL("./config.json", import.meta.url), "utf8"));
const check = process.argv.includes("--check");
const { link, reference } = buildPublisher(DEVSLAB_PUBLISHER);
const start = "<!-- publisher:start -->";
const end = "<!-- publisher:end -->";
const markdown = `${start}\n${config.attributionLabel ?? "Open source by"} [${link.label}](${link.href}).\n${end}`;
const source = {
"@context": "https://schema.org",
"@type": "SoftwareSourceCode",
"@id": `${config.repository}#software`,
name: config.name,
url: config.url,
codeRepository: config.repository,
publisher: reference,
};
const html = `${start}\n<p class="publisher-attribution">Open source by ${renderPublisherHtml(DEVSLAB_PUBLISHER)}</p>\n<script type="application/ld+json">${serializeJsonLd(source)}</script>\n${end}`;

async function update(relative, transform) {
const url = new URL(relative, root);
const current = (await readFile(url, "utf8").catch((error) => {
if (error.code === "ENOENT") return "";
throw error;
})).replaceAll("\r\n", "\n");
const next = transform(current);
if (current === next) return;
if (check) throw new Error(`Publisher output is stale: ${fileURLToPath(url)}; run npm run sync --prefix tools/publisher`);
await writeFile(url, next);
}
function replaceBlock(text, value) {
const from = text.indexOf(start);
const to = text.indexOf(end);
if (from < 0 || to < from) throw new Error("Missing publisher markers");
return text.slice(0, from) + value + text.slice(to + end.length);
}
for (const path of config.readmes ?? ["README.md", "README.ko.md"]) {
await update(path, (text) => replaceBlock(text, markdown));
}
if (config.kind === "mkdocs") {
await update("docs/overrides/publisher.html", () => html + "\n");
}
for (const path of config.pages) {
await update(path, (text) => replaceBlock(text, html));
}
console.log(check ? "Publisher output is current." : "Publisher output synchronized.");
Loading