1+ # Licensed to the Apache Software Foundation (ASF) under one or more
2+ # contributor license agreements. See the NOTICE file distributed with
3+ # this work for additional information regarding copyright ownership.
4+ # The ASF licenses this file to You under the Apache License, Version 2.0
5+ # (the "License"); you may not use this file except in compliance with
6+ # the License. You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+
16+ # ╔═══════════════════════════════════════════════════════════════════════════╗
17+ # ║ NIGHTLY BUILD WORKFLOW ║
18+ # ║ (Latest Unstable Builds) ║
19+ # ╚═══════════════════════════════════════════════════════════════════════════╝
20+ #
21+ # PURPOSE: Automated nightly builds for testing latest changes
22+ #
23+ # WHEN TO USE:
24+ # -----------
25+ # ✅ Automatic daily at 2 AM UTC
26+ # ✅ For testing latest main branch changes
27+ # ✅ Provides unstable/preview builds
28+ # ✅ Publishes to apache/solr-mcp-nightly
29+ # ❌ DO NOT use for production releases
30+ #
31+ # COMPARISON WITH OTHER WORKFLOWS:
32+ # --------------------------------
33+ # nightly-build.yml (THIS FILE):
34+ # - Purpose: Nightly builds
35+ # - Trigger: Scheduled (2 AM UTC)
36+ # - Docker Hub: apache/solr-mcp-nightly
37+ # - Stability: Unstable/preview
38+ # - Use for: Testing latest changes
39+ #
40+ # build-and-publish.yml:
41+ # - Purpose: Development CI/CD
42+ # - Trigger: Automatic (push/PR)
43+ # - Docker Hub: Personal namespace
44+ # - Use for: Daily development work
45+ #
46+ # release-publish.yml:
47+ # - Purpose: Official ASF releases
48+ # - Trigger: Manual (after vote)
49+ # - Docker Hub: apache/solr-mcp
50+ # - Stability: Stable/production
51+ # - Use for: Production releases
52+ #
53+ # atr-release.yml:
54+ # - Purpose: Future ATR automation
55+ # - Status: Blocked (needs automated signing)
56+ # - Use for: When ATR is ready
57+ #
58+ # ────────────────────────────────────────────────────────────────────────────
59+ #
60+ # Nightly Build Workflow for Apache Solr MCP
61+ # ===========================================
62+ #
63+ # This workflow creates nightly builds for the Solr MCP project and publishes
64+ # them to Apache's nightly infrastructure and Docker Hub preview registry.
65+ #
66+ # Schedule:
67+ # ---------
68+ # Runs daily at 2 AM UTC or on manual trigger
69+ #
70+ # Artifacts Published:
71+ # --------------------
72+ # 1. Source tarball to https://nightlies.apache.org/solr/mcp/
73+ # 2. Docker image to apache/solr-mcp-nightly on Docker Hub
74+ # 3. Build artifacts to GitHub releases (pre-release)
75+
76+ name : Nightly Build
77+
78+ # Triggers for the workflow
79+ # - schedule: runs automatically via cron at a fixed time (02:00 UTC daily)
80+ # - workflow_dispatch: allow maintainers to run the workflow manually and pass inputs
81+ on :
82+ schedule :
83+ # Run at 2 AM UTC every day
84+ - cron : ' 0 2 * * *'
85+ workflow_dispatch : # Allow manual trigger
86+ inputs :
87+ # Optional input to skip Docker publishing if you only want to build artifacts
88+ skip_docker :
89+ description : ' Skip Docker publishing'
90+ required : false
91+ type : boolean
92+ default : false
93+
94+ # Environment variables used by steps below
95+ # - JAVA_VERSION: selects the JDK version used to build and run Gradle
96+ # - JAVA_DISTRIBUTION: selects the vendor (Temurin = Eclipse Adoptium)
97+ env :
98+ JAVA_VERSION : ' 25'
99+ JAVA_DISTRIBUTION : ' temurin'
100+
101+ jobs :
102+ nightly-build :
103+ name : Nightly Build and Publish
104+ runs-on : ubuntu-latest
105+
106+ # Permissions required by this job:
107+ # - contents:write → needed to create GitHub pre-releases and upload assets
108+ # - packages:write → needed when pushing container images to registries
109+ permissions :
110+ contents : write
111+ packages : write
112+
113+ steps :
114+ - name : Checkout code
115+ uses : actions/checkout@v4
116+
117+ - name : Set up JDK ${{ env.JAVA_VERSION }}
118+ uses : actions/setup-java@v4
119+ with :
120+ java-version : ${{ env.JAVA_VERSION }}
121+ distribution : ${{ env.JAVA_DISTRIBUTION }}
122+ cache : ' gradle'
123+
124+ - name : Grant execute permission for gradlew
125+ run : chmod +x gradlew
126+
127+ - name : Generate nightly version
128+ id : version
129+ run : |
130+ # Generate version with date stamp
131+ DATE_STAMP=$(date +%Y%m%d)
132+ SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
133+ NIGHTLY_VERSION="nightly-${DATE_STAMP}-${SHORT_SHA}"
134+ echo "version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT
135+ echo "date=$DATE_STAMP" >> $GITHUB_OUTPUT
136+
137+ - name : Build project
138+ run : ./gradlew build
139+
140+ - name : Create source distribution
141+ run : |
142+ # Create source tarball
143+ mkdir -p build/distributions
144+ tar czf build/distributions/solr-mcp-${{ steps.version.outputs.version }}-src.tar.gz \
145+ --exclude='.git' \
146+ --exclude='build' \
147+ --exclude='.gradle' \
148+ --exclude='*.iml' \
149+ --exclude='.idea' \
150+ .
151+
152+ # Generate SHA512 checksum
153+ cd build/distributions
154+ sha512sum solr-mcp-${{ steps.version.outputs.version }}-src.tar.gz > \
155+ solr-mcp-${{ steps.version.outputs.version }}-src.tar.gz.sha512
156+
157+ - name : Build and publish Docker image to apache/solr-mcp-nightly
158+ if : ${{ !inputs.skip_docker }}
159+ run : |
160+ # Build and push to apache/solr-mcp-nightly
161+ # Note: Requires DOCKERHUB_APACHE_USERNAME and DOCKERHUB_APACHE_TOKEN secrets
162+ # These should be set up with Apache PMC credentials
163+ if [[ -n "${{ secrets.DOCKERHUB_APACHE_USERNAME }}" ]]; then
164+ ./gradlew jib \
165+ -Djib.to.image=apache/solr-mcp-nightly:${{ steps.version.outputs.version }} \
166+ -Djib.to.auth.username=${{ secrets.DOCKERHUB_APACHE_USERNAME }} \
167+ -Djib.to.auth.password=${{ secrets.DOCKERHUB_APACHE_TOKEN }} \
168+ -Djib.to.tags=${{ steps.version.outputs.version }},latest-nightly
169+ fi
170+
171+ - name : Upload to Apache Nightlies
172+ if : ${{ secrets.APACHE_NIGHTLIES_USER != '' }}
173+ run : |
174+ # Upload to Apache nightlies infrastructure
175+ # Requires APACHE_NIGHTLIES_USER and APACHE_NIGHTLIES_KEY secrets
176+ # These are typically available to Apache committers
177+
178+ # Create directory structure
179+ UPLOAD_DIR="solr/mcp/${{ steps.version.outputs.date }}"
180+
181+ # Use rsync or scp to upload to nightlies.apache.org
182+ # This is a placeholder - actual implementation depends on Apache infra access
183+ echo "Would upload to: https://nightlies.apache.org/${UPLOAD_DIR}/"
184+ echo "Files to upload:"
185+ ls -la build/distributions/
186+
187+ - name : Create GitHub pre-release
188+ uses : softprops/action-gh-release@v1
189+ with :
190+ tag_name : nightly-${{ steps.version.outputs.date }}
191+ name : Nightly Build ${{ steps.version.outputs.date }}
192+ prerelease : true
193+ draft : false
194+ files : |
195+ build/distributions/solr-mcp-*.tar.gz
196+ build/distributions/solr-mcp-*.sha512
197+ build/libs/solr-mcp-*.jar
198+ body : |
199+ ## Nightly Build
200+
201+ **Date**: ${{ steps.version.outputs.date }}
202+ **Commit**: ${{ github.sha }}
203+
204+ ### Docker Image
205+ ```bash
206+ docker pull apache/solr-mcp-nightly:${{ steps.version.outputs.version }}
207+ ```
208+
209+ ### Source Distribution
210+ - [solr-mcp-${{ steps.version.outputs.version }}-src.tar.gz](https://github.com/${{ github.repository }}/releases/download/nightly-${{ steps.version.outputs.date }}/solr-mcp-${{ steps.version.outputs.version }}-src.tar.gz)
211+
212+ **Note**: This is a nightly build and not an official Apache release.
213+
214+ - name : Clean up old nightly releases
215+ run : |
216+ # Keep only the last 7 nightly builds
217+ # This helps manage storage and keeps releases clean
218+ gh release list --limit 100 | grep "^nightly-" | tail -n +8 | cut -f1 | while read tag; do
219+ echo "Deleting old nightly release: $tag"
220+ gh release delete "$tag" --yes --cleanup-tag
221+ done
222+ env :
223+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments