diff --git a/build/aarch64-apple-darwin.env b/build/aarch64-apple-darwin.env new file mode 100644 index 0000000..5a8be27 --- /dev/null +++ b/build/aarch64-apple-darwin.env @@ -0,0 +1,3 @@ +ARCH=arm64 +PLATFORM=darwin +UPNOTIFY_BINARY=target/aarch64-apple-darwin/release/upnotify \ No newline at end of file diff --git a/build/cross-release.sh b/build/cross-release.sh deleted file mode 100755 index 692941b..0000000 --- a/build/cross-release.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -die() { - echo "FAILED TO COMPILE" - exit 1 -} - -compile() { - local cargo_target=$1 - local goos=$2 -# docker run --rm --name "upnotify-release-${cargo_target}" --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/myapp \ -# -w /usr/src/myapp rust:1.70 sh -c \ -# "rustup target add $cargo_target && cargo build --release --target ${cargo_target}" || die - cargo build --release --target "${cargo_target}" || die - cp "target/${cargo_target}/release/upnotify" "dist/upnotify_${goos}/" -} - -target=$1 -os=$2 -arch=$3 - -case $os in - darwin) case $arch in - arm64) cargo_target=aarch64-apple-darwin - ;; - amd64) cargo_target=x86_64-apple-darwin - ;; - esac - ;; - linux) case $arch in - arm64) cargo_target=aarch64-unknown-linux-gnu - ;; - amd64) cargo_target=x86_64-unknown-linux-gnu - ;; - esac - ;; - windows) - case $arch in - arm64) cargo_target=aarch64-pc-windows-msvc - ;; - amd64) cargo_target=x86_64-pc-windows-gnu - ;; - esac - ;; -esac - -compile "${cargo_target}" "${target}" \ No newline at end of file diff --git a/build/nfpm.yaml.tmpl b/build/nfpm.yaml.tmpl new file mode 100644 index 0000000..4d89354 --- /dev/null +++ b/build/nfpm.yaml.tmpl @@ -0,0 +1,19 @@ +# nfpm example configuration file +# +# check https://nfpm.goreleaser.com/configuration for detailed usage +# +name: "upnotify" +arch: "${ARCH}" +platform: "${PLATFORM}" +version: "${VERSION}" +section: "default" +priority: "extra" +provides: + - "upnotify" +maintainer: "Scott Jackson " +description: Tool to log to standard out when the status of a web service changes. +homepage: "https://github.com/scottmmjackson/upnotify" +license: "BSD 3.0" +contents: +- src: ${UPNOTIFY_BINARY} + dst: /usr/bin/upnotify diff --git a/build/program.rb.tmpl b/build/program.rb.tmpl new file mode 100644 index 0000000..5dabd2c --- /dev/null +++ b/build/program.rb.tmpl @@ -0,0 +1,49 @@ +# typed: false +# frozen_string_literal: true + +class Upnotify < Formula + desc "Tool to log to standard out when the status of a web service changes." + homepage "https://github.com/scottmmjackson/upnotify" + version "${VERSION}" + + on_macos do + if Hardware::CPU.intel? + url "${X86_DARWIN_RELEASE_URL}" + sha256 "${X86_DARWIN_RELEASE_SHA}" + + def install + bin.install "upnotify" + end + end + if Hardware::CPU.intel? + url "${ARM64_DARWIN_RELEASE_URL}" + sha256 "${ARM64_DARWIN_RELEASE_SHA}" + + def install + bin.install "upnotify" + end + end + end + on_linux do + if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? + url "${ARM64_LINUX_RELEASE_URL}" + sha256 "${ARM64_LINUX_RELEASE_SHA}" + + def install + bin.install "bb2todotxt" + end + end + if Hardware::CPU.intel? + url "${X86_LINUX_RELEASE_URL}" + sha256 "${X86_LINUX_RELEASE_SHA}" + + def install + bin.install "bb2todotxt" + end + end + end + + test do + system "#{bin}/upnotify --version" + end +end \ No newline at end of file diff --git a/build/version.sh b/build/version.sh new file mode 100755 index 0000000..3ec44f6 --- /dev/null +++ b/build/version.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +git tag --list --contains "$(git log -n1 --pretty='%h')" --sort -refname | head -n 1 \ No newline at end of file diff --git a/justfile b/justfile index 1c1a267..b8181de 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,31 @@ target:=`rustc -vV | sed -n 's|host: ||p'` +os_family:=os_family() +archive_type:=if os_family == "windows" { "zip" } else { "tarball" } +os:=os() +arch:=arch() +version:=`git tag` default: build +sys-info: + @echo "os_family {{os_family()}}" + @echo "os {{os()}}" + @echo "arch: {{arch()}}" + +clean: + rm -rf target + build: - cargo build --release --target {{target}} \ No newline at end of file + cargo build --release --target {{target}} + +build-mac-m1: + just target=aarch64-apple-darwin archive + +archive-tarball: + tar czf target/{{target}}/release/upnotify-{{version}}-{{target}}.tar.gz target/{{target}}/release/upnotify + +archive-zip: + zip target/{{target}}/release/upnotify-{{version}}-{{target}}.zip target/{{target}}/release/upnotify + +archive: build + just archive-{{archive_type}} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4180aa2..7595ca3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ enum Result { } fn main() { - let cli = Command::new("HTTP Status Monitor") + let cli = Command::new("Upnotify") .version("0.1.0") .author("Scott Jackson") .about("Monitors HTTP status changes of a URL")