summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClementTsang <cjhtsang@uwaterloo.ca>2020-08-23 23:24:06 -0400
committerClementTsang <cjhtsang@uwaterloo.ca>2020-08-23 23:45:34 -0400
commitf1371b8d9f8d471fe89baef2d5b6b34175ebe668 (patch)
treeb1940e08ff55fe135a22917f3dbba007354c4354
parent52a21b9bec054e98f35a4af9926325ca0c8f0477 (diff)
ci: Fix some incorrect behaviour caused by deployment script
-rw-r--r--.github/workflows/deploy.yml23
-rw-r--r--.travis.yml14
-rw-r--r--deployment/linux/arch/PKGBUILD.template2
-rw-r--r--deployment/linux/arch/PKGBUILD_BIN.template2
-rw-r--r--deployment/macos/homebrew/bottom.rb.template9
-rw-r--r--deployment/packager.py37
-rw-r--r--deployment/windows/winget/winget.yaml.template2
7 files changed, 68 insertions, 21 deletions
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index b9db66ee..a206f256 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -8,12 +8,33 @@ jobs:
set_env:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
- name: Set env
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
- name: Test env
run: |
echo $RELEASE_VERSION
+ update_homebrew:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Download packages
+ run: |
+ curl -LO "https://github.com/ClementTsang/bottom/releases/download/$RELEASE_VERSION/bottom_x86_64-unknown-linux-gnu.tar.gz";
+ curl -LO "https://github.com/ClementTsang/bottom/releases/download/$RELEASE_VERSION/bottom_x86_64-apple-darwin.tar.gz";
+ - name: Execute packaging script
+ run: |
+ python "./deployment/packager.py" $RELEASE_VERSION "./deployment/macos/homebrew/bottom.rb.template" "./bottom.rb" "SHA256" "./bottom_x86_64-apple-darwin.tar.gz" "./bottom_x86_64-unknown-linux-gnu.tar.gz";
+ - name: Upload bottom.rb to release
+ uses: svenstaro/upload-release-action@2.1.0
+ with:
+ repo_token: ${{ secrets.BOTTOM_PACKAGE_DEPLOYMENT }}
+ file: bottom.rb
+ tag: ${{ $RELEASE_VERSION }}
+ overwrite: true
+ update_packages:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
- name: Trigger homebrew
run: |
curl -X POST https://api.github.com/repos/ClementTsang/homebrew-bottom/dispatches \
diff --git a/.travis.yml b/.travis.yml
index 6099eabe..308fa93a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -62,7 +62,10 @@ before_deploy:
zip bottom_i686-pc-windows-msvc.zip "btm.exe";
rm "btm.exe"
python "./deployment/windows/choco/choco_packager.py" "bottom_i686-pc-windows-msvc.zip" "bottom_x86_64-pc-windows-msvc.zip" $TRAVIS_TAG "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolateyinstall.ps1.template" "./deployment/windows/choco/bottom.nuspec" "./deployment/windows/choco/tools/chocolateyinstall.ps1" "./deployment/windows/choco/tools/";
- zip choco.zip "./deployment/windows/choco/bottom.nuspec" "./deployment/windows/choco/tools/";
+ cd "./deployment/windows/choco/"
+ zip -r choco.zip "bottom.nuspec" "tools/";
+ cd "../../../";
+ mv "./deployment/windows/choco/choco.zip" "./choco.zip"
cargo install cargo-wix;
cargo wix init;
cargo wix;
@@ -73,16 +76,17 @@ before_deploy:
strip btm;
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
tar -czvf bottom_x86_64-unknown-linux-gnu.tar.gz btm;
- tar -czvf bottom_required_files.tar.gz ./src ./Cargo.toml ./Cargo.lock LICENSE README.md;
- python "./deployment/packager.py" "./bottom_x86_64-unknown-linux-gnu.tar.gz" $TRAVIS_TAG "./deployment/linux/arch/PKGBUILD_BIN.template" "./PKGBUILD_BIN" "SHA512";
- python "./deployment/packager.py" "./bottom_required_files.tar.gz" $TRAVIS_TAG "./deployment/linux/arch/PKGBUILD.template" "./PKGBUILD" "SHA512";
+ python "./deployment/packager.py" $TRAVIS_TAG "./deployment/linux/arch/PKGBUILD_BIN.template" "./PKGBUILD_BIN" "SHA512" "./bottom_x86_64-unknown-linux-gnu.tar.gz";
+ curl -LO "https://github.com/ClementTsang/bottom/archive/$TRAVIS_TAG.tar.gz";
+ python "./deployment/packager.py" $TRAVIS_TAG "./deployment/linux/arch/PKGBUILD.template" "./PKGBUILD" "SHA512" "./$TRAVIS_TAG.tar.gz";
+ rm "$TRAVIS_TAG.tar.gz";
tar -czvf arch.tar.gz PKGBUILD_BIN PKGBUILD;
cargo install cargo-deb;
cargo deb;
cp ./target/debian/bottom_*.deb .;
elif [[ $TRAVIS_OS_NAME == "osx" ]]; then
tar -czvf bottom_x86_64-apple-darwin.tar.gz btm;
- python "./deployment/packager.py" "./bottom_x86_64-apple-darwin.tar.gz" $TRAVIS_TAG "./deployment/macos/homebrew/bottom.rb.template" "./bottom.rb" "SHA256";
+ # The bottom.rb file must be generated AFTER, since it relies on the Linux binary file.
fi
fi
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