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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
64 changes: 64 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy
on:
release:
types: [created]

defaults:
run:
shell: bash

permissions:
contents: write

env:
BINARY_NAME=lsmkd

jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: aarch64-unknown-linux-musl
os: ubuntu-22.04
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: x86_64-unknown-linux-musl
os: ubuntu-22.04
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
name: Deploy ${{ matrix.target }}
steps:
- uses: actions/checkout@v5
- name: Install Rust
run: ci/install-rust.sh stable ${{ matrix.target }}
- name: Build asset
run: ci/make-release-asset.sh ${{ env.BINARY_NAME }} ${{ matrix.os }} ${{ matrix.target }}
- name: Update release with new asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload $ASSET_TAG $ASSET_PATH

publish:
name: Publish to crates.io
runs-on: ubuntu-latest
permissions:
id-token: write
environment: publish
steps:
- uses: actions/checkout@v5
- name: Install Rust (rustup)
run: rustup update stable --no-self-update && rustup default stable
- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@v1
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish --no-verify
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust
run: bash ci/install-rust.sh stable x86_64-unknown-linux-gnu
- name: Update Rust
run: rustup update stable --no-self-update && rustup default stable
- run: rustup component add rustfmt
- run: cargo fmt --check

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust
run: bash ci/install-rust.sh stable x86_64-unknown-linux-gnu
- name: Update Rust
run: rustup update stable --no-self-update && rustup default stable
- run: rustup component add clippy
- run: cargo clippy --workspace --all-targets --no-deps -- -D warnings

build:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust
run: bash ci/install-rust.sh stable aarch64-unknown-linux-musl
- name: Update Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Build
run: cargo build --locked --target aarch64-unknown-linux-musl
run: cargo build --locked

success:
name: Success gate
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*.swp
*.swo
*~
.env

# OS
.DS_Store
Thumbs.db

2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lsmkd"
description = "Recursively find markdown files and list them along with table of contents index"
license = "MIT"
version = "1.0.0"
version = "0.0.1"
authors = ["Ken Hill <ken@sharpbits.io>"]
edition = "2024"
repository = "https://github.com/sharpbits/lsmkd"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This utility is explicitly only read-only, it does not modify markdown files to

## Usage

```sh
```
$ lsmkd -h
List and index markdown files with table-of-contents and line numbers

Expand Down
51 changes: 51 additions & 0 deletions ci/make-release-asset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Builds the release and creates an archive
set -ex

BINARY_NAME=$1
OS=$2
TARGET=$3

if [[ -z "$GITHUB_REF" ]]
then
echo "GITHUB_REF must be set"
exit 1
fi

# Strip */tags/ from the start of the ref.
TAG=${GITHUB_REF#*/tags/}

host=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
export CARGO_PROFILE_RELEASE_LTO=true

cargo build --locked --bin $BINARY_NAME --release --target $TARGET

cd target/$TARGET/release

case $OS in
ubuntu*)
asset="$BINARY_NAME-$TAG-$TARGET.tar.gz"
tar czf ../../$asset $BINARY_NAME
;;
macos*)
asset="$BINARY_NAME-$TAG-$TARGET.tar.gz"
tar czf ../../$asset $BINARY_NAME
;;
windows*)
asset="$BINARY_NAME-$TAG-$TARGET.zip"
7z a ../../$asset $BINARY_NAME.exe
;;
*)
echo "OS should be second parameter, was: $OS"
;;
esac

cd ../..

if [[ -z "$GITHUB_ENV" ]]
then
echo "GITHUB_ENV not set, run: gh release upload $TAG target/$asset"
else
echo "ASSET_TAG=$TAG" >> $GITHUB_ENV
echo "ASSET_PATH=target/$asset" >> $GITHUB_ENV
fi