From 2815cc4efea63e27ae94335cf650d0a878e8556e Mon Sep 17 00:00:00 2001
From: Stephan Boyer <stephan@stephanboyer.com>
Date: Sun, 18 Jun 2023 05:22:27 -0700
Subject: [PATCH] Add support for Windows on AArch64

---
 .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++------------
 CHANGELOG.md             |  9 ++++--
 Cargo.lock               |  2 +-
 Cargo.toml               |  2 +-
 README.md                |  4 +--
 toast.yml                |  2 +-
 6 files changed, 54 insertions(+), 24 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5b7f8d1..ed79c34 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,7 +8,7 @@ jobs:
     name: Build for Linux
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - if: ${{ github.event_name == 'push' }}
       uses: azure/docker-login@v1
       with:
@@ -25,7 +25,7 @@ jobs:
 
         # The artifact name will contain the target triple, so the file name doesn't need to.
         mv artifacts/tagref-x86_64-unknown-linux-gnu artifacts/tagref
-    - uses: actions/upload-artifact@v2
+    - uses: actions/upload-artifact@v3
       with:
         name: x86_64-unknown-linux-gnu
         path: artifacts/tagref
@@ -36,7 +36,7 @@ jobs:
 
         # The artifact name will contain the target triple, so the file name doesn't need to.
         mv artifacts/tagref-x86_64-unknown-linux-musl artifacts/tagref
-    - uses: actions/upload-artifact@v2
+    - uses: actions/upload-artifact@v3
       with:
         name: x86_64-unknown-linux-musl
         path: artifacts/tagref
@@ -47,7 +47,7 @@ jobs:
 
         # The artifact name will contain the target triple, so the file name doesn't need to.
         mv artifacts/tagref-aarch64-unknown-linux-gnu artifacts/tagref
-    - uses: actions/upload-artifact@v2
+    - uses: actions/upload-artifact@v3
       with:
         name: aarch64-unknown-linux-gnu
         path: artifacts/tagref
@@ -58,7 +58,7 @@ jobs:
 
         # The artifact name will contain the target triple, so the file name doesn't need to.
         mv artifacts/tagref-aarch64-unknown-linux-musl artifacts/tagref
-    - uses: actions/upload-artifact@v2
+    - uses: actions/upload-artifact@v3
       with:
         name: aarch64-unknown-linux-musl
         path: artifacts/tagref
@@ -67,7 +67,7 @@ jobs:
     name: Build for Windows
     runs-on: windows-latest
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - run: |
         # Make Bash not silently ignore errors.
         set -euo pipefail
@@ -76,22 +76,38 @@ jobs:
         rustup toolchain install 1.65.0 # [ref:rust_1.65.0]
         rustup default 1.65.0 # [ref:rust_1.65.0]
 
-        # Build and test.
+        # Add the targets.
+        rustup target add x86_64-pc-windows-msvc
+        rustup target add aarch64-pc-windows-msvc
+
+        # Build and test for x86_64-pc-windows-msvc.
         RUSTFLAGS='--codegen target-feature=+crt-static' cargo build \
           --locked \
           --release \
           --target x86_64-pc-windows-msvc
         NO_COLOR=true cargo test --locked # [ref:colorless_tests]
-    - uses: actions/upload-artifact@v2
+
+        # Build and test for aarch64-pc-windows-msvc.
+        RUSTFLAGS='--codegen target-feature=+crt-static' cargo build \
+          --locked \
+          --release \
+          --target aarch64-pc-windows-msvc
+        NO_COLOR=true cargo test --locked # [ref:colorless_tests]
+    - uses: actions/upload-artifact@v3
       with:
         name: x86_64-pc-windows-msvc
         path: target/x86_64-pc-windows-msvc/release/tagref.exe
         if-no-files-found: error
+    - uses: actions/upload-artifact@v3
+      with:
+        name: aarch64-pc-windows-msvc
+        path: target/aarch64-pc-windows-msvc/release/tagref.exe
+        if-no-files-found: error
   ci-macos:
     name: Build for macOS
     runs-on: macos-latest
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - run: |
         # Make Bash not silently ignore errors.
         set -euo pipefail
@@ -100,22 +116,27 @@ jobs:
         rustup toolchain install 1.65.0 # [ref:rust_1.65.0]
         rustup default 1.65.0 # [ref:rust_1.65.0]
 
+        # Add the targets.
+        rustup target add x86_64-apple-darwin
+        rustup target add aarch64-apple-darwin
+
         # Build and test for x86_64-apple-darwin.
-        cargo build --locked --release --target x86_64-apple-darwin
+        SDKROOT=$(xcrun --show-sdk-path) \
+          MACOSX_DEPLOYMENT_TARGET=$(xcrun --show-sdk-version) \
+            cargo build --locked --release --target x86_64-apple-darwin
         NO_COLOR=true cargo test --locked # [ref:colorless_tests]
 
         # Build and test for aarch64-apple-darwin.
-        rustup target add aarch64-apple-darwin
         SDKROOT=$(xcrun --show-sdk-path) \
           MACOSX_DEPLOYMENT_TARGET=$(xcrun --show-sdk-version) \
             cargo build --locked --release --target aarch64-apple-darwin
         NO_COLOR=true cargo test --locked # [ref:colorless_tests]
-    - uses: actions/upload-artifact@v2
+    - uses: actions/upload-artifact@v3
       with:
         name: x86_64-apple-darwin
         path: target/x86_64-apple-darwin/release/tagref
         if-no-files-found: error
