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

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to build (e.g., 0.1.0)"
required: true
type: string
dry_run:
description: "Dry run (build but don't create release)"
required: false
type: boolean
default: true

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build ${{ matrix.artifact_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: linux-x86_64
ffi_ext: so
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
artifact_name: linux-aarch64
ffi_ext: so
- os: macos-13
target: x86_64-apple-darwin
artifact_name: macos-x86_64
ffi_ext: dylib
- os: macos-14
target: aarch64-apple-darwin
artifact_name: macos-aarch64
ffi_ext: dylib

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

- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=v${{ inputs.version }}" >> $GITHUB_OUTPUT
echo "Using manual version: v${{ inputs.version }}"
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "Using tag version: ${GITHUB_REF#refs/tags/}"
fi

- name: Verify version matches Cargo.toml
run: |
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
BUILD_VERSION=${{ steps.version.outputs.VERSION }}
BUILD_VERSION=${BUILD_VERSION#v} # Strip v prefix
echo "Cargo.toml version: $CARGO_VERSION"
echo "Build version: $BUILD_VERSION"
if [ "$CARGO_VERSION" != "$BUILD_VERSION" ]; then
echo "::error::Version mismatch! Cargo.toml has $CARGO_VERSION but building v$BUILD_VERSION"
exit 1
fi
echo "Version check passed"

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libluajit-5.1-dev libclang-dev pkg-config

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install luajit pkg-config

- name: Build release
run: cargo build --release --target ${{ matrix.target }}

- name: Create artifact directory
run: |
mkdir -p artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}

- name: Copy binaries to artifact directory
run: |
cp target/${{ matrix.target }}/release/penview artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}/
cp target/${{ matrix.target }}/release/libwebsocket_ffi.${{ matrix.ffi_ext }} artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}/websocket_ffi.so
echo "${{ steps.version.outputs.VERSION }}" > artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}/VERSION

- name: Create tarball
run: |
cd artifact
tar -czvf penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}.tar.gz penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}
path: artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}.tar.gz

release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || !inputs.dry_run }}
permissions:
contents: write

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

- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=v${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Collect tarballs
run: |
mkdir -p release
find artifacts -name "*.tar.gz" -exec cp {} release/ \;
ls -la release/

- name: Generate checksums
run: |
cd release
sha256sum *.tar.gz > SHA256SUMS.txt
cat SHA256SUMS.txt

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: penview ${{ steps.version.outputs.VERSION }}
draft: false
prerelease: false
generate_release_notes: true
files: |
release/*.tar.gz
release/SHA256SUMS.txt
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/bin
rust/websocket-ffi/lua/
4 changes: 2 additions & 2 deletions Cargo.lock

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

39 changes: 39 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,42 @@ members = [
"rust/penview",
"rust/websocket-ffi",
]

[workspace.package]
version = "0.1.0"
edition = "2024"
authors = ["Rahul Garg <rg@vihu.dev>"]
readme = "README.md"
license = "MIT"
repository = "https://github.com/vihu/penview.nvim"
homepage = "https://github.com/vihu/penview.nvim"

[workspace.dependencies]
anyhow = "1"
askama = "0.14"
axum = { version = "0.8", features = ["ws"] }
base64 = "0.22.0"
clap = { version = "4", features = ["derive"] }
futures-channel = "0.3"
futures-util = "0.3"
inquire = "0.9"
mime_guess = "2"
lazy_static = "1.4.0"
log = "0.4"
log4rs = { version = "1.4", features = ["file_appender"] }
log-panics = "2"
notify = "8"
mlua = "0.9.7"
nvim-oxi = { version = "0.4.2", features = ["neovim-0-9", "libuv", "mlua"] }
open = "5"
parking_lot = "0.12"
pulldown-cmark = "0.13"
resolve-path = "0.1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
tokio-tungstenite = { version = "0.21.0", features = [] }
tracing = "0.1"
tracing-subscriber = "0.3"
url = "2"
uuid = { version = "1", features = [ "v4", "fast-rng", "macro-diagnostics" ] }
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ Real-time Markdown preview for Neovim with GitHub Flavored Markdown styling.
## Requirements

- Neovim 0.9+
- Rust toolchain (for building)
- curl (for downloading pre-compiled binaries)
- Rust toolchain (only if building from source)

## Installation

### lazy.nvim
### lazy.nvim (recommended)

Pre-compiled binaries are automatically downloaded for Linux and macOS (x86_64 and aarch64):

```lua
{
"vihu/penview.nvim",
build = "make build",
build = function()
require("penview.build").install()
end,
ft = "markdown",
config = function()
require("penview").setup({
Expand All @@ -43,6 +48,51 @@ Real-time Markdown preview for Neovim with GitHub Flavored Markdown styling.
}
```

### packer.nvim

```lua
use {
"vihu/penview.nvim",
run = function()
require("penview.build").install()
end,
config = function()
require("penview").setup({
browser = "firefox",
})
end,
}
```

### vim-plug

```vim
Plug 'vihu/penview.nvim', { 'do': ':lua require("penview.build").install()' }

" In your init.vim or after/plugin:
lua require("penview").setup({ browser = "firefox" })
```

### Building from source

If pre-compiled binaries are unavailable for your platform, or you prefer to build from source:

```lua
-- lazy.nvim
{
"vihu/penview.nvim",
build = "make build", -- Requires Rust toolchain
-- ...
}
```

Build dependencies:

- Rust toolchain (stable)
- libluajit (libluajit-5.1-dev on Debian/Ubuntu)
- libclang-dev
- pkg-config

## Usage

1. Open a markdown file
Expand Down
Loading