diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2eb8aec --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + + - run: dotnet restore + + - run: dotnet build --no-restore -c Release + + - run: dotnet test --no-build -c Release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fbc8dc7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Release + +on: + push: + tags: ["v*"] + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + + - name: Extract version from tag + id: version + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + + - run: dotnet restore + + - run: dotnet build --no-restore -c Release -p:Version=${{ steps.version.outputs.VERSION }} + + - run: dotnet test --no-build -c Release + + - name: Push to NuGet + run: dotnet nuget push "artifacts/pkg/Fluidify.${{ steps.version.outputs.VERSION }}.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + files: artifacts/pkg/Fluidify.${{ steps.version.outputs.VERSION }}.nupkg diff --git a/README.md b/README.md index dd5c26e..58b5c2f 100644 --- a/README.md +++ b/README.md @@ -1 +1,63 @@ -# Fluidify \ No newline at end of file +# Fluidify + +A modern alternative to T4 — an MSBuild task that processes [Fluid](https://github.com/sebastienros/fluid) (Liquid) template files at build time to generate code, configuration, or any other text output. + +## Installation + +```shell +dotnet add package Fluidify +``` + +Fluidify is a development dependency — it runs only at build time and adds nothing to your project's runtime output. + +## Usage + +Add `` items to your project file. Each item points to a `.fluid` template, and any custom metadata you set becomes a template variable. + +```xml + + + + +``` + +Templates use standard [Liquid syntax](https://shopify.github.io/liquid/): + +**Models/Greeting.cs.fluid** +```liquid +public static class Greeting +{ + public const string Value = "{{ Greeting }}, World!"; +} +``` + +Building the project renders each template before compilation. The output path is inferred by stripping the `.fluid` extension, so `Models/Greeting.cs.fluid` produces `Models/Greeting.cs`. + +Fluidify works with any text format — C#, JSON, HTML, YAML, or anything else. The `.fluid` extension is just a convention; the template itself is plain text with Liquid tags. + +### Custom output path + +Use the `Destination` metadata to write the output to a different location: + +```xml + + + +``` + +Relative paths are resolved from the project directory. Directories are created automatically. + +## How it works + +Fluidify registers an MSBuild target that runs before `CoreCompile`. For each `` item it: + +1. Parses the `.fluid` file using the Fluid template engine +2. Passes all item metadata (except `Destination`) as template variables +3. Writes the rendered output to the inferred or specified destination + +## License + +Apache-2.0 diff --git a/src/Fluidify/Fluidify.csproj b/src/Fluidify/Fluidify.csproj index 5772f1f..d295c46 100644 --- a/src/Fluidify/Fluidify.csproj +++ b/src/Fluidify/Fluidify.csproj @@ -5,6 +5,13 @@ latest Fluidify 0.1.0 + stanoddly + A modern alternative to T4 — an MSBuild task that processes Fluid (Liquid) template files at build time to generate code, configuration, or any other text output. + Apache-2.0 + https://github.com/stanoddly/Fluidify + https://github.com/stanoddly/Fluidify + README.md + msbuild;codegen;liquid;fluid;template true $(MSBuildThisFileDirectory)../../artifacts/pkg false @@ -20,6 +27,7 @@ +