|
22 | 22 | default: '' |
23 | 23 |
|
24 | 24 | jobs: |
25 | | - prepare: |
| 25 | +prepare: |
26 | 26 | runs-on: ubuntu-latest |
27 | 27 | outputs: |
28 | 28 | run-build: ${{ steps.check.outputs.run }} |
|
32 | 32 | mapchete-hub-cli-ref: ${{ steps.resolve.outputs.cli }} |
33 | 33 | steps: |
34 | 34 | - uses: actions/checkout@v4 |
| 35 | + |
35 | 36 | - id: check |
36 | 37 | run: | |
37 | 38 | if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then |
|
52 | 53 |
|
53 | 54 | # 2. Extract values from the repository_dispatch payload if they exist |
54 | 55 | DISPATCH_REPO="${{ github.event.client_payload.source_repo }}" |
55 | | - # Prioritize image_tag (versioning) over sha (development commits) |
56 | 56 | DISPATCH_REF="${{ github.event.client_payload.image_tag || github.event.client_payload.sha }}" |
57 | 57 |
|
58 | | - # 3. Resolve final references using a strict priority order: |
59 | | - # Manual Input > Matching Repository Dispatch > versions.yml Default |
60 | | - |
| 58 | + # 3. Resolve final references |
61 | 59 | if [[ -n "${{ inputs.mapchete-ref }}" ]]; then M_REF="${{ inputs.mapchete-ref }}" |
62 | 60 | elif [[ "$DISPATCH_REPO" == "mapchete" ]]; then M_REF="$DISPATCH_REF" |
63 | 61 | else M_REF="$MAPCHETE_DEFAULT_VAL"; fi |
|
79 | 77 | echo "hub=$HUB_REF" >> $GITHUB_OUTPUT |
80 | 78 | echo "cli=$CLI_REF" >> $GITHUB_OUTPUT |
81 | 79 |
|
| 80 | + - name: Generate Summary |
| 81 | + run: | |
| 82 | + echo "### 🛠️ Build Preparation Summary" >> $GITHUB_STEP_SUMMARY |
| 83 | + echo "**Trigger Event:** \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY |
| 84 | + echo "**Target Image:** \`${{ inputs.image-name }}\`" >> $GITHUB_STEP_SUMMARY |
| 85 | + echo "**Run Build:** \`${{ steps.check.outputs.run }}\`" >> $GITHUB_STEP_SUMMARY |
| 86 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 87 | + echo "| Component | Resolved Reference |" >> $GITHUB_STEP_SUMMARY |
| 88 | + echo "| :--- | :--- |" >> $GITHUB_STEP_SUMMARY |
| 89 | + echo "| mapchete | \`${{ steps.resolve.outputs.mapchete }}\` |" >> $GITHUB_STEP_SUMMARY |
| 90 | + echo "| mapchete-eo | \`${{ steps.resolve.outputs.eo }}\` |" >> $GITHUB_STEP_SUMMARY |
| 91 | + echo "| mapchete-hub | \`${{ steps.resolve.outputs.hub }}\` |" >> $GITHUB_STEP_SUMMARY |
| 92 | + echo "| mapchete-hub-cli | \`${{ steps.resolve.outputs.cli }}\` |" >> $GITHUB_STEP_SUMMARY |
| 93 | +
|
82 | 94 | build: |
83 | 95 | needs: prepare |
84 | 96 | if: needs.prepare.outputs.run-build == 'true' |
@@ -194,23 +206,77 @@ jobs: |
194 | 206 | subject-digest: ${{ steps.push.outputs.digest }} |
195 | 207 | push-to-registry: true |
196 | 208 |
|
| 209 | + - name: Update Version Tracking Files |
| 210 | + if: github.event_name == 'repository_dispatch' |
| 211 | + run: | |
| 212 | + NEW_REF="${{ github.event.client_payload.image_tag }}" |
| 213 | + SOURCE="${{ github.event.client_payload.source_repo }}" |
| 214 | + TYPE="${{ github.event.client_payload.type }}" |
| 215 | + DATE=$(date +'%Y-%m-%d') |
| 216 | + |
| 217 | + # 1. Determine the target reference for versions.yml |
| 218 | + # If it's a version release, use the tag. Otherwise, use 'main'. |
| 219 | + if [[ "$TYPE" == "version" ]]; then |
| 220 | + TARGET_REF="$NEW_REF" |
| 221 | + else |
| 222 | + TARGET_REF="main" |
| 223 | + fi |
| 224 | +
|
| 225 | + echo "Updating $SOURCE to $TARGET_REF in versions.yml" |
| 226 | +
|
| 227 | + # 2. Update versions.yml (assuming keys exist in the file) |
| 228 | + case "$SOURCE" in |
| 229 | + "mapchete") |
| 230 | + sed -i "s/^MAPCHETE_REF:.*/MAPCHETE_REF: $TARGET_REF/" versions.yml |
| 231 | + ;; |
| 232 | + "mapchete-eo") |
| 233 | + sed -i "s/^MAPCHETE_EO_REF:.*/MAPCHETE_EO_REF: $TARGET_REF/" versions.yml |
| 234 | + ;; |
| 235 | + "mapchete-hub") |
| 236 | + sed -i "s/^MAPCHETE_HUB_REF:.*/MAPCHETE_HUB_REF: $TARGET_REF/" versions.yml |
| 237 | + ;; |
| 238 | + "mapchete-hub-cli") |
| 239 | + sed -i "s/^MAPCHETE_HUB_CLI_REF:.*/MAPCHETE_HUB_CLI_REF: $TARGET_REF/" versions.yml |
| 240 | + ;; |
| 241 | + esac |
| 242 | +
|
| 243 | + # 3. Handle CHANGELOG.md (Only for Version Releases) |
| 244 | + if [[ "$TYPE" == "version" ]]; then |
| 245 | + # Create file if it doesn't exist |
| 246 | + if [[ ! -f CHANGELOG.md ]]; then |
| 247 | + echo "# Changelog" > CHANGELOG.md |
| 248 | + echo "All notable changes to the Mapchete Container Images will be documented in this file." >> CHANGELOG.md |
| 249 | + fi |
| 250 | +
|
| 251 | + # Create the new entry |
| 252 | + NEW_ENTRY="## [$NEW_REF] - $DATE\n- Automated release alignment: **$SOURCE** updated to \`$NEW_REF\`\n- Image: \`ghcr.io/mapchete/${{ inputs.image-name }}:$NEW_REF\`\n- Fingerprint: \`${{ steps.image-fingerprint-check.outputs.fingerprint }}\` \n" |
| 253 | +
|
| 254 | + # Prepend the entry below the header (line 3) |
| 255 | + sed -i "3i $NEW_ENTRY" CHANGELOG.md |
| 256 | + fi |
| 257 | +
|
197 | 258 | - name: Automated Version PR |
198 | 259 | if: github.event_name == 'repository_dispatch' && github.event.client_payload.type == 'version' |
199 | 260 | uses: peter-evans/create-pull-request@v6 |
200 | 261 | with: |
201 | 262 | token: ${{ secrets.MAPCHETE_PAT || secrets.GITHUB_TOKEN }} |
202 | | - commit-message: "chore: update ${{ inputs.image-name }} to ${{ github.event.client_payload.image_tag }}" |
203 | | - branch: "bump/${{ inputs.image-name }}" |
204 | | - title: "🚀 Bump ${{ inputs.image-name }} version" |
| 263 | + commit-message: "chore(release): align ${{ inputs.image-name }} with ${{ github.event.client_payload.image_tag }}" |
| 264 | + branch: "release/${{ inputs.image-name }}-${{ github.event.client_payload.image_tag }}" |
| 265 | + title: "🚀 Release Align: ${{ inputs.image-name }} @ ${{ github.event.client_payload.image_tag }}" |
205 | 266 | body: | |
206 | | - Automated update from `${{ github.event.client_payload.source_repo }}`. |
207 | | - - **New Version:** `${{ github.event.client_payload.image_tag }}` |
208 | | - - **Fingerprint:** `${{ steps.image-fingerprint-check.outputs.fingerprint }}` |
| 267 | + ### 📦 Automated Release Alignment |
| 268 | + A new tagged version was detected in the source repository. |
| 269 | + |
| 270 | + **Changes:** |
| 271 | + 1. **versions.yml**: Updated `${{ github.event.client_payload.source_repo }}` reference to `${{ github.event.client_payload.image_tag }}`. |
| 272 | + 2. **CHANGELOG.md**: Added release entry. |
| 273 | + |
| 274 | + Verification Fingerprint: `${{ steps.image-fingerprint-check.outputs.fingerprint }}` |
209 | 275 | base: main |
210 | 276 | delete-branch: true |
| 277 | + labels: "automated-pr, release-alignment" |
211 | 278 | assignees: "scartography" |
212 | 279 | reviewers: "ungarj" |
213 | | - labels: "automated-pr" |
214 | 280 |
|
215 | 281 | cleanup-registry: |
216 | 282 | needs: [prepare, build] |
|
0 commit comments