Skip to content
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Release
on:
push:
tags:
- "v*.*.*"

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Build CLI
run: ./gradlew --no-daemon :cli:shadowDistZip :cli:shadowDistTar

- name: Rename cli-shadow to cli
run: |
mv cli/build/distributions/cli-shadow.zip cli/build/distributions/cli.zip
mv cli/build/distributions/cli-shadow.tar cli/build/distributions/cli.tar

- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
cli/build/distributions/cli.zip
cli/build/distributions/cli.tar
fail_on_unmatched_files: true
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<h1 align="center">SAMT - Simple API Modeling Toolkit</h1>

<div align="center">

[![Latest Stable Release on GitHub](https://img.shields.io/github/v/release/samtkit/core?display_name=tag&sort=semver)](https://github.com/samtkit/core/releases/latest)
[![Total Downloads on GitHub](https://img.shields.io/github/downloads/samtkit/core/total)](https://github.com/samtkit/core/releases/latest)
[![MIT License](https://img.shields.io/github/license/samtkit/core)](./LICENSE)

</div>

<p align="center">
<i>Tired of unreadable OpenAPI YAML files and a plethora of different tools?
<br>SAMT is a developer-focused, extendable and easy-to-learn toolkit for modeling APIs using a business-first approach</i>
<br>
</p>

<hr>

## Documentation

Get started with SAMT, learn fundamental concepts or extend SAMT with a custom generator.

- [Getting Started](https://github.com/samtkit/core/wiki/Getting-Started)
- [Modeling Concepts](https://github.com/samtkit/core/wiki/Modeling-Concepts)
- [Visual Studio Code Plugin](https://marketplace.visualstudio.com/items?itemName=samt.samt)

### Advanced

- [Authoring Generators](https://github.com/samtkit/core/wiki/Authoring-Generators)
- [Architecture](https://github.com/samtkit/core/wiki/Architecture)

## Development Setup

SAMT is written in [Kotlin](https://kotlinlang.org/) and uses [Gradle](https://gradle.org/) as a build tool, for the best developer experience we recommend using [IntelliJ](https://www.jetbrains.com/idea/).

If you want to start SAMT locally, simply clone the repository and compile it using Gradle:

```shell
./gradlew assemble
```

You can also compile the CLI module locally:

```shell
./gradlew :cli:shadowJar
```

And then compile SAMT files using this locally compiled version:

```shell
java -jar ./cli/build/libs/samt-cli.jar ./specification/examples/todo-service/*.samt
```

If you're more interested in the [SAMT Visual Studio Code plugin](https://github.com/samtkit/vscode) or the related language server, you can also compile it locally as well:

```shell
./gradlew :language-server:shadowJar
```

## Contributing

Want to report a bug, contribute code, or improve documentation? Excellent!
Simply create an [issue](https://github.com/samtkit/core/issues),
open a [pull request](https://github.com/samtkit/core/pulls) or
start a [discussion](https://github.com/samtkit/core/discussions).
2 changes: 1 addition & 1 deletion cli/src/main/kotlin/tools/samt/cli/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fun main(args: Array<String>) {
val cliArgs = CliArgs()
val jCommander = JCommander.newBuilder()
.addObject(cliArgs)
.programName("java -jar samt-cli.jar")
.programName("./samtw")
.build()
jCommander.parse(*args)
if (cliArgs.help) {
Expand Down
2 changes: 2 additions & 0 deletions wrapper/samt-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
samtVersion=v0.0.1
distributionUrl=https\://github.com/samtkit/core/releases/download/$samtVersion/cli.tar
42 changes: 42 additions & 0 deletions wrapper/samtw
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env sh

if [ ! -f ./samt-wrapper.properties ]; then
echo "samt-wrapper.properties file not found." >&2
exit 1
fi

. ./samt-wrapper.properties

if ! command -v tar > /dev/null; then
echo "This script requires 'tar' to be installed." >&2
exit 1
fi

mkdir -p .samt/cli

if [ ! -f .samt/.gitignore ]; then
echo "*" > .samt/.gitignore
fi

currentVersion=$(cat .samt/cli/version.txt 2> /dev/null || echo "0.0.0")

if [ "$currentVersion" != "$samtVersion" ]; then
echo "Downloading samt $samtVersion from '$distributionUrl'..."
if command -v curl > /dev/null; then
if ! curl -s -L "$distributionUrl" | tar x -C .samt/cli; then
echo "An error occurred while downloading '$distributionUrl' archive using curl." >&2
exit 1
fi
echo "$samtVersion" > .samt/cli/version.txt
elif command -v curl > /dev/null; then
if ! wget -qO- "$distributionUrl" | tar x -C .samt/cli; then
echo "An error occurred while downloading '$distributionUrl' archive using wget." >&2
exit 1
fi
else
echo "samtw requires either 'curl' or 'wget' to be installed." >&2
exit 1
fi
fi

exec ".samt/cli/cli-shadow/bin/cli" "$@"
59 changes: 59 additions & 0 deletions wrapper/samtw.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@echo off

setlocal EnableDelayedExpansion

if not exist samt-wrapper.properties (
echo "samt-wrapper.properties not found."
exit /b 1
)

for /f "tokens=1,2 delims==" %%G in (samt-wrapper.properties) do (
if "%%G"=="samtVersion" (
set "samtVersion=%%H"
)
if "%%G"=="distributionUrl" (
set distributionUrlPattern=%%H
)
)

set distributionUrl=%distributionUrlPattern:$samtVersion=!samtVersion!%
set distributionUrl=%distributionUrl:\:=:%

where tar >nul || (
echo "This script requires 'tar' to be installed." >&2
exit /b 1
)

if not exist .samt\cli mkdir .samt\cli

if not exist .samt\.gitignore echo *> .samt\.gitignore

set "currentVersion=0.0.0"

if exist .samt\cli\version.txt (
set /p currentVersion=<.samt\cli\version.txt
)

if "%currentVersion%" neq "%samtVersion%" (
echo Downloading samt %samtVersion% from '%distributionUrl%'...
WHERE /q curl
if %ERRORLEVEL% EQU 0 (
curl -L -o .samt\cli\cli.tar "%distributionUrl%" || (
echo An error occurred while downloading '%distributionUrl%' archive using curl. >&2
exit /b 1
)

) else (
echo samtw requires 'curl' to be installed. >&2
exit /b 1
)

tar xf .samt\cli\cli.tar -C .samt\cli || (
echo An error occurred while unpacking .samt\cli\cli.tar using tar. >&2
exit /b 1
)

echo %samtVersion%> .samt\cli\version.txt
)

call ".samt\cli\cli-shadow\bin\cli.bat" %*