Skip to content

Commit 1eb880e

Browse files
committed
ci(zaparoo): add unstable upstream build alongside stable
Publishes a rolling MiSTer_Zaparoo_unstable prerelease built against upstream master HEAD with the Zaparoo commits cherry-picked on top. Equivalent to the upstream MiSTer-unstable-nightlies build but for this fork. Runs in both push and daily sync workflows, so users can grab either the stable or the latest unstable from one repo.
1 parent f2e4636 commit 1eb880e

4 files changed

Lines changed: 145 additions & 1 deletion

File tree

.github/build_unstable_release.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
# Build MiSTer_Zaparoo from upstream master HEAD and publish a rolling unstable
3+
# release. Companion to build_release.sh (which targets upstream stable).
4+
# Requires GH_TOKEN in environment.
5+
6+
set -euo pipefail
7+
8+
RELEASE_TAG="${UNSTABLE_RELEASE_TAG:-MiSTer_Zaparoo_unstable}"
9+
10+
METADATA_FILE=$(mktemp)
11+
UNSTABLE_BUILD_METADATA_FILE="${METADATA_FILE}" UNSTABLE_BUILD_METADATA_ONLY=true ./unstable-build.sh
12+
13+
# shellcheck disable=SC1090
14+
source "${METADATA_FILE}"
15+
16+
if [ "${SKIP_EXISTING_RELEASE:-false}" = "true" ] && \
17+
gh release view "${RELEASE_TAG}" 2>/dev/null | grep -q "${UNSTABLE_NAME}_${FORK_SHORT_SHA}"; then
18+
echo "Unstable release for ${UNSTABLE_NAME}+${FORK_SHORT_SHA} already published; skipping."
19+
exit 0
20+
fi
21+
22+
UNSTABLE_BUILD_METADATA_FILE="${METADATA_FILE}" \
23+
UNSTABLE_BUILD_UNSTABLE_COMMIT="${UNSTABLE_COMMIT}" \
24+
./unstable-build.sh
25+
26+
# shellcheck disable=SC1090
27+
source "${METADATA_FILE}"
28+
29+
ARTIFACT_BIN="bin/${UNSTABLE_NAME}_${FORK_SHORT_SHA}"
30+
ARTIFACT_ELF="${ARTIFACT_BIN}.elf"
31+
cp "bin/MiSTer_Zaparoo" "${ARTIFACT_BIN}"
32+
cp "bin/MiSTer_Zaparoo.elf" "${ARTIFACT_ELF}"
33+
34+
# Rolling tag: replace the release on every successful build.
35+
gh release delete "${RELEASE_TAG}" --cleanup-tag --yes 2>/dev/null || true
36+
37+
gh release create "${RELEASE_TAG}" \
38+
--prerelease \
39+
--title "Zaparoo unstable @ ${UNSTABLE_NAME}" \
40+
--notes "Automated build from upstream master HEAD (${UNSTABLE_NAME}) with Zaparoo commit ${FORK_SHORT_SHA}.
41+
42+
Tracks the upstream MiSTer master branch tip — equivalent to the upstream MiSTer-unstable-nightlies build, but with the Zaparoo fork applied. Updated on every push and daily upstream sync." \
43+
"${ARTIFACT_BIN}" \
44+
"${ARTIFACT_ELF}"

.github/workflows/push_release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ jobs:
2828
path: gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf
2929
key: gcc-arm-10.2-2020.11
3030

31-
- name: Build and release
31+
- name: Build and release (stable)
3232
run: bash .github/build_release.sh
3333
env:
3434
GH_TOKEN: ${{ github.token }}
35+
36+
- name: Build and release (unstable)
37+
run: bash .github/build_unstable_release.sh
38+
env:
39+
GH_TOKEN: ${{ github.token }}

.github/workflows/sync_release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ jobs:
4242
env:
4343
GH_TOKEN: ${{ github.token }}
4444
SKIP_EXISTING_RELEASE: true
45+
46+
- name: Build unstable release
47+
run: bash .github/build_unstable_release.sh
48+
env:
49+
GH_TOKEN: ${{ github.token }}
50+
SKIP_EXISTING_RELEASE: true

