Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: sh -n install.sh scripts/*.sh
- run: ./scripts/check-release-prep.sh
- run: cargo fmt --check
- run: cargo clippy --all-targets -- -D warnings
- run: cargo test
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
cp "target/${{ matrix.target }}/release/ocvm" "dist/${name}/"
cp README.md LICENSE CHANGELOG.md "dist/${name}/"
tar -C dist -czf "dist/${name}.tar.gz" "${name}"
shasum -a 256 "dist/${name}.tar.gz" > "dist/${name}.tar.gz.sha256"
(cd dist && shasum -a 256 "${name}.tar.gz" > "${name}.tar.gz.sha256")

- name: Package Windows artifact
if: matrix.archive == 'zip'
Expand All @@ -59,7 +59,7 @@ jobs:
Copy-Item README.md,LICENSE,CHANGELOG.md "dist/$name/"
Compress-Archive -Path "dist/$name/*" -DestinationPath "dist/$name.zip"
$hash = (Get-FileHash "dist/$name.zip" -Algorithm SHA256).Hash.ToLower()
"$hash dist/$name.zip" | Out-File -FilePath "dist/$name.zip.sha256" -Encoding ascii
"$hash $name.zip" | Out-File -FilePath "dist/$name.zip.sha256" -Encoding ascii

- uses: actions/upload-artifact@v4
with:
Expand All @@ -84,4 +84,3 @@ jobs:
with:
files: release-assets/*
generate_release_notes: true

16 changes: 14 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ need() {
need curl
need tar

system="$(uname -s)"
machine="$(uname -m)"
system="${OCVM_TEST_UNAME_S:-$(uname -s)}"
machine="${OCVM_TEST_UNAME_M:-$(uname -m)}"

case "$system" in
Darwin) os="apple-darwin" ;;
Expand All @@ -39,6 +39,18 @@ esac

target="${arch}-${os}"
asset="ocvm-${target}.tar.gz"

if [ "${OCVM_INSTALL_DRY_RUN:-}" = "1" ]; then
cat <<EOF
repo=${REPO}
target=${target}
asset=${asset}
api_url=${API_BASE}/repos/${REPO}/releases/latest
install_dir=${INSTALL_DIR}
EOF
exit 0
fi

tmp="${TMPDIR:-/tmp}/ocvm-install.$$"
mkdir -p "$tmp"
trap 'rm -rf "$tmp"' EXIT INT TERM
Expand Down
43 changes: 43 additions & 0 deletions scripts/check-release-prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh
set -eu

root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
cd "$root"

expect_output() {
expected="$1"
shift
output="$("$@")"
printf '%s\n' "$output" | grep -F "$expected" >/dev/null || {
echo "expected output to contain: $expected" >&2
echo "$output" >&2
exit 1
}
}

expect_file_text() {
file="$1"
text="$2"
grep -F "$text" "$file" >/dev/null || {
echo "expected $file to contain: $text" >&2
exit 1
}
}

expect_output "asset=ocvm-x86_64-unknown-linux-gnu.tar.gz" \
env OCVM_INSTALL_DRY_RUN=1 OCVM_TEST_UNAME_S=Linux OCVM_TEST_UNAME_M=x86_64 ./install.sh

expect_output "asset=ocvm-x86_64-apple-darwin.tar.gz" \
env OCVM_INSTALL_DRY_RUN=1 OCVM_TEST_UNAME_S=Darwin OCVM_TEST_UNAME_M=x86_64 ./install.sh

expect_output "asset=ocvm-aarch64-apple-darwin.tar.gz" \
env OCVM_INSTALL_DRY_RUN=1 OCVM_TEST_UNAME_S=Darwin OCVM_TEST_UNAME_M=arm64 ./install.sh

expect_file_text .github/workflows/release.yml "target: x86_64-unknown-linux-gnu"
expect_file_text .github/workflows/release.yml "target: x86_64-apple-darwin"
expect_file_text .github/workflows/release.yml "target: aarch64-apple-darwin"
expect_file_text .github/workflows/release.yml "target: x86_64-pc-windows-msvc"
expect_file_text .github/workflows/release.yml 'shasum -a 256 "${name}.tar.gz" > "${name}.tar.gz.sha256"'
expect_file_text .github/workflows/release.yml '"$hash $name.zip"'

echo "release prep checks passed"
Loading