35 lines
2.0 KiB
Bash
Executable File
35 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# release-macos.sh <repo-dir> [tag] — build the macOS aarch64 packages with the repo's packaging/macos/package.sh and
|
|
# (re)create the Gitea release on masi/<name> with them. Tag defaults to v<version from the dmg name>.
|
|
# Ad-hoc signed, not notarized. Needs rustup's cargo first in PATH. Env: GITEA, OWNER, TEA_LOGIN.
|
|
set -euo pipefail
|
|
cd "${1:?usage: release-macos.sh <repo-dir> [tag]}"
|
|
NAME=$(basename "$PWD"); GITEA=${GITEA:-https://git.marcospaulo.dev.br}; OWNER=${OWNER:-masi}
|
|
LOGIN=${TEA_LOGIN:-${GITEA#*://}}
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
rm -rf dist/release
|
|
# macOS refuses `hdiutil attach` onto a mountpoint on some external volumes (nosuid/noowners): use /tmp for the
|
|
# verification mount, patching the repo's script for this run only.
|
|
PKG=$PWD/packaging/macos/package.sh
|
|
if grep -qE 'MOUNT="\$WORK/dmg-check"|mount="\$WORK/dmg-verify-mount"' "$PKG"; then
|
|
trap 'git -C "$(dirname "$PKG")" checkout -q -- "$PKG"' EXIT
|
|
sed -i '' -e 's|MOUNT="$WORK/dmg-check"|MOUNT="$(mktemp -d /tmp/dmg-check.XXXXXX)"|' \
|
|
-e 's|mount="$WORK/dmg-verify-mount"|mount="$(mktemp -d /tmp/dmg-verify.XXXXXX)"|' "$PKG"
|
|
fi
|
|
packaging/macos/package.sh --arch aarch64
|
|
cd dist/release
|
|
FILES=(); for f in *; do FILES+=(--asset "$f"); done
|
|
VER=$(ls | sed -nE 's/^[a-z-]+-([0-9][0-9A-Za-z.+-]*)-macos-.*/\1/p' | head -1)
|
|
TAG=${2:-v$VER}
|
|
# Never delete an existing release (it may carry assets from other platforms): add or replace only our files.
|
|
if tea releases list --login "$LOGIN" --repo "$OWNER/$NAME" -o simple 2>/dev/null | awk '{print $1}' | grep -qx "$TAG"; then
|
|
for f in *; do
|
|
tea releases assets delete --login "$LOGIN" --repo "$OWNER/$NAME" --confirm "$TAG" "$f" 2>/dev/null || true
|
|
done
|
|
tea releases assets create --login "$LOGIN" --repo "$OWNER/$NAME" "$TAG" *
|
|
else
|
|
tea releases create --login "$LOGIN" --repo "$OWNER/$NAME" --tag "$TAG" --target debrand --title "$NAME $VER" \
|
|
--note "macOS Apple silicon (aarch64) build. Ad-hoc signed, not notarized." "${FILES[@]}"
|
|
fi
|
|
tea releases assets list --login "$LOGIN" --repo "$OWNER/$NAME" "$TAG"
|