Skip to content

Commit c661bd3

Browse files
authored
Merge pull request #1 from ServiceStack/copilot/setup-service-stack-library
Setup Zig project structure for Zigistry package registry
2 parents 803f7ad + 55284be commit c661bd3

File tree

10 files changed

+779
-2
lines changed

10 files changed

+779
-2
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
strategy:
15+
matrix:
16+
zig-version: ['0.13.0', '0.14.0']
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Zig
21+
uses: goto-bus-stop/setup-zig@v2
22+
with:
23+
version: ${{ matrix.zig-version }}
24+
25+
- name: Run tests
26+
run: zig build test
27+
28+
- name: Build examples
29+
run: |
30+
zig build example
31+
zig build advanced
32+
33+
- name: Check formatting
34+
run: zig fmt --check src/ examples/

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Contributing to ServiceStack Zig
2+
3+
Thank you for your interest in contributing to the ServiceStack Zig client library!
4+
5+
## Development Setup
6+
7+
1. Install Zig 0.13.0 or later from [ziglang.org](https://ziglang.org/download/)
8+
2. Clone the repository
9+
3. Run tests: `zig build test`
10+
4. Run examples: `zig build example`
11+
12+
## Building
13+
14+
```bash
15+
# Build the library
16+
zig build
17+
18+
# Run tests
19+
zig build test
20+
21+
# Run the basic example
22+
zig build example
23+
```
24+
25+
## Code Style
26+
27+
- Follow the Zig standard library conventions
28+
- Use `zig fmt` to format your code
29+
- Add tests for new functionality
30+
- Document public APIs with doc comments
31+
32+
## Testing
33+
34+
All new features should include appropriate tests. Run the test suite before submitting:
35+
36+
```bash
37+
zig build test
38+
```
39+
40+
## Submitting Changes
41+
42+
1. Fork the repository
43+
2. Create a feature branch
44+
3. Make your changes with tests
45+
4. Ensure all tests pass
46+
5. Submit a pull request
47+
48+
## Questions?
49+
50+
Feel free to open an issue if you have questions or need help with your contribution.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 ServiceStack
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PUBLISHING.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Publishing to Zigistry
2+
3+
This document describes the setup for publishing the ServiceStack Zig library to Zigistry.
4+
5+
## Package Structure
6+
7+
The package is structured according to Zigistry requirements:
8+
9+
### Required Files
10+
11+
1. **build.zig.zon** - Package metadata file
12+
- Package name: `servicestack`
13+
- Version: `0.1.0`
14+
- Description: ServiceStack HTTP Client Library for Zig
15+
- Minimum Zig version: `0.13.0`
16+
- License: MIT
17+
- Paths: Specifies which files are included in the package
18+
19+
2. **build.zig** - Build configuration
20+
- Defines the `servicestack` module
21+
- Sets up tests with `zig build test`
22+
- Provides example builds with `zig build example` and `zig build advanced`
23+
- Uses standard Zig build system conventions
24+
25+
3. **src/lib.zig** - Main library file
26+
- Exports the public API
27+
- Includes documentation comments
28+
- Contains unit tests
29+
30+
4. **LICENSE** - MIT License file
31+
32+
5. **README.md** - Package documentation
33+
- Installation instructions
34+
- Usage examples
35+
- API reference
36+
37+
### Additional Files
38+
39+
- **CONTRIBUTING.md** - Contributor guidelines
40+
- **examples/** - Example code demonstrating usage
41+
- `basic.zig` - Simple examples
42+
- `advanced.zig` - Comprehensive usage
43+
- **.github/workflows/ci.yml** - GitHub Actions CI/CD
44+
45+
## How to Publish
46+
47+
### Step 1: Prepare Release
48+
49+
1. Update version in `build.zig.zon`
50+
2. Update README.md with any changes
51+
3. Ensure all tests pass: `zig build test`
52+
4. Commit all changes
53+
54+
### Step 2: Create Git Tag
55+
56+
```bash
57+
git tag v0.1.0
58+
git push origin v0.1.0
59+
```
60+
61+
### Step 3: Submit to Zigistry
62+
63+
Follow the Zigistry submission process:
64+
65+
1. Visit [zigistry.dev](https://zigistry.dev) (when available)
66+
2. Submit the package with the GitHub repository URL
67+
3. The package manager will use the git tag to fetch the code
68+
4. Zigistry will calculate the hash for the tarball
69+
70+
### Step 4: Using the Package
71+
72+
Once published, users can add it to their projects:
73+
74+
```zig
75+
// build.zig.zon
76+
.{
77+
.name = "my-project",
78+
.version = "0.1.0",
79+
.dependencies = .{
80+
.servicestack = .{
81+
.url = "https://github.com/ServiceStack/servicestack-zig/archive/v0.1.0.tar.gz",
82+
.hash = "1220...", // Hash provided by Zigistry
83+
},
84+
},
85+
}
86+
```
87+
88+
## Package Features
89+
90+
### HTTP Client
91+
92+
The package provides a complete HTTP client for ServiceStack services:
93+
94+
- **GET** requests
95+
- **POST** requests with JSON body
96+
- **PUT** requests with JSON body
97+
- **DELETE** requests
98+
- Automatic JSON content-type headers
99+
- Error handling
100+
- Memory management with allocators
101+
102+
### Testing
103+
104+
Run tests with:
105+
```bash
106+
zig build test
107+
```
108+
109+
Tests include:
110+
- Client initialization
111+
- URL construction
112+
- Basic functionality tests
113+
114+
### Examples
115+
116+
Two examples are provided:
117+
118+
1. **Basic Example** (`zig build example`)
119+
- Simple GET and POST requests
120+
- Basic error handling
121+
122+
2. **Advanced Example** (`zig build advanced`)
123+
- All HTTP methods
124+
- Comprehensive error handling
125+
- JSON data examples
126+
127+
## Continuous Integration
128+
129+
GitHub Actions CI is configured to:
130+
- Test on multiple Zig versions (0.13.0, 0.14.0)
131+
- Run all tests
132+
- Build all examples
133+
- Check code formatting
134+
135+
## Versioning
136+
137+
The package follows Semantic Versioning:
138+
- MAJOR version for incompatible API changes
139+
- MINOR version for backwards-compatible functionality
140+
- PATCH version for backwards-compatible bug fixes
141+
142+
Current version: **0.1.0** (Initial release)
143+
144+
## Support
145+
146+
For issues or questions:
147+
- Open an issue on GitHub
148+
- See CONTRIBUTING.md for contribution guidelines
149+
150+
## License
151+
152+
This package is released under the MIT License. See LICENSE file for details.

0 commit comments

Comments
 (0)