Skip to content

Commit d32fd8f

Browse files
committed
feat: enhance release workflow with additional artifact source options and build type selection
1 parent 79bb1ae commit d32fd8f

File tree

2 files changed

+104
-15
lines changed

2 files changed

+104
-15
lines changed

.github/workflows/release.yml

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@ on:
1414
description: "Version name for the release (required for manual runs)"
1515
required: true
1616
type: string
17+
artifact_source:
18+
description: "Source of artifacts to release"
19+
required: true
20+
type: choice
21+
options:
22+
- "auto-detect-release"
23+
- "auto-detect-ci"
24+
- "specific-workflow"
25+
default: "auto-detect-release"
26+
workflow_run_id:
27+
description: "Specific workflow run ID (only used when artifact_source is 'specific-workflow')"
28+
required: false
29+
type: string
30+
build_type:
31+
description: "Build type to search for (when using auto-detect)"
32+
required: false
33+
type: choice
34+
options:
35+
- "release"
36+
- "ci"
37+
default: "release"
1738
draft:
1839
description: "Create as draft release"
1940
required: false
@@ -48,6 +69,9 @@ jobs:
4869
EVENT_NAME: ${{ github.event_name }}
4970
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
5071
INPUT_VERSION: ${{ github.event.inputs.version_name }}
72+
INPUT_ARTIFACT_SOURCE: ${{ github.event.inputs.artifact_source }}
73+
INPUT_WORKFLOW_RUN_ID: ${{ github.event.inputs.workflow_run_id }}
74+
INPUT_BUILD_TYPE: ${{ github.event.inputs.build_type }}
5175
GH_TOKEN: ${{ secrets.PAT }}
5276
run: |
5377
set -euo pipefail
@@ -88,26 +112,59 @@ jobs:
88112
exit 1
89113
fi
90114
VERSION_NAME="$INPUT_VERSION"
91-
# Try to find the most recent successful docker-build run with release metadata
92-
echo "Locating latest successful docker-build run with build_type=release..."
93-
mapfile -t CANDIDATES < <(gh run list -w "Build IronFox (Docker)" --json databaseId,conclusion,status -q '[.[] | select(.conclusion=="success" and .status=="completed") | .databaseId]' | head -n 15)
94-
for id in "${CANDIDATES[@]}"; do
95-
rm -rf _meta && mkdir -p _meta
96-
if gh run download "$id" --name ironfox-build-metadata --dir _meta >/dev/null 2>&1; then
115+
116+
# Handle artifact source based on user selection
117+
ARTIFACT_SOURCE="${INPUT_ARTIFACT_SOURCE:-auto-detect-release}"
118+
echo "Artifact source: $ARTIFACT_SOURCE"
119+
120+
if [[ "$ARTIFACT_SOURCE" == "specific-workflow" ]]; then
121+
# Use specific workflow run ID provided by user
122+
if [[ -z "${INPUT_WORKFLOW_RUN_ID:-}" ]]; then
123+
echo "Error: workflow_run_id is required when artifact_source is 'specific-workflow'"
124+
exit 1
125+
fi
126+
RUN_ID="$INPUT_WORKFLOW_RUN_ID"
127+
echo "Using specified workflow run ID: $RUN_ID"
128+
129+
# Verify the run exists and has artifacts
130+
mkdir -p _meta
131+
if gh run download "$RUN_ID" --name ironfox-build-metadata --dir _meta >/dev/null 2>&1; then
97132
set -o allexport
98133
source _meta/metadata.env || true
99134
set +o allexport
100-
if [[ "${build_type:-}" == "release" ]]; then
101-
RUN_ID="$id"
102-
DO_RELEASE=true
103-
echo "Selected docker-build run: $RUN_ID (build_type=release)"
104-
break
135+
echo "Found metadata from run $RUN_ID (build_type=${build_type:-unknown})"
136+
DO_RELEASE=true
137+
else
138+
echo "Warning: Could not download metadata from run $RUN_ID, but proceeding anyway"
139+
DO_RELEASE=true
140+
fi
141+
else
142+
# Auto-detect based on build type
143+
SEARCH_BUILD_TYPE="${INPUT_BUILD_TYPE:-release}"
144+
if [[ "$ARTIFACT_SOURCE" == "auto-detect-ci" ]]; then
145+
SEARCH_BUILD_TYPE="ci"
146+
fi
147+
148+
echo "Locating latest successful docker-build run with build_type=$SEARCH_BUILD_TYPE..."
149+
mapfile -t CANDIDATES < <(gh run list -w "Build IronFox (Docker)" --json databaseId,conclusion,status -q '[.[] | select(.conclusion=="success" and .status=="completed") | .databaseId]' | head -n 15)
150+
for id in "${CANDIDATES[@]}"; do
151+
rm -rf _meta && mkdir -p _meta
152+
if gh run download "$id" --name ironfox-build-metadata --dir _meta >/dev/null 2>&1; then
153+
set -o allexport
154+
source _meta/metadata.env || true
155+
set +o allexport
156+
if [[ "${build_type:-}" == "$SEARCH_BUILD_TYPE" ]]; then
157+
RUN_ID="$id"
158+
DO_RELEASE=true
159+
echo "Selected docker-build run: $RUN_ID (build_type=$SEARCH_BUILD_TYPE)"
160+
break
161+
fi
105162
fi
163+
done
164+
if [[ "$DO_RELEASE" != "true" ]]; then
165+
echo "Error: Could not find a recent successful docker-build run with build_type=$SEARCH_BUILD_TYPE"
166+
exit 1
106167
fi
107-
done
108-
if [[ "$DO_RELEASE" != "true" ]]; then
109-
echo "Error: Could not find a recent successful docker-build run with buildType=release"
110-
exit 1
111168
fi
112169
else
113170
echo "Error: Unexpected event type: $EVENT_NAME"

