ci: fix some bugs...

This commit is contained in:
ClementTsang 2020-08-22 23:32:28 -04:00
parent 397a7e8467
commit 5e0ab22645
3 changed files with 18 additions and 19 deletions

View File

@ -31,23 +31,17 @@ before_script:
- rustup component add clippy
script:
- cargo clippy -- -D clippy::all
- cargo build --verbose --target $TARGET
- cargo test --verbose --target $TARGET
before_cache:
- rm -rf /home/travis/.cargo/git
- rm -rf /home/travis/.cargo/registry
cache:
directories:
- /home/travis/.cargo
cache: cargo
notifications:
email:
on_success: never
before_deploy:
- cargo install --path . --target $TARGET --locked --force;
- |
cargo install --path . --target $TARGET --locked --force
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
choco install zip;
rustup target add x86_64-pc-windows-msvc;
@ -60,14 +54,15 @@ before_deploy:
strip "./target/i686-pc-windows-msvc/release/btm";
mv "./target/i686-pc-windows-msvc/release/btm" "btm.exe";
zip bottom_i686-pc-windows-msvc.zip "btm.exe";
python "./deployment/windows/choco/choco_packager.py" "bottom_i686-pc-windows-msvc.zip" "bottom_x86_64-pc-windows-msvc.zip" $TRAVIS_TAG;
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";
zip choco.zip "./deployment/windows/choco/bottom.nuspec" "./deployment/windows/choco/tools/";
choco install dotnet4.5.1;
choco install wixtoolset;
cargo install cargo-wix;
cargo wix init;
cargo wix;
cp "./target/wix/bottom*.msi" ./bottom_x86_64_installer.msi
python "./deployment/packager.py" "./bottom_x86_64_installer.msi" $TRAVIS_TAG "./deployment/windows/winget/winget.yaml.template", "$TRAVIS_TAG.yaml" "SHA256";
cp "./target/wix/bottom*.msi" ./bottom_x86_64_installer.msi;
python "./deployment/packager.py" "./bottom_x86_64_installer.msi" $TRAVIS_TAG "./deployment/windows/winget/winget.yaml.template" "$TRAVIS_TAG.yaml" "SHA256";
else
cargo build --release;
cp ./target/release/btm btm;
@ -75,15 +70,15 @@ before_deploy:
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" "./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";
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";
python "./deployment/packager.py" "./bottom_x86_64-apple-darwin.tar.gz" $TRAVIS_TAG "./deployment/macos/homebrew/bottom.rb.template" "./bottom.rb" "SHA256";
fi
fi

View File

@ -29,7 +29,7 @@ with open(deployment_file_path, "rb") as deployment_file:
print('Unsupported hash format "%s". Please use SHA512, SHA256, or SHA1.', hash_type)
exit(1)
print("Generated hash: ", deployment_hash)
print("Generated hash: %s" % str(deployment_hash))
with open(template_file_path, "r") as template_file:
template = Template(template_file.read())

View File

@ -10,11 +10,15 @@ args = sys.argv
deployment_file_path_32 = args[1]
deployment_file_path_64 = args[2]
version = args[3]
nuspec_template = args[4]
ps1_template = args[5]
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)
print(" NUSPEC TEMPLATE: %s" % nuspec_template)
print(" PS1 TEMPLATE: %s" % ps1_template)
with open(deployment_file_path_32, "rb") as deployment_file_32, open(
deployment_file_path_64, "rb"
@ -22,10 +26,10 @@ with open(deployment_file_path_32, "rb") as deployment_file_32, open(
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)
print("Generated 32 hash: %s" % str(hash_32))
print("Generated 64 hash: %s" % str(hash_64))
with open("./bottom.nuspec.template", "r") as template_file:
with open(nuspec_template, "r") as template_file:
template = Template(template_file.read())
substitute = template.safe_substitute(version=version)
print("\n================== Generated nuspec file ==================\n")
@ -36,7 +40,7 @@ with open(deployment_file_path_32, "rb") as deployment_file_32, open(
generated_file.write(substitute)
os.makedirs("tools")
with open("./chocolateyinstall.ps1.template", "r") as template_file:
with open(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")