From c80611bf77daf5d802be2fc0caa7e6b24ce50a2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 24 Oct 2023 10:36:38 +0200
Subject: [PATCH] Advertise stable macOS Apple Silicon package

Also claim compatibility with macOS 14
---
 _includes/download-stable.html | 14 +++++++++-----
 setup-download-links.sh        | 14 ++++++--------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/_includes/download-stable.html b/_includes/download-stable.html
index 9f6b74b..ef5e5b8 100644
--- a/_includes/download-stable.html
+++ b/_includes/download-stable.html
@@ -42,15 +42,19 @@
 
   <section class="dynare_section" id="stable_content2">
     <p>
-      Compatible with macOS 13 “Ventura” (Intel x86-64 / Apple Silicon via
-      Rosetta 2) and MATLAB (R2014a–R2023b). <b>NB</b>: This package is
-      unsigned; to run it, you need to right click on it and select “Open” from
-      the menu that pops up.
-      If you want to use Dynare with Octave, do not download this package,
+      Compatible with macOS 14 “Sonoma” (Intel x86-64 / Apple Silicon) and
+      MATLAB (R2014a–R2023b). <b>NB</b>: This package is unsigned; to run it,
+      you need to right click on it and select “Open” from the menu that pops
+      up. If you want to use Dynare with Octave, do not download this package,
       but rather use the one from Homebrew (see
       the <a href="/resources/quick_start">quick start guide</a> for
       instructions).
     </p>
+    <p>Available as Apple Silicon (arm64) or Intel (x86-64) pkg installers.</p>
+    <p class="stable">
+      <i class="fas fa-file-download"></i>
+      {% include release/download-release-macos-arm64.html %}
+    </p>
     <p class="stable">
       <i class="fas fa-file-download"></i>
       {% include release/download-release-macos-x86_64.html %}
diff --git a/setup-download-links.sh b/setup-download-links.sh
index d53575c..286aee3 100755
--- a/setup-download-links.sh
+++ b/setup-download-links.sh
@@ -9,12 +9,6 @@ for branch in release snapshot; do
     cd "$branch"
 
     for dir in macos-x86_64 macos-arm64 source windows windows-7z windows-zip; do
-
-        # FIXME: remove this when publishing 5.5 with arm64
-        if [[ $branch == release ]] && [[ $dir == macos-arm64 ]]; then
-            continue
-        fi
-
         wget --no-verbose "https://www.dynare.org/$branch/$dir.json"
         readarray -t filenames < <(jq .[].filename "$dir.json")
         readarray -t timestamps < <(jq .[].date "$dir.json")
@@ -28,10 +22,14 @@ for branch in release snapshot; do
             mb=$((size[i] / (10 ** 6)))
             if [[ $branch == release ]]; then
                 readarray -t -d - split <<< "$filename"
-                if [[ $dir == windows* ]] || [[ $dir == macos* ]]; then
+                if [[ $dir == windows* ]]; then
                     version=${split[1]}
                     ext=${filename##*.}
-                else
+                elif [[ $dir == macos* ]]; then
+                    version=${split[1]}
+                    ext=${split[2]%%.*} # For macOS, we use the architecture as the extension (arm64 vs x86_64)
+                    ext=${ext/_/-} # Transform x86_64 into x86-64
+                else # Source
                     [[ ${split[1]} =~ ([0-9\.]+)\.([^[:space:]]+) ]]
                     version=${BASH_REMATCH[1]}
                     ext=${BASH_REMATCH[2]}
-- 
GitLab