Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed May 8, 2024
0 parents commit 11ac70b
Show file tree
Hide file tree
Showing 23 changed files with 5,871 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- run: npm install
- run: npm run build
- run: npm run typecheck
- run: npm run lint
- run: npm run format -- --check
18 changes: 18 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Deploy Worker
on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest
needs: CI
steps:
- uses: actions/checkout@v4

- name: Build & Deploy Worker
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.wrangler/
.dev.vars
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
A Cloudflare Worker for managing ZLS build artifacts.

# API

The API Endpoint is `releases.zigtools.org`.

## /v1/select-zls-version?zig_version=${VERSION}

> [!IMPORTANT]
> If you are developing a tool that automatically installs ZLS then you came to the right place!
Will respond with metadata about a ZLS build that is compatible with the given Zig version.
The response body is similar to Zig's [index.json](https://ziglang.org/download/index.json).

### Example

```bash
curl "https://releases.zigtools.org/v1/select-zls-version?zig_version=0.12.0"
>>> TODO
```

```bash
curl "https://releases.zigtools.org/v1/select-zls-version?zig_version=0.13.0-dev.7%2B73c6c13a" # 0.13.0-dev.7+73c6c13a
>>> TODO
```

```bash
curl "https://releases.zigtools.org/v1/select-zls-version?zig_version=1.0.0"
>>> null
```

## /v1/select-zls-version (TODO)

> [!WARNING]
> This has not been implemented yet
The response body imitates Zig's [index.json](https://ziglang.org/download/index.json) except that there is no field for `master`. Development builds of ZLS should be queried by supplying the Zig version that is being used.

### Example

```bash
curl "https://releases.zigtools.org/v1/select-zls-version"
>>> TODO
```

## /v1/publish

> [!IMPORTANT]
> This request is only intended to be used by ZLS's GitHub CI.
The body is a `multipart/form-data` with the following key value pairs:

- `zls-version`: The ZLS version which must be semantic version
- `zig-version`: The Zig version which must be semantic version
- `minimum-build-zig-version`: The minimum Zig version that is required to compile and test ZLS:
- `minimum-runtime-zig-version`: The minimum Zig version that is required to run ZLS:

All other fields are interpreted as release artifacts. The key must have the following format:

`zls-${ARCH}-${OS}-${ZLS_VERSION}.(tar.xz|zip)` (Example: `zls-x86_64-linux-0.1.0.tar.xz`)

> [!WARNING]
> Minisign support has not been implemented yet.
Release artifacts can also be signed with [minisign](https://jedisct1.github.io/minisign/) by publishing an additional `.minisign` file for every artifact. (Example: `zls-x86_64-linux-0.1.0.tar.xz.minisign`)

## Development

```bash
# start a local worker
git clone https://github.com/zigtools/release-worker
cd release-worker
npm install
npx wrangler d1 execute production-db-backend --local --file=./migrations/0000_initial.sql
npm run dev
```

```bash
# Publish a ZLS release (Requires `tar` and `7z`)
git clone https://github.com/zigtools/zls
cd zls
ZLS_WORKER_ENDPOINT=http://localhost:8787 zig build release -Drelease-publish=success --summary all
```
20 changes: 20 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import prettierConfig from "eslint-config-prettier";

export default tseslint.config(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
eslint.configs.recommended,
...tseslint.configs.stylisticTypeChecked,
...tseslint.configs.strictTypeChecked,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
prettierConfig,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
);
12 changes: 12 additions & 0 deletions migrations/0000_initial.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DROP TABLE IF EXISTS ZLSReleases;
CREATE TABLE ZLSReleases (
ZLSVersion TEXT NOT NULL PRIMARY KEY,
ZLSVersionMajor INTEGER NOT NULL,
ZLSVersionMinor INTEGER NOT NULL,
ZLSVersionPatch INTEGER NOT NULL,
ZLSVersionBuildID INTEGER,
IsRelease BOOLEAN NOT NULL,
JsonData TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_zls_releases_zls_version ON ZLSReleases(ZLSVersion);
CREATE INDEX IF NOT EXISTS idx_zls_releases_is_release_major_minor_patch ON ZLSReleases(IsRelease, ZLSVersionMajor, ZLSVersionMinor, ZLSVersionPatch);
Loading

0 comments on commit 11ac70b

Please sign in to comment.