ci: Fix some incorrect behaviour caused by deployment script
This commit is contained in:
parent
52a21b9bec
commit
f1371b8d9f
|
@ -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 \
|
||||
|
|
14
.travis.yml
14
.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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -14,7 +14,7 @@ source=(
|
|||
LICENSE::${url}/raw/${pkgver}/LICENSE
|
||||
)
|
||||
sha512sums=(
|
||||
'$hash'
|
||||
'$hash1'
|
||||
SKIP
|
||||
)
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue