diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-08-23 23:24:06 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-08-23 23:45:34 -0400 |
commit | f1371b8d9f8d471fe89baef2d5b6b34175ebe668 (patch) | |
tree | b1940e08ff55fe135a22917f3dbba007354c4354 /deployment | |
parent | 52a21b9bec054e98f35a4af9926325ca0c8f0477 (diff) |
ci: Fix some incorrect behaviour caused by deployment script
Diffstat (limited to 'deployment')
-rw-r--r-- | deployment/linux/arch/PKGBUILD.template | 2 | ||||
-rw-r--r-- | deployment/linux/arch/PKGBUILD_BIN.template | 2 | ||||
-rw-r--r-- | deployment/macos/homebrew/bottom.rb.template | 9 | ||||
-rw-r--r-- | deployment/packager.py | 37 | ||||
-rw-r--r-- | deployment/windows/winget/winget.yaml.template | 2 |
5 files changed, 37 insertions, 15 deletions
diff --git a/deployment/linux/arch/PKGBUILD.template b/deployment/linux/arch/PKGBUILD.template index ef344605..0519e734 100644 --- a/deployment/linux/arch/PKGBUILD.template +++ b/deployment/linux/arch/PKGBUILD.template @@ -10,7 +10,7 @@ arch=('x86_64') url="https://github.com/ClementTsang/bottom" source=("$pkgname-$pkgver.tar.gz::https://github.com/ClementTsang/bottom/archive/$pkgver.tar.gz") license=('MIT') -sha512sums=('$hash') +sha512sums=('$hash1') build() { cargo build --release --locked diff --git a/deployment/linux/arch/PKGBUILD_BIN.template b/deployment/linux/arch/PKGBUILD_BIN.template index 41580b48..e2003c95 100644 --- a/deployment/linux/arch/PKGBUILD_BIN.template +++ b/deployment/linux/arch/PKGBUILD_BIN.template @@ -14,7 +14,7 @@ source=( LICENSE::${url}/raw/${pkgver}/LICENSE ) sha512sums=( - '$hash' + '$hash1' SKIP ) diff --git a/deployment/macos/homebrew/bottom.rb.template b/deployment/macos/homebrew/bottom.rb.template index b338c5f5..65b6f896 100644 --- a/deployment/macos/homebrew/bottom.rb.template +++ b/deployment/macos/homebrew/bottom.rb.template @@ -1,9 +1,14 @@ 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" + if OS.mac? + url "https://github.com/ClementTsang/bottom/releases/download/#{version}/bottom_x86_64-apple-darwin.tar.gz" + sha256 "$hash1" + elsif OS.linux? + url "https://github.com/ClementTsang/bottom/releases/download/#{version}/bottom_x86_64-unknown-linux-gnu.tar.gz" + sha256 "$hash2" + end def install bin.install "btm" diff --git a/deployment/packager.py b/deployment/packager.py index ef49a84f..1f96fc99 100644 --- a/deployment/packager.py +++ b/deployment/packager.py @@ -3,22 +3,27 @@ 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] +version = args[1] +template_file_path = args[2] +generated_file_path = args[3] # SHA512, SHA256, or SHA1 -hash_type = args[5] +hash_type = args[4] -print("Generating package for file: %s" % deployment_file_path) +# Deployment files +deployment_file_path_1 = args[5] +deployment_file_path_2 = args[6] if len(args) > 6 else None + +print("Generating package for file: %s" % deployment_file_path_1) +if deployment_file_path_2 is not None: + print("and for file: %s" % deployment_file_path_2) 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: +def get_hash(deployment_file): if str.lower(hash_type) == "sha512": deployment_hash = hashlib.sha512(deployment_file.read()).hexdigest() elif str.lower(hash_type) == "sha256": @@ -26,18 +31,30 @@ with open(deployment_file_path, "rb") as deployment_file: 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) + print( + 'Unsupported hash format "%s". Please use SHA512, SHA256, or SHA1.', hash_type) exit(1) print("Generated hash: %s" % str(deployment_hash)) + return deployment_hash + + +with open(deployment_file_path_1, "rb") as deployment_file_1: + deployment_hash_1 = get_hash(deployment_file_1) + + deployment_hash_2 = None + if deployment_file_path_2 is not None: + with open(deployment_file_path_2, "rb") as deployment_file_2: + deployment_hash_2 = get_hash(deployment_file_2) with open(template_file_path, "r") as template_file: template = Template(template_file.read()) - substitute = template.safe_substitute(version=version, hash=deployment_hash) + substitute = template.safe_substitute( + version=version, hash1=deployment_hash_1) if deployment_hash_2 is None else template.safe_substitute( + version=version, hash1=deployment_hash_1, hash2=deployment_hash_2) 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/winget/winget.yaml.template b/deployment/windows/winget/winget.yaml.template index 807aa38b..947105f2 100644 --- a/deployment/windows/winget/winget.yaml.template +++ b/deployment/windows/winget/winget.yaml.template @@ -10,6 +10,6 @@ Homepage: https://github.com/ClementTsang/bottom Installers:
- Arch: x64
Url: https://github.com/ClementTsang/bottom/releases/download/$version/bottom-$version-x86_64.msi
- Sha256: $hash
+ Sha256: $hash1
InstallerType: msi
\ No newline at end of file |