unstable-build.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
# Build MiSTer_Zaparoo from upstream master HEAD (the "unstable" tip).
3+
#
4+
# Mirrors stable-build.sh but skips the releases/MiSTer_* lookup. Builds in a
5+
# temporary worktree at upstream HEAD with the Zaparoo commits cherry-picked on
6+
# top, so the current checkout stays untouched.
7+
8+
set -euo pipefail
9+
10+
UPSTREAM_REPO="https://github.com/MiSTer-devel/Main_MiSTer.git"
11+
UPSTREAM_REMOTE="${UPSTREAM_REMOTE:-upstream}"
12+
UPSTREAM_BRANCH="${UPSTREAM_BRANCH:-master}"
13+
OUTPUT_DIR="${UNSTABLE_BUILD_OUTPUT_DIR:-bin}"
14+
METADATA_FILE="${UNSTABLE_BUILD_METADATA_FILE:-}"
15+
PINNED_UNSTABLE_COMMIT="${UNSTABLE_BUILD_UNSTABLE_COMMIT:-}"
16+
17+
cd "$(dirname "$0")"
18+
19+
FORK_HEAD=$(git rev-parse HEAD)
20+
FORK_SHORT_SHA=$(git rev-parse --short HEAD)
21+
22+
if ! git remote get-url "${UPSTREAM_REMOTE}" >/dev/null 2>&1; then
23+
git remote add "${UPSTREAM_REMOTE}" "${UPSTREAM_REPO}"
24+
elif [ "${UPSTREAM_REMOTE}" = "upstream" ]; then
25+
UPSTREAM_URL=$(git remote get-url "${UPSTREAM_REMOTE}")
26+
if [ "${UPSTREAM_URL}" != "${UPSTREAM_REPO}" ] && [ "${UPSTREAM_URL}" != "git@github.com:MiSTer-devel/Main_MiSTer.git" ] && [ "${UPSTREAM_URL}" != "ssh://git@github.com/MiSTer-devel/Main_MiSTer.git" ]; then
27+
echo "error: upstream remote points to ${UPSTREAM_URL}, expected ${UPSTREAM_REPO}" >&2
28+
echo " set UPSTREAM_REMOTE to use a custom remote intentionally" >&2
29+
exit 1
30+
fi
31+
fi
32+
33+
git fetch --no-tags --prune --no-recurse-submodules "${UPSTREAM_REMOTE}" \
34+
"+refs/heads/${UPSTREAM_BRANCH}:refs/remotes/${UPSTREAM_REMOTE}/${UPSTREAM_BRANCH}"
35+
36+
UPSTREAM_REF="${UPSTREAM_REMOTE}/${UPSTREAM_BRANCH}"
37+
UNSTABLE_COMMIT=${PINNED_UNSTABLE_COMMIT}
38+
if [ -z "${UNSTABLE_COMMIT}" ]; then
39+
UNSTABLE_COMMIT=$(git rev-parse "${UPSTREAM_REF}")
40+
fi
41+
if [ -z "${UNSTABLE_COMMIT}" ]; then
42+
echo "error: could not resolve upstream HEAD" >&2
43+
exit 1
44+
fi
45+
if ! git merge-base --is-ancestor "${UNSTABLE_COMMIT}" "${UPSTREAM_REF}"; then
46+
echo "error: unstable commit ${UNSTABLE_COMMIT} is not reachable from ${UPSTREAM_REF}" >&2
47+
exit 1
48+
fi
49+
50+
UNSTABLE_SHORT_SHA=$(git rev-parse --short=8 "${UNSTABLE_COMMIT}")
51+
UNSTABLE_DATE=$(TZ=UTC git log -1 --format=%cd --date=format-local:%Y%m%d "${UNSTABLE_COMMIT}")
52+
UNSTABLE_NAME="MiSTer_unstable_${UNSTABLE_DATE}_${UNSTABLE_SHORT_SHA}"
53+
FORK_COMMITS=$(git rev-list --reverse --no-merges "${UPSTREAM_REF}..${FORK_HEAD}")
54+
55+
if [ -n "${METADATA_FILE}" ]; then
56+
cat >"${METADATA_FILE}" <<EOF
57+
UNSTABLE_NAME=${UNSTABLE_NAME}
58+
UNSTABLE_DATE=${UNSTABLE_DATE}
59+
UNSTABLE_COMMIT=${UNSTABLE_COMMIT}
60+
UNSTABLE_SHORT_SHA=${UNSTABLE_SHORT_SHA}
61+
FORK_SHORT_SHA=${FORK_SHORT_SHA}
62+
EOF
63+
fi
64+
65+
if [ "${UNSTABLE_BUILD_METADATA_ONLY:-false}" = "true" ]; then
66+
echo "==> Upstream master HEAD is ${UNSTABLE_NAME}"
67+
exit 0
68+
fi
69+
70+
TMP_WORKTREE=$(mktemp -d "${TMPDIR:-/tmp}/mister-zaparoo-unstable.XXXXXX")
71+
cleanup() {
72+
git worktree remove --force "${TMP_WORKTREE}" >/dev/null 2>&1 || true
73+
}
74+
trap cleanup EXIT
75+
76+
echo "==> Building from upstream ${UNSTABLE_NAME} with Zaparoo ${FORK_SHORT_SHA}"
77+
git worktree add --detach "${TMP_WORKTREE}" "${UNSTABLE_COMMIT}" >/dev/null
78+
79+
if [ -n "${FORK_COMMITS}" ]; then
80+
git -C "${TMP_WORKTREE}" cherry-pick --no-commit ${FORK_COMMITS}
81+
fi
82+
83+
"${TMP_WORKTREE}/docker-build.sh" "$@"
84+
85+
mkdir -p "${OUTPUT_DIR}"
86+
cp "${TMP_WORKTREE}/bin/MiSTer_Zaparoo" "${OUTPUT_DIR}/MiSTer_Zaparoo"
87+
cp "${TMP_WORKTREE}/bin/MiSTer_Zaparoo.elf" "${OUTPUT_DIR}/MiSTer_Zaparoo.elf"
88+
89+
echo "==> Built ${OUTPUT_DIR}/MiSTer_Zaparoo from ${UNSTABLE_NAME}"

0 commit comments

Comments
 (0)