summaryrefslogtreecommitdiffstats
path: root/deployment
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-08-18 20:22:50 -0700
committerGitHub <noreply@github.com>2020-08-18 23:22:50 -0400
commitb2a00d49f17b60ec5fcb68ca819d6e79f9c69014 (patch)
tree4a40be7bac1ad2d75405ad975919b8b4afbbe5cd /deployment
parenteb5ac54ad0c8dbc444f3852a7ccc0e8e5af5cecc (diff)
ci: Automatically build package files on release
Automatically builds packages for AUR, chocolatey, and homebrew on release.
Diffstat (limited to 'deployment')
-rw-r--r--deployment/linux/arch/PKGBUILD.template23
-rw-r--r--deployment/linux/arch/PKGBUILD_BIN.template24
-rw-r--r--deployment/macos/homebrew/bottom.rb.template15
-rw-r--r--deployment/packager.py43
-rw-r--r--deployment/windows/choco/bottom.nuspec.template52
-rw-r--r--deployment/windows/choco/choco_packager.py48
-rw-r--r--deployment/windows/choco/chocolateyinstall.ps1.template20
7 files changed, 225 insertions, 0 deletions
diff --git a/deployment/linux/arch/PKGBUILD.template b/deployment/linux/arch/PKGBUILD.template
new file mode 100644
index 00000000..bf0b2298
--- /dev/null
+++ b/deployment/linux/arch/PKGBUILD.template
@@ -0,0 +1,23 @@
+# Maintainer: Clement Tsang (xoronth) <cjhtsang@uwaterloo.ca>
+
+pkgname=bottom
+pkgver=$version
+pkgrel=0
+pkgdesc="A cross-platform graphical process/system monitor with a customizable interface and a multitude of features."
+provides=('bottom')
+makedepends=('cargo')
+arch=('x86_64')
+url="https://github.com/ClementTsang/bottom"
+source=("$pkgname-$pkgver.tar.gz::https://github.com/ClementTsang/bottom/releases/download/$pkgver/bottom_required_files.tar.gz")
+license=('MIT')
+sha512sums=('$hash')
+
+build() {
+ cargo build --release --locked
+}
+
+package() {
+ install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/${pkgname}/LICENSE"
+ cd "./target/release"
+ install -Dm755 btm "$pkgdir/usr/bin/btm"
+} \ No newline at end of file
diff --git a/deployment/linux/arch/PKGBUILD_BIN.template b/deployment/linux/arch/PKGBUILD_BIN.template
new file mode 100644
index 00000000..41580b48
--- /dev/null
+++ b/deployment/linux/arch/PKGBUILD_BIN.template
@@ -0,0 +1,24 @@
+# Maintainer: Clement Tsang (xoronth) <cjhtsang@uwaterloo.ca>
+
+pkgname=bottom-bin
+pkgver=$version
+pkgrel=0
+pkgdesc='A cross-platform graphical process/system monitor with a customizable interface and a multitude of features.'
+provides=('bottom')
+conflicts=('bottom')
+arch=('x86_64')
+url="https://github.com/ClementTsang/bottom"
+license=(MIT)
+source=(
+ archive-${pkgver}.tar.gz::${url}/releases/download/${pkgver}/bottom_x86_64-unknown-linux-gnu.tar.gz
+ LICENSE::${url}/raw/${pkgver}/LICENSE
+)
+sha512sums=(
+ '$hash'
+ SKIP
+)
+
+package() {
+ install -Dm755 btm "$pkgdir"/usr/bin/btm
+ install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+}
diff --git a/deployment/macos/homebrew/bottom.rb.template b/deployment/macos/homebrew/bottom.rb.template
new file mode 100644
index 00000000..b338c5f5
--- /dev/null
+++ b/deployment/macos/homebrew/bottom.rb.template
@@ -0,0 +1,15 @@
+class Bottom < Formula
+ desc "A cross-platform graphical process/system monitor with a customizable interface and a multitude of features."
+ homepage "https://github.com/ClementTsang/bottom"
+ url "https://github.com/ClementTsang/bottom/releases/download/$version/bottom_x86_64-apple-darwin.tar.gz"
+ sha256 "$hash"
+ version "$version"
+
+ def install
+ bin.install "btm"
+ ohai "You're done! Run with \"btm\""
+ ohai "For runtime flags, see \"btm --help\""
+ ohai "If you want to configure bottom, by default bottom looks for a file in $HOME/.config/bottom/bottom.toml"
+ end
+ end
+ \ No newline at end of file
diff --git a/deployment/packager.py b/deployment/packager.py
new file mode 100644
index 00000000..ec167675
--- /dev/null
+++ b/deployment/packager.py
@@ -0,0 +1,43 @@
+import hashlib
+import sys
+from string import Template
+
+args = sys.argv
+deployment_file_path = args[1]
+version = args[2]
+template_file_path = args[3]
+generated_file_path = args[4]
+
+# SHA512, SHA256, or SHA1
+hash_type = args[5]
+
+print("Generating package for file: %s" % deployment_file_path)
+print(" VERSION: %s" % version)
+print(" TEMPLATE PATH: %s" % template_file_path)
+print(" SAVING AT: %s" % generated_file_path)
+print(" USING HASH TYPE: %s" % hash_type)
+
+
+with open(deployment_file_path, "rb") as deployment_file:
+ if str.lower(hash_type) == "sha512":
+ deployment_hash = hashlib.sha512(deployment_file.read()).hexdigest()
+ elif str.lower(hash_type) == "sha256":
+ deployment_hash = hashlib.sha256(deployment_file.read()).hexdigest()
+ elif str.lower(hash_type) == "sha1":
+ deployment_hash = hashlib.sha1(deployment_file.read()).hexdigest()
+ else:
+ print('Unsupported hash format "%s". Please use SHA512, SHA256, or SHA1.', hash_type)
+ exit(1)
+
+ print("Generated hash: ", deployment_hash)
+
+ with open(template_file_path, "r") as template_file:
+ template = Template(template_file.read())
+ substitute = template.safe_substitute(version=version, hash=deployment_hash)
+ print("\n================== Generated package file ==================\n")
+ print(substitute)
+ print("\n============================================================\n")
+
+ with open(generated_file_path, "w") as generated_file:
+ generated_file.write(substitute)
+
diff --git a/deployment/windows/choco/bottom.nuspec.template b/deployment/windows/choco/bottom.nuspec.template
new file mode 100644
index 00000000..acecb0ca
--- /dev/null
+++ b/deployment/windows/choco/bottom.nuspec.template
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Read this before creating packages: https://chocolatey.org/docs/create-packages -->
+<!-- It is especially important to read the above link to understand additional requirements when publishing packages to the community feed aka dot org (https://chocolatey.org/packages). -->
+
+<!-- Test your packages in a test environment: https://github.com/chocolatey/chocolatey-test-environment -->
+
+<!--
+This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Reference. Chocolatey uses a special version of NuGet.Core that allows us to do more than was initially possible. As such there are certain things to be aware of:
+
+* the package xmlns schema url may cause issues with nuget.exe
+* Any of the following elements can ONLY be used by choco tools - projectSourceUrl, docsUrl, mailingListUrl, bugTrackerUrl, packageSourceUrl, provides, conflicts, replaces
+* nuget.exe can still install packages with those elements but they are ignored. Any authoring tools or commands will error on those elements
+-->
+
+<!-- You can embed software files directly into packages, as long as you are not bound by distribution rights. -->
+<!-- * If you are an organization making private packages, you probably have no issues here -->
+<!-- * If you are releasing to the community feed, you need to consider distribution rights. -->
+<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
+<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
+ <metadata>
+ <!-- == PACKAGE SPECIFIC SECTION == -->
+ <id>bottom</id>
+ <version>$version</version>
+
+ <!-- == SOFTWARE SPECIFIC SECTION == -->
+ <!-- This section is about the software itself -->
+ <title>bottom</title>
+ <authors>Clement Tsang</authors>
+ <projectUrl>https://github.com/ClementTsang/bottom</projectUrl>
+ <licenseUrl>https://github.com/ClementTsang/bottom/blob/master/LICENSE</licenseUrl>
+ <requireLicenseAcceptance>true</requireLicenseAcceptance>
+ <projectSourceUrl>https://github.com/ClementTsang/bottom</projectSourceUrl>
+ <docsUrl>https://github.com/ClementTsang/bottom/blob/master/README.md</docsUrl>
+ <bugTrackerUrl>https://github.com/ClementTsang/bottom/issues</bugTrackerUrl>
+ <tags>cli cross-platform terminal top tui monitoring bottom btm</tags>
+ <summary>A cross-platform graphical process/system monitor with a customizable interface and a multitude of features.</summary>
+ <description>
+ A cross-platform graphical process/system monitor with a customizable interface and a multitude of features. Supports Linux, macOS, and Windows. Inspired by both [gtop](https://github.com/aksakalli/gtop) and [gotop](https://github.com/cjbassi/gotop).
+
+ **Usage**
+ To use, run `btm` in a terminal.
+
+ For more [documentation and usage](https://github.com/ClementTsang/bottom/blob/master/README.md), see the [official repo](https://github.com/ClementTsang/bottom).
+ </description>
+ <releaseNotes>https://github.com/ClementTsang/bottom/releases/tag/0.4.3/</releaseNotes>
+ </metadata>
+ <files>
+ <!-- this section controls what actually gets packaged into the Chocolatey package -->
+ <file src="tools\**" target="tools" />
+ <!--Building from Linux? You may need this instead: <file src="tools/**" target="tools" />-->
+ </files>
+</package>
diff --git a/deployment/windows/choco/choco_packager.py b/deployment/windows/choco/choco_packager.py
new file mode 100644
index 00000000..0d4431a0
--- /dev/null
+++ b/deployment/windows/choco/choco_packager.py
@@ -0,0 +1,48 @@
+# Because choco is a special case and I'm too lazy to make my
+# packaging script robust enough, so whatever, hard-code time.
+
+import hashlib
+import sys
+from string import Template
+import os
+
+args = sys.argv
+deployment_file_path_32 = args[1]
+deployment_file_path_64 = args[2]
+version = args[3]
+
+print("Generating Chocolatey package for:")
+print(" 32-bit: %s", deployment_file_path_32)
+print(" 64-bit: %s", deployment_file_path_64)
+print(" VERSION: %s" % version)
+
+with open(deployment_file_path_32, "rb") as deployment_file_32, open(
+ deployment_file_path_64, "rb"
+) as deployment_file_64:
+ hash_32 = hashlib.sha1(deployment_file_32.read()).hexdigest()
+ hash_64 = hashlib.sha1(deployment_file_64.read()).hexdigest()
+
+ print("Generated 32 hash: ", hash_32)
+ print("Generated 64 hash: ", hash_64)
+
+ with open("./bottom.nuspec.template", "r") as template_file:
+ template = Template(template_file.read())
+ substitute = template.safe_substitute(version=version)
+ print("\n================== Generated nuspec file ==================\n")
+ print(substitute)
+ print("\n============================================================\n")
+
+ with open("./bottom.nuspec", "w") as generated_file:
+ generated_file.write(substitute)
+
+ os.makedirs("tools")
+ with open("./chocolateyinstall.ps1.template", "r") as template_file:
+ template = Template(template_file.read())
+ substitute = template.safe_substitute(version=version, hash_32=hash_32, hash_64=hash_64)
+ print("\n================== Generated chocolateyinstall file ==================\n")
+ print(substitute)
+ print("\n============================================================\n")
+
+ with open("./tools/chocolateyinstall.ps1", "w") as generated_file:
+ generated_file.write(substitute)
+
diff --git a/deployment/windows/choco/chocolateyinstall.ps1.template b/deployment/windows/choco/chocolateyinstall.ps1.template
new file mode 100644
index 00000000..638d7281
--- /dev/null
+++ b/deployment/windows/choco/chocolateyinstall.ps1.template
@@ -0,0 +1,20 @@
+$ErrorActionPreference = 'Stop';
+$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
+$url = 'https://github.com/ClementTsang/bottom/releases/download/$version/bottom_i686-pc-windows-msvc.zip'
+$url64 = 'https://github.com/ClementTsang/bottom/releases/download/$version/bottom_x86_64-pc-windows-msvc.zip'
+
+$packageArgs = @{
+ packageName = $env:ChocolateyPackageName
+ softwareName = 'bottom'
+ unzipLocation = $toolsDir
+ fileType = 'exe'
+ url = $url
+ url64bit = $url64
+
+ checksum = '$hash_32'
+ checksumType = 'sha1'
+ checksum64 = '$hash_64'
+ checksumType64= 'sha1'
+
+}
+Install-ChocolateyZipPackage @packageArgs