Skip to content

Commit 3719eb8

Browse files
committed
Improve NT selection
1 parent 47a1052 commit 3719eb8

File tree

2 files changed

+81
-8
lines changed

2 files changed

+81
-8
lines changed

.github/workflows/NativePipeline.yml

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
default: ""
99

1010
nt_branch:
11-
description: "Native Template branch to use (Default: master)"
12-
default: "master"
11+
description: "Native Template branch/tag to use (Leave empty to auto-select based on Mendix version)"
12+
default: ""
1313
required: false
1414
type: string
1515

@@ -59,6 +59,9 @@ on:
5959
- video-player-native
6060
- web-view-native
6161

62+
# Run at 0:00 UTC (2:00 AM CET time during summer, 1:00 AM during winter)
63+
schedule:
64+
- cron: '0 0 * * *'
6265
# Trigger on PR
6366
# pull_request:
6467

@@ -152,8 +155,78 @@ jobs:
152155
run: |
153156
echo "Mendix Version: ${{ steps.set-mendix-version.outputs.MENDIX_VERSION }}"
154157
158+
159+
determine-nt-version:
160+
needs: [mendix-version]
161+
runs-on: ubuntu-latest
162+
outputs:
163+
nt_branch: ${{ steps.determine-nt-branch.outputs.nt_branch }}
164+
steps:
165+
- name: "Check if nt_branch was specified"
166+
id: check-input
167+
run: |
168+
if [[ -n "${{ github.event.inputs.nt_branch }}" ]]; then
169+
echo "Using specified nt_branch: ${{ github.event.inputs.nt_branch }}"
170+
echo "nt_branch=${{ github.event.inputs.nt_branch }}" >> $GITHUB_OUTPUT
171+
echo "source=input" >> $GITHUB_OUTPUT
172+
else
173+
echo "No nt_branch specified, will determine from mendix_version"
174+
echo "source=auto" >> $GITHUB_OUTPUT
175+
fi
176+
177+
- name: "Download mendix_version.json from native-template repo"
178+
if: steps.check-input.outputs.source == 'auto'
179+
run: |
180+
curl -s -o mendix_version.json https://raw.githubusercontent.com/mendix/native-template/master/mendix_version.json
181+
cat mendix_version.json
182+
183+
- name: "Determine Native Template version based on Mendix version"
184+
if: steps.check-input.outputs.source == 'auto'
185+
id: determine-nt-branch
186+
run: |
187+
mendix_version="${{ needs.mendix-version.outputs.mendix_version }}"
188+
# Extract just the major.minor.patch part without any suffixes
189+
mendix_version_base=$(echo $mendix_version | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
190+
191+
echo "Mendix version: $mendix_version"
192+
echo "Mendix base version: $mendix_version_base"
193+
194+
# Use jq to find the appropriate NT version
195+
nt_version=$(jq -r --arg mv "$mendix_version_base" '
196+
# Define version comparison function first
197+
def version_to_int(v): v | split(".") | map(tonumber) | .[0]*1000000 + .[1]*1000 + .[2];
198+
199+
# Convert input Mendix version to comparable format
200+
($mv | version_to_int) as $mv_int |
201+
202+
# Find matching range
203+
to_entries |
204+
map(
205+
select(
206+
(.value.min_mendix_version | version_to_int) <= $mv_int and
207+
(if .value.max_mendix_version then (.value.max_mendix_version | version_to_int) >= $mv_int else true end)
208+
)
209+
) |
210+
211+
# Get the latest matching NT version
212+
sort_by(.key | split(".") | map(tonumber)) |
213+
last |
214+
if . then .key else "master" end
215+
' mendix_version.json)
216+
217+
echo "Selected Native Template version: $nt_version"
218+
echo "nt_branch=$nt_version" >> $GITHUB_OUTPUT
219+
220+
- name: "Set output nt_branch"
221+
id: set-output
222+
run: |
223+
if [[ "${{ steps.check-input.outputs.source }}" == "input" ]]; then
224+
echo "nt_branch=${{ steps.check-input.outputs.nt_branch }}" >> $GITHUB_OUTPUT
225+
else
226+
echo "nt_branch=${{ steps.determine-nt-branch.outputs.nt_branch }}" >> $GITHUB_OUTPUT
227+
fi
155228
docker-images:
156-
needs: mendix-version
229+
needs: [mendix-version]
157230
runs-on: ubuntu-22.04
158231
steps:
159232
- name: "Login to GitHub Container Registry"
@@ -311,14 +384,14 @@ jobs:
311384
platform: ios
312385
mda-file: automation.mda
313386
android-app:
314-
needs: [android-bundle]
387+
needs: [android-bundle, determine-nt-version]
315388
runs-on: ubuntu-22.04
316389
steps:
317390
- name: "Check out Native Template for Native Components Test Project"
318391
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
319392
with:
320393
repository: mendix/native-template
321-
ref: ${{ github.event.inputs.nt_branch || 'master' }}
394+
ref: ${{ needs.determine-nt-version.outputs.nt_branch }}
322395
path: native-template
323396
- name: "Check out code"
324397
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -377,14 +450,14 @@ jobs:
377450
name: android-app
378451
path: native-template/android/app/build/outputs/apk/**/*.apk
379452
ios-app:
380-
needs: [ios-bundle]
453+
needs: [ios-bundle, determine-nt-version]
381454
runs-on: macos-13
382455
steps:
383456
- name: "Check out Native Template for Native Components Test Project"
384457
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
385458
with:
386459
repository: mendix/native-template
387-
ref: ${{ github.event.inputs.nt_branch || 'master' }}
460+
ref: ${{ needs.determine-nt-version.outputs.nt_branch }}
388461
path: native-template
389462
- name: "Check out code"
390463
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

configs/e2e/mendix-versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"latest": "10.21.1.64969",
2+
"latest": "10.22.0.68245",
33
"8": "8.18.23.62193"
44
}

0 commit comments

Comments
 (0)