Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bicep Module Latest Version Display Ordering #1182

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/hugo-build-pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
buildpr:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.124.1
HUGO_VERSION: 0.128.2
steps:
- name: Install Hugo CLI
run: |
Expand Down Expand Up @@ -56,5 +56,6 @@ jobs:
hugo \
--gc \
--minify \
--ignoreCache \
--baseURL "${{ steps.pages.outputs.base_url }}/"
working-directory: ./docs
3 changes: 2 additions & 1 deletion .github/workflows/hugo-site-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.124.1
HUGO_VERSION: 0.128.2
steps:
- name: Install Hugo CLI
run: |
Expand Down Expand Up @@ -67,6 +67,7 @@ jobs:
hugo \
--gc \
--minify \
--ignoreCache \
--baseURL "${{ steps.pages.outputs.base_url }}/"
working-directory: ./docs

Expand Down
25 changes: 23 additions & 2 deletions docs/layouts/shortcodes/moduleNameStatusOwners.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,35 @@
</thead>
{{ end }}
{{ range $item, $maps }}
{{ if not ( in $exclude $item.ModuleStatus ) }}
{{ if not (in $exclude $item.ModuleStatus) }}
{{ $moduleLatestVersion = "N/A" }}
{{ if or (eq $item.ModuleStatus "Available :green_circle:") (eq $item.ModuleStatus "Orphaned :eyes:") }}
{{ $moduleMcrUrl := printf "https://mcr.microsoft.com/v2/bicep/%s/tags/list" $item.ModuleName }}
{{ $moduleMcrData := getJSON $moduleMcrUrl }}
{{ $moduleVersions := $moduleMcrData.tags }}
{{ if $moduleVersions }}
{{ $moduleLatestVersion = index $moduleVersions (sub (len $moduleVersions) 1) }}
{{/* Initialize $sortedVersions as an empty slice */}}
{{ $sortedVersions := slice }}
{{ range $moduleVersions }}
{{ $parts := split . "." }}
{{ $major := printf "%03d" (index $parts 0 | int) }}
{{ $minor := printf "%03d" (index $parts 1 | int) }}
{{ $patch := printf "%03d" (index $parts 2 | int) }}
{{ $sortableVersion := print $major $minor $patch }}
{{ $sortedVersions = $sortedVersions | append (dict "sortableVersion" $sortableVersion "originalVersion" .) }}
{{ end }}

{{/* Sort by the sortableVersion field */}}
{{ $sortedVersions = sort $sortedVersions "sortableVersion" }}

{{/* Extract the original versions in sorted order */}}
{{ $originalSortedVersions := slice }}
{{ range $sortedVersions }}
{{ $originalSortedVersions = $originalSortedVersions | append .originalVersion }}
{{ end }}

{{/* Set $moduleLatestVersion to the first element of $sortedSemVers, which is the latest version */}}
{{ $moduleLatestVersion = index $originalSortedVersions (sub (len $originalSortedVersions) 1) }}
{{ end }}
{{ end }}
{{ $trimmedModuleStatus := replace $item.ModuleStatus "Module " "" }}
Expand Down