Skip to content

Commit d5936ff

Browse files
committed
chore(moonapi): publish under the moonbitstack namespace on mooncakes, with an opt-in release workflow.
Signed-off-by: Leo Cheng (heke1228) <chengkelfan@qq.com>
1 parent 502d87d commit d5936ff

30 files changed

Lines changed: 121 additions & 55 deletions

File tree

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
# A version tag publishes this module to mooncakes under the moonbitstack account. Publishing is
4+
# opt-in: the publish job runs only while the organization (or repository) variable
5+
# MOONCAKES_PUBLISH is 'true', so a tag with the switch off only runs the tests.
6+
on:
7+
push:
8+
tags: ["v*"]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
persist-credentials: false
21+
22+
- name: install moonbit
23+
run: |
24+
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
25+
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
26+
27+
- name: test
28+
run: |
29+
moon update
30+
moon check --target all --deny-warn
31+
moon test --target all
32+
33+
publish:
34+
needs: test
35+
if: vars.MOONCAKES_PUBLISH == 'true'
36+
runs-on: ubuntu-latest
37+
environment: mooncakes
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
persist-credentials: false
42+
43+
- name: install moonbit
44+
run: |
45+
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
46+
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
47+
48+
- name: check tag and namespace
49+
run: |
50+
version="$(sed -n 's/^version = "\(.*\)"/\1/p' moon.mod)"
51+
grep -q '^name = "moonbitstack/' moon.mod || { echo "::error::moon.mod is not under moonbitstack"; exit 1; }
52+
if [ "$GITHUB_REF_TYPE" = tag ] && [ "${GITHUB_REF_NAME##*v}" != "$version" ]; then
53+
echo "::error::tag $GITHUB_REF_NAME does not match moon.mod version $version"; exit 1
54+
fi
55+
56+
- name: publish
57+
env:
58+
CREDENTIALS: ${{ secrets.MOONCAKES_CREDENTIALS }}
59+
run: |
60+
if [ -z "$CREDENTIALS" ]; then echo "::error::MOONCAKES_CREDENTIALS is not available"; exit 1; fi
61+
trap 'rm -f ~/.moon/credentials.json' EXIT
62+
printf '%s' "$CREDENTIALS" > ~/.moon/credentials.json
63+
moon update
64+
moon publish

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
[![Check and Test](https://github.com/moonbitstack/moonapi/actions/workflows/ci.yml/badge.svg)](https://github.com/moonbitstack/moonapi/actions/workflows/ci.yml)
88
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
9-
[![mooncakes](https://img.shields.io/badge/mooncakes-Lfan--ke%2Fmoonapi-brightgreen)](https://mooncakes.io/docs/Lfan-ke/moonapi)
9+
[![mooncakes](https://img.shields.io/badge/mooncakes-Lfan--ke%2Fmoonapi-brightgreen)](https://mooncakes.io/docs/moonbitstack/moonapi)
1010

1111
</div>
1212

13+
> Moved on mooncakes from `Lfan-ke/moonapi` to `moonbitstack/moonapi`.
14+
1315
`moonapi` builds an [`AsgiApp`](https://github.com/moonbitstack/moonasgi) from typed routes and generates its own **OpenAPI / Swagger** document — the role FastAPI plays for Python. It depends only on `moonasgi`, so it's backend-agnostic (routing and OpenAPI run in-process on every backend); a server such as [`mooncat`](https://github.com/moonbitstack/mooncat) runs the resulting app.
1416

1517
```mermaid

docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
<a href="#security-extractors"><span class="at">§</span>Security extractors</a>
118118
<a href="#signatures"><span class="at">§</span>Signature primitives</a>
119119
<a href="#di-demo"><span class="at">§</span>Dependency injection worked example</a>
120-
</nav><button class="theme-btn" id="theme">◐ toggle theme</button><div class="side-foot"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><a href="https://mooncakes.io/docs/Lfan-ke/moonapi"><img alt="mooncakes" src="https://img.shields.io/badge/mooncakes-Lfan--ke%2Fmoonapi-1f6feb"></a></div></aside>
121-
<main><header class="hero"><h1>moonapi</h1><p class="tag">A typed web framework for MoonBit &#8212; FastAPI-style routing and multi-version OpenAPI, on the moonasgi SEAM. Backend-agnostic &#8212; the async transport lives in the server (mooncat) that runs the app.</p><div class="badges"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><img alt="tests" src="https://img.shields.io/badge/tests-86%20passing%20%C3%974%20backends-0ca678"><a href="https://github.com/moonbitstack/moonapi"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-source-24292f?logo=github"></a><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-6d5efc"></div><div class="install"><span class="prompt">$</span><code>moon add Lfan-ke/moonapi</code><button class="copy" data-copy="moon add Lfan-ke/moonapi">copy</button></div><div class="contract"><h2><span class="spark">&#10038;</span> The contract at a glance</h2><pre><span class="k">let</span> app = <span class="ty">App</span>::new()
120+
</nav><button class="theme-btn" id="theme">◐ toggle theme</button><div class="side-foot"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><a href="https://mooncakes.io/docs/moonbitstack/moonapi"><img alt="mooncakes" src="https://img.shields.io/badge/mooncakes-Lfan--ke%2Fmoonapi-1f6feb"></a></div></aside>
121+
<main><header class="hero"><h1>moonapi</h1><p class="tag">A typed web framework for MoonBit &#8212; FastAPI-style routing and multi-version OpenAPI, on the moonasgi SEAM. Backend-agnostic &#8212; the async transport lives in the server (mooncat) that runs the app.</p><div class="badges"><a href="https://github.com/moonbitstack/moonapi/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/moonbitstack/moonapi/ci.yml?branch=master&label=CI&logo=github"></a><img alt="tests" src="https://img.shields.io/badge/tests-86%20passing%20%C3%974%20backends-0ca678"><a href="https://github.com/moonbitstack/moonapi"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-source-24292f?logo=github"></a><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-6d5efc"></div><div class="install"><span class="prompt">$</span><code>moon add moonbitstack/moonapi</code><button class="copy" data-copy="moon add moonbitstack/moonapi">copy</button></div><div class="contract"><h2><span class="spark">&#10038;</span> The contract at a glance</h2><pre><span class="k">let</span> app = <span class="ty">App</span>::new()
122122
app.get(&quot;/users/:id&quot;, ctx =&gt; text(200, &quot;user &quot; + ctx.param(&quot;id&quot;).unwrap()))
123123

124124
<span class="k">let</span> spec = app.openapi_json(version=<span class="ty">OpenApi31</span>) // also <span class="ty">OpenApi30</span> / <span class="ty">Swagger20</span>
@@ -412,7 +412,7 @@
412412
<div class="item" data-k="enum"><span class="kind">enum</span><pre class="sig"><span class="k">enum</span> <span class="ty">Dep</span></pre><p class="doc">The dependency value type of the greet app. A sum type wrapping every dependency this app injects — the explicit, exhaustive stand-in for FastAPI resolving heterogeneous <code>Depends</code> values dynamically.</p></div>
413413
<div class="item" data-k="fn"><span class="kind">fn</span><pre class="sig"><span class="k">fn</span> greet_app(container : <span class="ty">Container</span>[<span class="ty">Dep</span>]) <span class="op">-&gt;</span> <span class="ty">App</span></pre><p class="doc">Build the greet application over a caller-supplied dependency <code>container</code>, so a test can register <code>dependency_overrides</code> on the same container before or between requests. <code>POST /greet</code> resolves the <code>&quot;greeting&quot;</code> dependency, reads a validated <code>GreetReq</code> body, and answers <code>{&quot;message&quot;: &quot;&lt;greeting&gt;, &lt;name&gt;&quot;}</code>; a malformed body gets a FastAPI-shaped <code>422</code>. The dependency scope brackets each request, so any <code>yield</code> teardown runs once the handler returns.</p></div>
414414
</section>
415-
<footer>Generated from source <code>///</code> doc-comments · <a href="https://mooncakes.io/docs/Lfan-ke/moonapi">mooncakes</a> · <a href="https://github.com/moonbitstack/moonapi">GitHub</a> · Apache-2.0 &#169; Leo Cheng</footer>
415+
<footer>Generated from source <code>///</code> doc-comments · <a href="https://mooncakes.io/docs/moonbitstack/moonapi">mooncakes</a> · <a href="https://github.com/moonbitstack/moonapi">GitHub</a> · Apache-2.0 &#169; Leo Cheng</footer>
416416
</main></div><script>
417417
document.addEventListener("DOMContentLoaded",()=>{
418418
document.querySelectorAll("[data-copy]").forEach(btn=>btn.addEventListener("click",()=>{

examples/01-openapi/moon.pkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
"Lfan-ke/moonapi",
3-
"Lfan-ke/moonasgi",
2+
"moonbitstack/moonapi",
3+
"moonbitstack/moonasgi",
44
"moonbitlang/core/encoding/utf8",
55
}
66

examples/02-routing/moon.pkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
"Lfan-ke/moonapi",
3-
"Lfan-ke/moonasgi",
2+
"moonbitstack/moonapi",
3+
"moonbitstack/moonasgi",
44
"moonbitlang/core/encoding/utf8",
55
}
66

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
"Lfan-ke/moonapi",
2+
"moonbitstack/moonapi",
33
}
44

55
pkgtype(kind: "executable")

examples/04-descriptors/moon.pkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
"Lfan-ke/moonapi",
3-
"Lfan-ke/moonasgi",
2+
"moonbitstack/moonapi",
3+
"moonbitstack/moonasgi",
44
"moonbitlang/core/encoding/utf8",
55
}
66

examples/05-constraints/moon.pkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
"Lfan-ke/moonapi",
3-
"Lfan-ke/moonasgi",
2+
"moonbitstack/moonapi",
3+
"moonbitstack/moonasgi",
44
"moonbitlang/core/encoding/utf8",
55
}
66

examples/06-typed-body/moon.pkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
"Lfan-ke/moonapi",
3-
"Lfan-ke/moonasgi",
2+
"moonbitstack/moonapi",
3+
"moonbitstack/moonasgi",
44
"moonbitlang/core/encoding/utf8",
55
}
66

examples/07-request-extractors/moon.pkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
"Lfan-ke/moonapi",
3-
"Lfan-ke/moonasgi",
2+
"moonbitstack/moonapi",
3+
"moonbitstack/moonasgi",
44
"moonbitlang/core/encoding/utf8",
55
}
66

0 commit comments

Comments
 (0)