-    - uses: actions/upload-artifact@v2
+    - uses: actions/upload-artifact@v3
       with:
         name: aarch64-apple-darwin
         path: target/aarch64-apple-darwin/release/tagref
@@ -124,7 +145,7 @@ jobs:
     name: Install on macOS
     runs-on: macos-latest
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - run: |
         # Make Bash not silently ignore errors.
         set -euo pipefail
@@ -138,7 +159,7 @@ jobs:
     name: Install on Ubuntu
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
     - run: |
         # Make Bash not silently ignore errors.
         set -euo pipefail
@@ -154,8 +175,8 @@ jobs:
     runs-on: ubuntu-latest
     needs: [ci-linux, ci-macos, ci-windows, install-macos, install-ubuntu]
     steps:
-    - uses: actions/checkout@v2
-    - uses: actions/download-artifact@v2
+    - uses: actions/checkout@v3
+    - uses: actions/download-artifact@v3
       with:
         path: artifacts/
     - env:
@@ -199,6 +220,9 @@ jobs:
         mv \
           artifacts/x86_64-pc-windows-msvc/tagref.exe \
           artifacts/tagref-x86_64-pc-windows-msvc.exe
+        mv \
+          artifacts/aarch64-pc-windows-msvc/tagref.exe \
+          artifacts/tagref-aarch64-pc-windows-msvc.exe
 
         # Create the release.
         hub release create \
@@ -211,6 +235,7 @@ jobs:
           --attach 'artifacts/tagref-x86_64-apple-darwin' \
           --attach 'artifacts/tagref-aarch64-apple-darwin' \
           --attach 'artifacts/tagref-x86_64-pc-windows-msvc.exe' \
+          --attach 'artifacts/tagref-aarch64-pc-windows-msvc.exe' \
           "v$VERSION"
         echo "Created release v$VERSION."
     - uses: stepchowfun/toast/.github/actions/toast@main
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aedb2a4..b0603e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,15 +5,20 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [1.8.4] - 2023-06-18
+
+### Added
+- Tagref supports a new platform: Windows on AArch64.
+
 ## [1.8.3] - 2023-06-02
 
 ### Added
-- Tagref supports a new platform: AArch64 musl Linux.
+- Tagref supports a new platform: musl Linux on AArch64.
 
 ## [1.8.2] - 2023-05-22
 
 ### Added
-- Tagref supports a new platform: AArch64 GNU Linux.
+- Tagref supports a new platform: GNU Linux on AArch64.
 
 ## [1.8.1] - 2023-05-11
 
diff --git a/Cargo.lock b/Cargo.lock
index 63b8eba..3bfef3d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -209,7 +209,7 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
 
 [[package]]
 name = "tagref"
-version = "1.8.3"
+version = "1.8.4"
 dependencies = [
  "atty",
  "clap",
diff --git a/Cargo.toml b/Cargo.toml
index 2b3e0d2..eda3e3a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "tagref"
-version = "1.8.3"
+version = "1.8.4"
 authors = ["Stephan Boyer <stephan@stephanboyer.com>"]
 edition = "2021"
 description = "Tagref helps you maintain cross-references in your code."
diff --git a/README.md b/README.md
index 86c182c..1d03c3e 100644
--- a/README.md
+++ b/README.md
@@ -116,9 +116,9 @@ curl https://raw.githubusercontent.com/stepchowfun/tagref/main/install.sh -LSfs
 
 If you prefer not to use this installation method, you can download the binary from the [releases page](https://github.com/stepchowfun/tagref/releases), make it executable (e.g., with `chmod`), and place it in some directory in your [`PATH`](https://en.wikipedia.org/wiki/PATH_\(variable\)) (e.g., `/usr/local/bin`).
 
-### Installation on Windows (x86-64)
+### Installation on Windows (AArch64 or x86-64)
 
-If you're running Windows on an x86-64 CPU, download the latest binary from the [releases page](https://github.com/stepchowfun/tagref/releases) and rename it to `tagref` (or `tagref.exe` if you have file extensions visible). Create a directory called `Tagref` in your `%PROGRAMFILES%` directory (e.g., `C:\Program Files\Tagref`), and place the renamed binary in there. Then, in the "Advanced" tab of the "System Properties" section of Control Panel, click on "Environment Variables..." and add the full path to the new `Tagref` directory to the `PATH` variable under "System variables". Note that the `Program Files` directory might have a different name if Windows is configured for a language other than English.
+If you're running Windows (AArch64 or x86-64), download the latest binary from the [releases page](https://github.com/stepchowfun/tagref/releases) and rename it to `tagref` (or `tagref.exe` if you have file extensions visible). Create a directory called `Tagref` in your `%PROGRAMFILES%` directory (e.g., `C:\Program Files\Tagref`), and place the renamed binary in there. Then, in the "Advanced" tab of the "System Properties" section of Control Panel, click on "Environment Variables..." and add the full path to the new `Tagref` directory to the `PATH` variable under "System variables". Note that the `Program Files` directory might have a different name if Windows is configured for a language other than English.
 
 To update to an existing installation, simply replace the existing binary.
 
diff --git a/toast.yml b/toast.yml
index 09f9656..f2e50fb 100644
--- a/toast.yml
+++ b/toast.yml
@@ -200,7 +200,7 @@ tasks:
     output_paths:
       - artifacts
     command: |
-      # Add the targets. It's likely that this script is currently running in one of them.
+      # Add the targets.
       rustup target add x86_64-unknown-linux-gnu
       rustup target add x86_64-unknown-linux-musl
       rustup target add aarch64-unknown-linux-gnu