Skip to content

Commit a2bb776

Browse files
committed
feat: initial version
0 parents  commit a2bb776

23 files changed

+7002
-0
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RUST_LOG=error,wasic=debug

.github/workflows/release.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: "Release tag (e.g., v1.0.0)"
8+
required: true
9+
type: string
10+
release_notes:
11+
description: "Release notes (optional, will use commit messages if not provided)"
12+
required: false
13+
type: string
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event.inputs.release_tag }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
build-binaries:
24+
name: Build Binaries
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
os:
29+
- ubuntu-latest
30+
- macos-latest
31+
include:
32+
- os: ubuntu-latest
33+
target: x86_64-unknown-linux-gnu
34+
bin_name: wasic
35+
asset_name: wasic-${{ github.event.inputs.release_tag }}-x86_64-unknown-linux-gnu.tar.gz
36+
- os: macos-latest
37+
target: aarch64-apple-darwin
38+
bin_name: wasic
39+
asset_name: wasic-${{ github.event.inputs.release_tag }}-aarch64-apple-darwin.tar.gz
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Setup Rust
46+
uses: dtolnay/rust-toolchain@stable
47+
with:
48+
targets: ${{ matrix.target }}
49+
50+
- name: Install just
51+
uses: extractions/setup-just@v2
52+
53+
- name: Cache cargo registry
54+
uses: actions/cache@v4
55+
with:
56+
path: |
57+
~/.cargo/registry
58+
~/.cargo/git
59+
target
60+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
61+
restore-keys: |
62+
${{ runner.os }}-cargo-
63+
64+
- name: Install tools
65+
run: |
66+
just install-tools
67+
68+
- name: Build and validate
69+
run: |
70+
just lint
71+
72+
- name: Build binary
73+
run: |
74+
cargo build --release --target ${{ matrix.target }}
75+
76+
- name: Package binary (Linux/macOS)
77+
if: matrix.os != 'windows-latest'
78+
run: |
79+
mkdir -p artifacts
80+
cp "target/${{ matrix.target }}/release/${{ matrix.bin_name }}" artifacts/
81+
cd artifacts
82+
tar -czf "${{ matrix.asset_name }}" "${{ matrix.bin_name }}"
83+
84+
- name: Package binary (Windows)
85+
if: matrix.os == 'windows-latest'
86+
run: |
87+
mkdir -p artifacts
88+
cp "target/${{ matrix.target }}/release/${{ matrix.bin_name }}" artifacts/
89+
cd artifacts
90+
7z a -tzip "${{ matrix.asset_name }}" "${{ matrix.bin_name }}"
91+
92+
- name: Upload artifacts
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: ${{ matrix.asset_name }}
96+
path: artifacts/${{ matrix.asset_name }}
97+
98+
create-release:
99+
name: Create GitHub Release
100+
needs: build-binaries
101+
runs-on: ubuntu-latest
102+
permissions:
103+
contents: write
104+
105+
steps:
106+
- name: Download all artifacts
107+
uses: actions/download-artifact@v4
108+
with:
109+
path: artifacts/
110+
111+
- name: Generate Release Notes
112+
id: generate_release_notes
113+
uses: actions/github-script@v7
114+
with:
115+
script: |
116+
const { owner, repo } = context.repo;
117+
const tag = context.ref.replace('refs/tags/', '');
118+
const releaseName = `Release ${tag}`;
119+
120+
// Try to get release notes from the tag's annotation
121+
try {
122+
const tagData = await github.rest.git.getTag({
123+
owner,
124+
repo,
125+
tag_sha: context.sha,
126+
});
127+
if (tagData.data.message) {
128+
core.setOutput('notes', tagData.data.message);
129+
return;
130+
}
131+
} catch (e) {
132+
console.log('No tag annotation found, falling back to commit messages.');
133+
}
134+
135+
// Fallback to commit messages since the last tag
136+
const { data: tags } = await github.rest.repos.listTags({
137+
owner,
138+
repo,
139+
per_page: 2,
140+
});
141+
142+
let baseSha;
143+
if (tags.length > 1 && tags[1].name !== tag) {
144+
baseSha = tags[1].commit.sha;
145+
} else {
146+
// If no previous tag, get the first commit
147+
const { data: commits } = await github.rest.repos.listCommits({
148+
owner,
149+
repo,
150+
per_page: 1,
151+
});
152+
baseSha = commits[0].sha;
153+
}
154+
155+
const { data: compare } = await github.rest.repos.compareCommits({
156+
owner,
157+
repo,
158+
base: baseSha,
159+
head: context.sha,
160+
});
161+
162+
const notes = compare.commits.map(commit => {
163+
return `- ${commit.commit.message.split('\\n')[0]} (${commit.sha.substring(0, 7)})`;
164+
}).join('\\n');
165+
166+
core.setOutput('notes', `## Changes\\n\\n${notes}`);
167+
168+
- name: Create Release
169+
uses: softprops/action-gh-release@v2
170+
with:
171+
tag_name: ${{ github.event.inputs.release_tag }}
172+
name: Release ${{ github.event.inputs.release_tag }}
173+
body: ${{ github.event.inputs.release_notes || steps.generate_release_notes.outputs.notes }}
174+
files: |
175+
artifacts/**/*.tar.gz
176+
artifacts/**/*.zip
177+
env:
178+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
paths-ignore: ["**.md", "**.txt"]
7+
pull_request:
8+
branches: [main]
9+
paths-ignore: ["**.md", "**.txt"]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
18+
jobs:
19+
test-and-lint:
20+
name: Test and Lint
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest]
25+
rust: [stable]
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Rust
32+
uses: dtolnay/rust-toolchain@stable
33+
34+
- name: Install just
35+
uses: extractions/setup-just@v2
36+
37+
- name: Cache cargo registry
38+
uses: actions/cache@v4
39+
with:
40+
path: |
41+
~/.cargo/registry
42+
~/.cargo/git
43+
target
44+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-cargo-
47+
48+
- name: Install tools
49+
run: |
50+
just install-tools
51+
52+
- name: Run linting
53+
run: |
54+
just lint

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
**/target
3+
examples/
4+
.DS_Store

.release-please-manifest.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"packages": {
3+
"pkg/wasic": {
4+
"release-type": "rust",
5+
"package-name": "wasic",
6+
"extra-files": [
7+
"pkg/wasic/Cargo.toml",
8+
"pkg/wasic/Cargo.lock"
9+
]
10+
}
11+
},
12+
"changelog-sections": [
13+
{
14+
"type": "feat",
15+
"section": "Features"
16+
},
17+
{
18+
"type": "fix",
19+
"section": "Bug Fixes"
20+
},
21+
{
22+
"type": "chore",
23+
"section": "Other Changes"
24+
},
25+
{
26+
"type": "docs",
27+
"section": "Documentation"
28+
},
29+
{
30+
"type": "refactor",
31+
"section": "Code Refactoring"
32+
},
33+
{
34+
"type": "test",
35+
"section": "Tests"
36+
}
37+
]
38+
}

0 commit comments

Comments
 (0)