diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..120c689 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..ea888c4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5da2294..b4115f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,8 +43,8 @@ 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 @@ -52,19 +52,19 @@ 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 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 diff --git a/.gitignore b/.gitignore index 83bc644..c94c2b9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,8 @@ *.swp *.swo *~ +.env # OS .DS_Store Thumbs.db - diff --git a/Cargo.lock b/Cargo.lock index c7a5149..2c3a915 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,7 +248,7 @@ checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "lsmkd" -version = "1.0.0" +version = "0.0.1" dependencies = [ "assert_cmd", "clap", diff --git a/Cargo.toml b/Cargo.toml index 4e07e99..1ad2243 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 "] edition = "2024" repository = "https://github.com/sharpbits/lsmkd" diff --git a/README.md b/README.md index 9771f7c..7141b94 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ci/make-release-asset.sh b/ci/make-release-asset.sh new file mode 100644 index 0000000..2e05773 --- /dev/null +++ b/ci/make-release-asset.sh @@ -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