scripts/github-build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,36 @@ fi
4545

4646
mkdir -p artifacts
4747

48+
ensure_gecko_source_metadata() {
49+
local repo_path="${mozilla_release:-}" sed_bin="${SED:-sed}"
50+
51+
if [[ -z "$repo_path" || ! -d "$repo_path/.git" ]]; then
52+
return
53+
fi
54+
55+
local repo_url commit
56+
repo_url=$(git -C "$repo_path" remote get-url origin 2>/dev/null || true)
57+
commit=$(git -C "$repo_path" rev-parse HEAD 2>/dev/null || true)
58+
59+
if [[ -n "$repo_url" ]]; then
60+
export MOZ_SOURCE_REPO="$repo_url"
61+
fi
62+
63+
if [[ -n "$commit" ]]; then
64+
export MOZ_SOURCE_CHANGESET="$commit"
65+
fi
66+
67+
local mozconfig="$repo_path/mozconfig"
68+
if [[ -f "$mozconfig" ]]; then
69+
if [[ -n "$repo_url" ]]; then
70+
"$sed_bin" -i "s|^export MOZ_SOURCE_REPO=.*|export MOZ_SOURCE_REPO='$repo_url'|" "$mozconfig"
71+
fi
72+
if [[ -n "$commit" ]]; then
73+
"$sed_bin" -i "s|^export MOZ_SOURCE_CHANGESET=.*|export MOZ_SOURCE_CHANGESET='$commit'|" "$mozconfig"
74+
fi
75+
fi
76+
}
77+
4878
# Setup environment variables similar to env_docker.sh
4979
export ANDROID_SDK_ROOT="${ANDROID_HOME:-/root/android-sdk}"
5080
export ANDROID_HOME="${ANDROID_HOME:-$ANDROID_SDK_ROOT}"
@@ -84,6 +114,7 @@ fi
84114

85115
bash -x ./scripts/get_sources.sh
86116
source "scripts/env_local.sh"
117+
ensure_gecko_source_metadata
87118

88119
# Apply mocha patch
89120
if [[ -f "scripts/mocha-patch.sh" ]]; then
@@ -101,6 +132,7 @@ if [[ -z "${IRONFOX_VERSION:-}" ]]; then
101132
fi
102133

103134
bash -x ./scripts/prebuild.sh "$VARIANT_ARG"
135+
ensure_gecko_source_metadata
104136

105137
if [[ "$BUILD_TYPE" == "bundle" ]]; then
106138
export MOZ_ANDROID_FAT_AAR_ARM64_V8A="$AAR_ARTIFACTS/geckoview-arm64-v8a.zip"

0 commit comments

Comments
 (0)