Skip to content

Commit

Permalink
Finalize release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmmjackson committed Aug 28, 2023
1 parent e27cd2f commit 27662c6
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 40 deletions.
72 changes: 36 additions & 36 deletions build/program.rb.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@
# 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}"
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}"
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
def install
bin.install "upnotify"
end
end
on_linux do
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
url "${ARM64_LINUX_RELEASE_URL}"
sha256 "${ARM64_LINUX_RELEASE_SHA}"
if Hardware::CPU.arm?
url "${ARM64_DARWIN_RELEASE_URL}"
sha256 "${ARM64_DARWIN_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 "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
def install
bin.install "upnotify"
end
end
if Hardware::CPU.intel?
url "${X86_LINUX_RELEASE_URL}"
sha256 "${X86_LINUX_RELEASE_SHA}"

test do
system "#{bin}/upnotify --version"
def install
bin.install "upnotify"
end
end
end

test do
system "#{bin}/upnotify --version"
end
end
55 changes: 51 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package_type:="none"
os:=os()
arch:=arch()
version:=`toml get Cargo.toml package.version --raw`
archive_name:="upnotify-{{version}}-{{target}}"
archive_name:="upnotify-" + version + "-" + target
msg:="Unknown error"

default: build
Expand Down Expand Up @@ -34,7 +34,8 @@ build-linux-arm64:
rust:1.70.0 sh -c "cargo install just toml-cli && just archive"

archive-tarball:
tar czf dist/{{target}}/{{archive_name}}.tar.gz target/{{target}}/release/upnotify
mkdir -p dist/{{target}}
tar czf dist/{{target}}/{{archive_name}}.tar.gz -C target/{{target}}/release/ upnotify

archive-zip:
zip dist/{{target}}/{{archive_name}}.zip target/{{target}}/release/upnotify
Expand All @@ -43,7 +44,7 @@ archive-all:
just archive-tarball archive-zip

archive: build
just archive-{{archive_type}}
just target={{target}} archive-{{archive_type}}

package-none:
@echo "Nothing to do; specify a package_type"
Expand All @@ -67,5 +68,51 @@ linux-packages:
package:
just package-{{package_type}}

homebrew-program:
create-release:
gh release create {{version}}

upload-to-release:
gh release view {{version}} || just msg="Release does not exist" die
gh release upload {{version}} \
dist/aarch64-apple-darwin/upnotify-{{version}}-aarch64-apple-darwin.tar.gz \
dist/x86_64-apple-darwin/upnotify-{{version}}-x86_64-apple-darwin.tar.gz \
dist/aarch64-unknown-linux-gnu/upnotify-{{version}}-aarch64-unknown-linux-gnu.tar.gz \
dist/aarch64-unknown-linux-gnu/upnotify-{{version}}.aarch64.rpm \
dist/aarch64-unknown-linux-gnu/upnotify_{{version}}_arm64.deb \
dist/x86_64-unknown-linux-gnu/upnotify-{{version}}-x86_64-unknown-linux-gnu.tar.gz \
dist/x86_64-unknown-linux-gnu/upnotify-{{version}}.x86_64.rpm \
dist/x86_64-unknown-linux-gnu/upnotify_{{version}}_amd64.deb \
--clobber


homebrew-program:
#!/usr/bin/env bash
export VERSION={{version}}
export X86_DARWIN_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-x86_64-apple-darwin.tar.gz") | .url')
export X86_DARWIN_RELEASE_SHA=$(shasum -a 256 \
dist/x86_64-apple-darwin/upnotify-{{version}}-x86_64-apple-darwin.tar.gz | awk '{print $1}')
export ARM64_DARWIN_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-aarch64-apple-darwin.tar.gz") | .url')
export ARM64_DARWIN_RELEASE_SHA=$(shasum -a 256 \
dist/aarch64-apple-darwin/upnotify-{{version}}-aarch64-apple-darwin.tar.gz | awk '{print $1}')
export X86_LINUX_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-x86_64-unknown-linux-gnu.tar.gz") | .url')
export X86_LINUX_RELEASE_SHA=$(shasum -a 256 \
dist/x86_64-unknown-linux-gnu/upnotify-{{version}}-x86_64-unknown-linux-gnu.tar.gz | awk '{print $1}')
export ARM64_LINUX_RELEASE_URL=$(gh release view {{version}} --json assets --jq \
'.assets[] | select(.name=="upnotify-{{version}}-aarch64-unknown-linux-gnu.tar.gz") | .url')
export ARM64_LINUX_RELEASE_SHA=$(shasum -a 256 \
dist/aarch64-unknown-linux-gnu/upnotify-{{version}}-aarch64-unknown-linux-gnu.tar.gz | awk '{print $1}')
envsubst < build/program.rb.tmpl > dist/program.rb
homebrew-update: homebrew-program
#!/usr/bin/env bash
git clone https://github.com/scottmmjackson/homebrew-sj dist/tap
cd dist/tap
git checkout -b upnotify-{{version}}
cp ../program.rb Formula/upnotify.rb
git add Formula/upnotify.rb
git commit -m "Added formula for upnotify {{version}}"
git push origin HEAD
gh pr create --title "Added formula for upnotify {{version}}" --body "Added formula for upnotify {{version}}"

0 comments on commit 27662c6

Please sign in to comment.