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
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
runner: ubuntu-latest
- goos: linux
goarch: arm64
runner: ubuntu-latest
- goos: windows
goarch: amd64
runner: ubuntu-latest
- goos: windows
goarch: arm64
runner: ubuntu-latest
- goos: darwin
goarch: amd64
runner: ubuntu-latest
- goos: darwin
goarch: arm64
runner: ubuntu-latest
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "stable"
cache: true
- name: Build
shell: bash
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
ext=""
if [ "${GOOS}" = "windows" ]; then ext=".exe"; fi
mkdir -p dist
go build -trimpath -ldflags="-s -w" -o "dist/devkit-${GOOS}-${GOARCH}${ext}" .
- uses: actions/upload-artifact@v4
with:
name: devkit-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*

release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: devkit-*
path: dist
merge-multiple: true
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" dist/* \
--repo "${GITHUB_REPOSITORY}" \
--title "devkit ${GITHUB_REF_NAME}" \
--generate-notes
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
push:
pull_request:

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "stable"
cache: true
- name: Format check
run: test -z "$(gofmt -l .)" || (gofmt -l . && exit 1)
if: runner.os != 'Windows'
- name: Test
run: go test ./...
- name: Build
run: go build ./...
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# devkit
A fast, portable developer toolkit for formatting JSON, converting between JSON and YAML, and checking TCP ports.

`devkit` is a fast, portable developer toolkit for formatting JSON, converting
between JSON and YAML, and checking TCP ports.

## Install

Download a binary for Windows, Linux, or macOS from the GitHub Releases page,
or build it from source:

```sh
go build -o devkit .
```

## JSON

Format JSON from a file or standard input:

```sh
devkit json format input.json
cat input.json | devkit json format -
devkit format input.json
```

Convert JSON to YAML:

```sh
devkit json to-yaml input.json
cat input.json | devkit json-to-yaml -
```

Large JSON integers are preserved without floating-point rounding.

## YAML

Convert YAML to formatted JSON:

```sh
devkit yaml to-json input.yaml
cat input.yaml | devkit yaml-to-json -
```

Empty input converts to `null`. Multiple YAML documents become a JSON array.
YAML mapping keys must be strings, duplicate keys are rejected, and non-finite
numbers cannot be represented by JSON.

## TCP ports

Check whether a TCP port accepts connections:

```sh
devkit port check example.com 443
devkit port check 127.0.0.1 8080 --timeout 5
devkit check-port example.com 443
```

The command prints `open` on success and exits with a non-zero status on failure.
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/hamrezoffic-source/devkit

go 1.22

require gopkg.in/yaml.v3 v3.0.1
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading
Loading