+++ /dev/null
-name: Release
-
-on:
- push:
- tags:
- - v[0-9]+.*
-
-jobs:
- create-release:
- name: Create GitHub release
- if: github.repository_owner == 'thombles'
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: taiki-e/create-gh-release-action@v1
- with:
- changelog: CHANGELOG.md
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- upload-assets:
- needs: create-release
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
- include:
- - os: windows-latest
- features: paste
- - os: macos-latest
- features: paste
- runs-on: ${{ matrix.os }}
- steps:
- - uses: actions/checkout@v2
- - uses: taiki-e/upload-rust-binary-action@v1
- with:
- bin: hashgood
- features: ${{ matrix.features || '' }}
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+++ /dev/null
-name: Rust
-
-on: [push]
-
-jobs:
- build:
-
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
- include:
- - os: windows-latest
- features: "--features paste"
- - os: macos-latest
- features: "--features paste"
- runs-on: ${{ matrix.os }}
-
- steps:
- - uses: actions/checkout@v1
- - name: Build
- run: cargo build ${{ matrix.features || '' }}
- - name: Run tests
- run: cargo test ${{ matrix.features || '' }}
--- /dev/null
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+source buildscripts/init.sh "$1"
+
+cargo build --target "${RUST_TARGET}"
--- /dev/null
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+
+TAG=$1
+
+BASENAME="hashgood-${TAG}"
+FILENAME="${BASENAME}.tar.xz"
+
+git archive "${TAG}" -o "${FILENAME}" --prefix="${BASENAME}/"
+
+echo "GENERIC_ARTIFACT|${FILENAME}|Source Code"
+echo "URL|Git Tag|https://code.octet-stream.net/hashgood/shortlog/refs/tags/${TAG}|${TAG}"
--- /dev/null
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+
+APP=hashgood
+
+PLATFORM=$1
+TAG=$2
+source buildscripts/init.sh "${PLATFORM}"
+
+BASENAME="${APP}-${TAG}-${PLATFORM}"
+
+case $PLATFORM in
+windows-x86_64)
+ FILENAME="${BASENAME}.zip"
+ TARCMD="/c/Windows/System32/tar.exe -acf ${FILENAME} ${BASENAME}"
+ ;;
+mac-x86_64|mac-arm64)
+ FILENAME="${BASENAME}.pkg"
+ TARCMD="pkgbuild --identifier net.octet-stream.${APP} --install-location /usr/local/bin/ --root ./${BASENAME} ${FILENAME}"
+ ;;
+*)
+ FILENAME="${BASENAME}.tar.xz"
+ TARCMD="tar -Jcf ${FILENAME} ${BASENAME}"
+ ;;
+esac
+
+
+cargo build --target "${RUST_TARGET}" --release
+
+if [[ ${CODESIGNCMD:-"unset"} != "unset" ]]; then
+ "${CODESIGNCMD}" "target/${RUST_TARGET}/release/${APP}"
+fi
+
+cd target
+mkdir "${BASENAME}"
+mv "${RUST_TARGET}/release/${APP}" "${BASENAME}"
+${TARCMD}
+
+if [[ ${NOTARISECMD:-"unset"} != "unset" ]]; then
+ "${NOTARISECMD}" "target/${FILENAME}"
+fi
+
+echo "PLATFORM_ARTIFACT|target/${FILENAME}"
--- /dev/null
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+
+PLATFORM=$1
+
+case $PLATFORM in
+mac-x86_64)
+ RUST_TARGET=x86_64-apple-darwin
+ ;;
+mac-arm64)
+ RUST_TARGET=aarch64-apple-darwin
+ ;;
+linux-x86_64)
+ RUST_TARGET=x86_64-unknown-linux-gnu
+ ;;
+linux-armhf)
+ RUST_TARGET=armv7-unknown-linux-gnueabihf
+ ;;
+linux-arm64)
+ RUST_TARGET=aarch64-unknown-linux-gnu
+ ;;
+windows-x86_64)
+ RUST_TARGET=x86_64-pc-windows-msvc
+ ;;
+*)
+ echo "Unrecognised platform"
+ exit 1
+ ;;
+esac
+
+export RUST_TARGET
--- /dev/null
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+source buildscripts/init.sh "$1"
+
+cargo clippy --all-targets --target "${RUST_TARGET}" -- -D warnings
+cargo fmt --all --check
--- /dev/null
+#!/bin/bash
+set -euxo pipefail
+cd "$(git rev-parse --show-toplevel)"
+source buildscripts/init.sh "$1"
+
+cargo test --target "${RUST_TARGET}"
"b9193853f7798e92e2f6b82eda336fa7d6fc0fa90fdefe665f372b0bad8cdf8c";
fn verify_digest(alg: Algorithm, data: &'static [u8], hash: &str) {
- let reader = Cursor::new(&*data);
+ let reader = Cursor::new(data);
let digests = create_digests(&[alg], Box::new(reader)).unwrap();
assert_eq!(digests.len(), 1);
assert_eq!(digests[0], (alg, hex::decode(hash).unwrap()));
/// Generate a candidate hash from the provided command line parameter, or throw an error.
fn get_by_parameter(param: &str) -> Result<CandidateHashes, String> {
let bytes =
- hex::decode(¶m).map_err(|_| "Provided hash is invalid or truncated hex".to_owned())?;
+ hex::decode(param).map_err(|_| "Provided hash is invalid or truncated hex".to_owned())?;
let alg = Algorithm::from_len(bytes.len())?;
let candidate = CandidateHash {
filename: None,
));
for i in &[invalid1, invalid2, invalid3, invalid4, invalid5] {
- assert!(read_raw_candidate_from_file(*i, example_path).is_none());
+ assert!(read_raw_candidate_from_file(i, example_path).is_none());
}
}