|
14 | 14 | description: "Version name for the release (required for manual runs)" |
15 | 15 | required: true |
16 | 16 | 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" |
17 | 38 | draft: |
18 | 39 | description: "Create as draft release" |
19 | 40 | required: false |
|
48 | 69 | EVENT_NAME: ${{ github.event_name }} |
49 | 70 | WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }} |
50 | 71 | 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 }} |
51 | 75 | GH_TOKEN: ${{ secrets.PAT }} |
52 | 76 | run: | |
53 | 77 | set -euo pipefail |
@@ -88,26 +112,59 @@ jobs: |
88 | 112 | exit 1 |
89 | 113 | fi |
90 | 114 | 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 |
97 | 132 | set -o allexport |
98 | 133 | source _meta/metadata.env || true |
99 | 134 | 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 |
105 | 162 | 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 |
106 | 167 | 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 |
111 | 168 | fi |
112 | 169 | else |
113 | 170 | echo "Error: Unexpected event type: $EVENT_NAME" |
|
0 commit comments