@@ -109,67 +109,92 @@ func generateMCPGatewayStartStep(config *MCPGatewayConfig, mcpServersConfig map[
109109 // Escape single quotes in JSON for shell
110110 escapedJSON := strings .ReplaceAll (string (configJSON ), "'" , "'\\ ''" )
111111
112+ // Detect action mode at compile time
113+ actionMode := DetectActionMode ()
114+ gatewayLog .Printf ("Generating gateway step for action mode: %s" , actionMode )
115+
112116 stepLines := []string {
113117 " - name: Start MCP Gateway" ,
114118 " run: |" ,
115119 " mkdir -p " + MCPGatewayLogsFolder ,
116120 " echo 'Starting MCP Gateway...'" ,
117121 " " ,
118- " # Detect if we're in development mode (runtime detection)" ,
119- " IS_DEV_MODE=\" false\" " ,
120- " if [ \" ${GITHUB_REF}\" = \" \" ] || [[ \" ${GITHUB_REF}\" == refs/pull/* ]] || [[ \" ${GITHUB_REF}\" == refs/heads/* && \" ${GITHUB_REF}\" != refs/heads/release* ]]; then" ,
121- " IS_DEV_MODE=\" true\" " ,
122- " fi" ,
123- " " ,
124- " # In development mode, always build from sources if possible" ,
125- " if [ \" $IS_DEV_MODE\" = \" true\" ] && [ -f \" cmd/awmg/main.go\" ] && [ -f \" Makefile\" ]; then" ,
126- " echo 'Building awmg from sources (development mode)...'" ,
127- " make build-awmg" ,
128- " if [ -f \" ./awmg\" ]; then" ,
129- " echo 'Built awmg successfully'" ,
130- " AWMG_CMD=\" ./awmg\" " ,
131- " else" ,
132- " echo 'ERROR: Failed to build awmg from sources'" ,
133- " exit 1" ,
134- " fi" ,
135- " # Check if awmg is already in PATH" ,
136- " elif command -v awmg &> /dev/null; then" ,
137- " echo 'awmg is already available in PATH'" ,
138- " AWMG_CMD=\" awmg\" " ,
139- " # Check for local awmg build" ,
140- " elif [ -f \" ./awmg\" ]; then" ,
141- " echo 'Using existing local awmg build'" ,
142- " AWMG_CMD=\" ./awmg\" " ,
143- " else" ,
144122 }
145-
123+
124+ // Generate different installation code based on compile-time mode
125+ if actionMode == ActionModeDev {
126+ // Development mode: build from sources
127+ gatewayLog .Print ("Using development mode - will build awmg from sources" )
128+ stepLines = append (stepLines ,
129+ " # Development mode: Build awmg from sources" ,
130+ " if [ -f \" cmd/awmg/main.go\" ] && [ -f \" Makefile\" ]; then" ,
131+ " echo 'Building awmg from sources (development mode)...'" ,
132+ " make build-awmg" ,
133+ " if [ -f \" ./awmg\" ]; then" ,
134+ " echo 'Built awmg successfully'" ,
135+ " AWMG_CMD=\" ./awmg\" " ,
136+ " else" ,
137+ " echo 'ERROR: Failed to build awmg from sources'" ,
138+ " exit 1" ,
139+ " fi" ,
140+ " # Check if awmg is already in PATH" ,
141+ " elif command -v awmg &> /dev/null; then" ,
142+ " echo 'awmg is already available in PATH'" ,
143+ " AWMG_CMD=\" awmg\" " ,
144+ " # Check for local awmg build" ,
145+ " elif [ -f \" ./awmg\" ]; then" ,
146+ " echo 'Using existing local awmg build'" ,
147+ " AWMG_CMD=\" ./awmg\" " ,
148+ " else" ,
149+ " echo 'ERROR: Could not find awmg binary or source files'" ,
150+ " echo 'Please build awmg with: make build-awmg'" ,
151+ " exit 1" ,
152+ " fi" ,
153+ )
154+ } else {
155+ // Release mode: download from GitHub releases
156+ gatewayLog .Print ("Using release mode - will download awmg from releases" )
157+ stepLines = append (stepLines ,
158+ " # Release mode: Download awmg from releases" ,
159+ " # Check if awmg is already in PATH" ,
160+ " if command -v awmg &> /dev/null; then" ,
161+ " echo 'awmg is already available in PATH'" ,
162+ " AWMG_CMD=\" awmg\" " ,
163+ " # Check for local awmg build" ,
164+ " elif [ -f \" ./awmg\" ]; then" ,
165+ " echo 'Using existing local awmg build'" ,
166+ " AWMG_CMD=\" ./awmg\" " ,
167+ " else" ,
168+ " # Download awmg from releases" ,
169+ " echo 'Downloading awmg from GitHub releases...'" ,
170+ " " ,
171+ " # Detect platform" ,
172+ " OS=$(uname -s | tr '[:upper:]' '[:lower:]')" ,
173+ " ARCH=$(uname -m)" ,
174+ " if [ \" $ARCH\" = \" x86_64\" ]; then ARCH=\" amd64\" ; fi" ,
175+ " if [ \" $ARCH\" = \" aarch64\" ]; then ARCH=\" arm64\" ; fi" ,
176+ " " ,
177+ " AWMG_BINARY=\" awmg-${OS}-${ARCH}\" " ,
178+ " if [ \" $OS\" = \" windows\" ]; then AWMG_BINARY=\" ${AWMG_BINARY}.exe\" ; fi" ,
179+ " " ,
180+ " # Download from releases using curl (no gh CLI dependency)" ,
181+ " RELEASE_URL=\" https://github.com/githubnext/gh-aw/releases/latest/download/$AWMG_BINARY\" " ,
182+ " echo \" Downloading from $RELEASE_URL\" " ,
183+ " if curl -L -f -o \" /tmp/$AWMG_BINARY\" \" $RELEASE_URL\" ; then" ,
184+ " chmod +x \" /tmp/$AWMG_BINARY\" " ,
185+ " AWMG_CMD=\" /tmp/$AWMG_BINARY\" " ,
186+ " echo 'Downloaded awmg successfully'" ,
187+ " else" ,
188+ " echo 'ERROR: Could not download awmg binary'" ,
189+ " echo 'Please ensure awmg is available or download it from:'" ,
190+ " echo 'https://github.com/githubnext/gh-aw/releases'" ,
191+ " exit 1" ,
192+ " fi" ,
193+ " fi" ,
194+ )
195+ }
196+
146197 stepLines = append (stepLines ,
147- " # Download awmg from releases" ,
148- " echo 'Downloading awmg from GitHub releases...'" ,
149- " " ,
150- " # Detect platform" ,
151- " OS=$(uname -s | tr '[:upper:]' '[:lower:]')" ,
152- " ARCH=$(uname -m)" ,
153- " if [ \" $ARCH\" = \" x86_64\" ]; then ARCH=\" amd64\" ; fi" ,
154- " if [ \" $ARCH\" = \" aarch64\" ]; then ARCH=\" arm64\" ; fi" ,
155- " " ,
156- " AWMG_BINARY=\" awmg-${OS}-${ARCH}\" " ,
157- " if [ \" $OS\" = \" windows\" ]; then AWMG_BINARY=\" ${AWMG_BINARY}.exe\" ; fi" ,
158- " " ,
159- " # Download from releases using curl (no gh CLI dependency)" ,
160- " RELEASE_URL=\" https://github.com/githubnext/gh-aw/releases/latest/download/$AWMG_BINARY\" " ,
161- " echo \" Downloading from $RELEASE_URL\" " ,
162- " if curl -L -f -o \" /tmp/$AWMG_BINARY\" \" $RELEASE_URL\" ; then" ,
163- " chmod +x \" /tmp/$AWMG_BINARY\" " ,
164- " AWMG_CMD=\" /tmp/$AWMG_BINARY\" " ,
165- " echo 'Downloaded awmg successfully'" ,
166- " else" ,
167- " echo 'ERROR: Could not find or download awmg binary'" ,
168- " echo 'Please ensure awmg is available or download it from:'" ,
169- " echo 'https://github.com/githubnext/gh-aw/releases'" ,
170- " exit 1" ,
171- " fi" ,
172- " fi" ,
173198 " " ,
174199 " # Start MCP gateway in background with config piped via stdin" ,
175200 fmt .Sprintf (" echo '%s' | $AWMG_CMD --port %d --log-dir %s > %s/gateway.log 2>&1 &" , escapedJSON , port , MCPGatewayLogsFolder , MCPGatewayLogsFolder ),
0 commit comments