Compare commits
8 Commits
f407b1c4af
...
v1.0.1b
| Author | SHA1 | Date | |
|---|---|---|---|
| af453ca2ec | |||
| cea84de242 | |||
| ad1ec9c2e3 | |||
| fa3b5592da | |||
| 722d687afe | |||
| 77c0b29b4c | |||
| 9ae965662c | |||
| 9ced2af562 |
16
.gitea/workflows/lint.yml
Normal file
16
.gitea/workflows/lint.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
shellcheck:
|
||||
runs-on: local
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Shellcheck
|
||||
run: sudo apt-get update && sudo apt-get install -y shellcheck
|
||||
- name: Run Shellcheck
|
||||
run: shellcheck kewt.sh markdown.sh tools/build-standalone.sh || true
|
||||
109
.gitea/workflows/release.yml
Normal file
109
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,109 @@
|
||||
name: Release Standalone Builder
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: local
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build standalone executable
|
||||
run: |
|
||||
chmod +x tools/build-standalone.sh
|
||||
./tools/build-standalone.sh
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Upload Release Asset
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: |-
|
||||
kewt
|
||||
api_key: '${{secrets.GITEA_TOKEN}}'
|
||||
|
||||
- name: Push to GitHub Release
|
||||
run: |
|
||||
TAG="${GITHUB_REF#refs/tags/}"
|
||||
|
||||
# Create the release on GitHub
|
||||
curl -sL -X POST \
|
||||
-H "Authorization: token ${{ secrets.GH_RELEASE_TOKEN }}" \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
"https://api.github.com/repos/n0va-bot/kewt/releases" \
|
||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" || true
|
||||
|
||||
# Get the release ID
|
||||
RELEASE_ID=$(curl -sL \
|
||||
-H "Authorization: token ${{ secrets.GH_RELEASE_TOKEN }}" \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
"https://api.github.com/repos/n0va-bot/kewt/releases/tags/${TAG}" | jq -r '.id')
|
||||
|
||||
# Upload the asset
|
||||
curl -sL -X POST \
|
||||
-H "Authorization: token ${{ secrets.GH_RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
"https://uploads.github.com/repos/n0va-bot/kewt/releases/${RELEASE_ID}/assets?name=kewt" \
|
||||
--data-binary @kewt
|
||||
|
||||
publish-aur:
|
||||
runs-on: local
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Arch Linux environment
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y pacman-package-manager curl jq || true
|
||||
|
||||
- name: Render PKGBUILD and SRCINFO
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
VERSION=${VERSION#refs/tags/}
|
||||
|
||||
curl -sL -o kewt https://git.krzak.org/N0VA/kewt/releases/download/v${VERSION}/kewt
|
||||
|
||||
CHECKSUM=$(sha256sum kewt | awk '{print $1}')
|
||||
|
||||
mkdir -p aur-work
|
||||
sed -e "s/VERSION_PLACEHOLDER/${VERSION}/g" \
|
||||
-e "s/SHA256SUM_PLACEHOLDER/${CHECKSUM}/g" \
|
||||
packaging/AUR/PKGBUILD.template > aur-work/PKGBUILD
|
||||
|
||||
cat > aur-work/.SRCINFO << SRCEOF
|
||||
pkgbase = kewt-bin
|
||||
pkgdesc = A minimalist, 100% POSIX static site generator inspired by werc and kew
|
||||
pkgver = ${VERSION}
|
||||
pkgrel = 1
|
||||
url = https://git.krzak.org/N0VA/kewt
|
||||
arch = any
|
||||
license = MIT
|
||||
depends = sh
|
||||
provides = kewt
|
||||
conflicts = kewt
|
||||
conflicts = kewt-git
|
||||
source = kewt-bin-${VERSION}.sh::https://git.krzak.org/N0VA/kewt/releases/download/v${VERSION}/kewt
|
||||
sha256sums = ${CHECKSUM}
|
||||
|
||||
pkgname = kewt-bin
|
||||
SRCEOF
|
||||
# Remove leading whitespace from heredoc
|
||||
sed -i 's/^ //' aur-work/.SRCINFO
|
||||
|
||||
- name: Publish to AUR
|
||||
uses: KSXGitHub/github-actions-deploy-aur@v3.0.1
|
||||
with:
|
||||
pkgname: kewt-bin
|
||||
pkgbuild: ./aur-work/PKGBUILD
|
||||
commit_username: ${{ github.actor }}
|
||||
commit_email: ${{ github.actor }}@users.noreply.github.com
|
||||
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
commit_message: "Update kewt-bin to ${{ github.ref_name }}"
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
out/
|
||||
kewt
|
||||
@@ -19,6 +19,15 @@ It's meant to be a static site generator, like _[kew](https://github.com/uint23/
|
||||
|
||||
If you want to **force** a file to be inlined, use `\!![]` instead of `\![]`
|
||||
|
||||
## Installation
|
||||
|
||||
You can clone the repository to use `kewt.sh` directly, or you can download the standalone executable, which bundles all dependencies into a single file:
|
||||
|
||||
```sh
|
||||
curl -L -o kewt https://git.krzak.org/N0VA/kewt/releases/latest/download/kewt
|
||||
chmod +x kewt
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
|
||||
18
kewt.sh
18
kewt.sh
@@ -20,7 +20,7 @@ Options:
|
||||
EOF
|
||||
}
|
||||
|
||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
script_dir=$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd)
|
||||
awk_dir="$script_dir/awk"
|
||||
|
||||
ensure_root_defaults() {
|
||||
@@ -93,10 +93,7 @@ create_new_site() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
generate_nav() {
|
||||
dinfo=$(find "$1" \( -name ".*" ! -name "." ! -name ".." -prune \) -o -print | sort | awk -v src="$1" -f "$awk_dir/collect_dir_info.awk")
|
||||
find "$1" \( -name ".*" ! -name "." ! -name ".." -prune \) -o -name "*.md" -print | sort | awk -v src="$1" -v single_file_index="$single_file_index" -v flatten="$flatten" -v order="$order" -v dinfo="$dinfo" -f "$awk_dir/generate_sidebar.awk"
|
||||
}
|
||||
|
||||
|
||||
src=""
|
||||
out=""
|
||||
@@ -133,9 +130,9 @@ while [ $# -gt 0 ]; do
|
||||
*)
|
||||
positional_count=$((positional_count + 1))
|
||||
if [ "$positional_count" -eq 1 ]; then
|
||||
[ -z "$src" ] && src="$1" || die "Source already set (use either positional or --from)."
|
||||
if [ -z "$src" ]; then src="$1"; else die "Source already set (use either positional or --from)."; fi
|
||||
elif [ "$positional_count" -eq 2 ]; then
|
||||
[ -z "$out" ] && out="$1" || die "Output already set (use either positional or --to)."
|
||||
if [ -z "$out" ]; then out="$1"; else die "Output already set (use either positional or --to)."; fi
|
||||
else
|
||||
die "Too many positional arguments."
|
||||
fi
|
||||
@@ -333,6 +330,7 @@ nav_links_html() {
|
||||
old_ifs=$IFS
|
||||
set -f
|
||||
IFS=','
|
||||
# shellcheck disable=SC2086
|
||||
set -- $nav_links
|
||||
IFS=$old_ifs
|
||||
set +f
|
||||
@@ -418,7 +416,7 @@ render_markdown() {
|
||||
closest_style_src=$(find_closest "styles.css" "$(dirname "$file")")
|
||||
[ -z "$closest_style_src" ] && closest_style_src=$(find_closest "style.css" "$(dirname "$file")")
|
||||
if [ -n "$closest_style_src" ]; then
|
||||
style_rel_to_src="${closest_style_src#$src/}"
|
||||
style_rel_to_src="${closest_style_src#"$src"/}"
|
||||
case "$closest_style_src" in
|
||||
"$src/styles.css") style_rel_to_src="styles.css" ;;
|
||||
"$src/style.css") style_rel_to_src="style.css" ;;
|
||||
@@ -466,7 +464,7 @@ render_markdown() {
|
||||
echo "Building site from '$src' to '$out'..."
|
||||
|
||||
eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type d -print" | sort | while read -r dir; do
|
||||
rel_dir="${dir#$src}"
|
||||
rel_dir="${dir#"$src"}"
|
||||
rel_dir="${rel_dir#/}"
|
||||
[ -z "$rel_dir" ] && rel_dir="."
|
||||
out_dir="$out/$rel_dir"
|
||||
@@ -518,7 +516,7 @@ if [ ! -f "$out/styles.css" ] && [ -f "$script_dir/styles/$style.css" ]; then
|
||||
fi
|
||||
|
||||
eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type f -print" | sort | while IFS= read -r file; do
|
||||
rel_path="${file#$src}"
|
||||
rel_path="${file#"$src"}"
|
||||
rel_path="${rel_path#/}"
|
||||
dir_rel=$(dirname "$rel_path")
|
||||
out_dir="$out/$dir_rel"
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
script_dir=$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd)
|
||||
awk_dir="$script_dir/awk"
|
||||
|
||||
sed_inplace() {
|
||||
script="$1"
|
||||
file="$2"
|
||||
tmp="${file}.tmp.$$"
|
||||
sed "$script" "$file" > "$tmp" && mv "$tmp" "$file" || {
|
||||
if sed "$script" "$file" > "$tmp" && mv "$tmp" "$file"; then
|
||||
return 0
|
||||
else
|
||||
rm -f "$tmp"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
temp_file="/tmp/markdown.$$.md"
|
||||
|
||||
21
packaging/AUR/PKGBUILD.template
Normal file
21
packaging/AUR/PKGBUILD.template
Normal file
@@ -0,0 +1,21 @@
|
||||
# Maintainer: n0va <n0va@krzak.org>
|
||||
pkgname=kewt-bin
|
||||
pkgver=VERSION_PLACEHOLDER
|
||||
pkgrel=1
|
||||
pkgdesc="A minimalist, 100% POSIX static site generator inspired by werc and kew"
|
||||
arch=('any')
|
||||
url="https://git.krzak.org/N0VA/kewt"
|
||||
license=('MIT')
|
||||
depends=('sh')
|
||||
provides=('kewt')
|
||||
conflicts=('kewt' 'kewt-git')
|
||||
source=("${pkgname}-${pkgver}.sh::${url}/releases/download/v${pkgver}/kewt")
|
||||
sha256sums=('SHA256SUM_PLACEHOLDER')
|
||||
|
||||
build() {
|
||||
chmod +x "${srcdir}/${pkgname}-${pkgver}.sh"
|
||||
}
|
||||
|
||||
package() {
|
||||
install -Dm755 "${srcdir}/${pkgname}-${pkgver}.sh" "${pkgdir}/usr/bin/kewt"
|
||||
}
|
||||
@@ -19,6 +19,15 @@ It's meant to be a static site generator, like _[kew](https://github.com/uint23/
|
||||
|
||||
If you want to **force** a file to be inlined, use `\!![]` instead of `\![]`
|
||||
|
||||
## Installation
|
||||
|
||||
You can clone the repository to use `kewt.sh` directly, or you can download the standalone executable, which bundles all dependencies into a single file:
|
||||
|
||||
```sh
|
||||
curl -L -o kewt https://git.krzak.org/N0VA/kewt/releases/latest/download/kewt
|
||||
chmod +x kewt
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
|
||||
32
tools/build-standalone.sh
Normal file
32
tools/build-standalone.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
if [ ! -f "$REPO_ROOT/kewt.sh" ]; then
|
||||
echo "kewt.sh not found. Run from the repository root or tools/."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OUT_FILE="$REPO_ROOT/kewt"
|
||||
|
||||
cat << 'EOF' > "$OUT_FILE"
|
||||
#!/bin/sh
|
||||
tmpdir=$(mktemp -d "/tmp/kewt.XXXXXX")
|
||||
trap 'rm -rf "$tmpdir"' EXIT HUP INT TERM
|
||||
|
||||
# Extract payload
|
||||
sed '1,/^#==PAYLOAD==$/d' "$0" | tar -xz -C "$tmpdir"
|
||||
|
||||
# Pass control to the extracted script
|
||||
exec "$tmpdir/kewt.sh" "$@"
|
||||
|
||||
#==PAYLOAD==
|
||||
EOF
|
||||
|
||||
tar -cz -C "$REPO_ROOT" kewt.sh markdown.sh awk styles >> "$OUT_FILE"
|
||||
|
||||
chmod +x "$OUT_FILE"
|
||||
|
||||
echo "Generated standalone executable at $OUT_FILE"
|
||||
Reference in New Issue
Block a user