Skip to content
Open

Nix #11

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
29 changes: 29 additions & 0 deletions .github/workflows/composite/assert-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: assert version

inputs:
filename:
required: true

expected-version:
required: true

runs:
using: "composite"
steps:
- name: Change permissions, read the current version
run: |
chmod +x ${{ inputs.filename }}
echo "BINARY_VERSION=$(${{ inputs.filename }} --version)" >> $GITHUB_ENV
shell: bash

- name: Verify bin version contains release tag
run: |
if ! [[ "${{ inputs.expected-version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Expected version is not valid. Exiting..."
exit 1
fi

if [[ "${{ env.BINARY_VERSION }}" != *"${{ inputs.expected-version }}"* ]]; then
exit 1
fi
shell: bash
44 changes: 44 additions & 0 deletions .github/workflows/composite/release-tag-to-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: determine release version

inputs:
release-tag:
required: true

outputs:
type:
value: ${{ steps.tag-type.outputs.tag-type }}
version:
value: ${{ steps.set-release-version.outputs.release-version }}

runs:
using: "composite"
steps:
- name: Determine tag type
id: tag-type
run: |
if [[ ${{ inputs.release-tag }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+$ ]]; then
echo "tag-type=PRE_RELEASE" >> $GITHUB_OUTPUT
elif [[ ${{ inputs.release-tag }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "tag-type=RELEASE" >> $GITHUB_OUTPUT
else
echo "Release tag is not valid. Exiting..."
exit 1
fi
shell: bash

- name: set release version
id: set-release-version
run: |
VERSION=$(echo "$RELEASE_TAG" | sed 's/^v//' | sed 's/-rc[0-9]\{1,\}//')

echo "Version without prefix: ${VERSION}"

if ! [[ ${VERSION} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version is not valid. Exiting..."
exit 1
fi

echo "release-version=${VERSION}" >> $GITHUB_OUTPUT
env:
RELEASE_TAG: ${{ inputs.release-tag }}
shell: bash
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: release

on:
push:
tags:
- v[0-9].[0-9]+.[0-9]+
- v[0-9].[0-9]+.[0-9]+-rc[0-9]+

jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: poet-bin-linux-amd64

- os: macos-latest
artifact_name: poet-bin-macos-arm

steps:
- name: checkout code
uses: actions/checkout@v4

- name: set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: build the binary
run: cargo build --release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- id: release-version
uses: ./.github/workflows/composite/release-tag-to-version
with:
release-tag: "${{ github.ref_name }}"

- name: rename the binary
run: mv ./target/release/poet ./${{ matrix.artifact_name }}
shell: bash

- uses: ./.github/workflows/composite/assert-version
with:
filename: "./${{ matrix.artifact_name }}"
expected-version: "${{ steps.release-version.outputs.version }}"

- name: upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
file: ./${{ matrix.artifact_name }}*
file_glob: true
overwrite: true
prerelease: ${{ steps.release-version.outputs.type == 'PRE_RELEASE' }}
tag: ${{ github.ref }}
2 changes: 1 addition & 1 deletion content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title = "Poet xD"

# This is a test header

This is a test contentz
This is a test content

**user**: test

Expand Down
66 changes: 66 additions & 0 deletions flake.lock

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

47 changes: 47 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
description = "Static site generator with JSX-like syntax, Rhai scripting, and more.";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, fenix, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};

toolchain = fenix.packages.${system}.minimal.toolchain;
in {
packages.${system}.default = pkgs.rustPlatform.buildRustPackage {
pname = "poet";
version = "0.3.0";

src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
};

nativeBuildInputs = [
toolchain
pkgs.pkg-config
pkgs.rustPlatform.bindgenHook
];
};

devShells.${system}.default = pkgs.mkShell {
buildInputs = [
toolchain
pkgs.pkg-config
self.packages.${system}.default
];
};
};
}
10 changes: 0 additions & 10 deletions src/content_document_front_matter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,15 @@ fn default_render() -> bool {
true
}

// #[derive(Debug, Deserialize, Serialize)]
// pub struct Excerpt {
// #[serde(rename = "type")]
// pub excerpt_type: String,
// pub content: String,
// }

#[derive(Clone, Debug, Deserialize, Hash, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ContentDocumentFrontMatter {
pub description: String,
#[serde(default)]
pub id: Option<String>,
pub layout: String,
// pub references: Vec<String>,
// pub truth_source_for: Vec<String>,
#[serde(default, rename = "collection")]
pub collections: CollectionPlacementList,
// pub excerpts: Vec<Excerpt>,
#[serde(default, with = "crate::flexible_datetime")]
pub last_updated_at: Option<DateTime<Utc>>,
pub primary_collection: Option<String>,
Expand Down
4 changes: 0 additions & 4 deletions src/mcp/jsonrpc/response/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ const ERROR_INVALID_REQUEST: i32 = -32600;
const ERROR_PARSE_ERROR: i32 = -32700;
const ERROR_RESOURCE_NOT_FOUND: i32 = -32002;

// pub const ERROR_METHOD_NOT_FOUND: i32 = -32601;
// pub const ERROR_SERVER_ERROR_RANGE_MIN: i32 = -32099;
// pub const ERROR_SERVER_ERROR_RANGE_MAX: i32 = -32000;

#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ResourceNotFound {
Expand Down