diff --git a/.github/bin/cross-compile b/.github/bin/cross-compile index b1c12a4d..67e316ba 100755 --- a/.github/bin/cross-compile +++ b/.github/bin/cross-compile @@ -42,14 +42,30 @@ cross_compile() { fi nimble --verbose build "${build_options[@]}" + local binary_name='configlet' if command -v llvm-strip &> /dev/null; then echo "stripping large comment section from executable..." >&2 llvm-strip -R .comment "${binary_name}" fi + if command -v file &> /dev/null; then + file "${binary_name}" + fi + if command -v llvm-readobj &> /dev/null; then + llvm-readobj "${binary_name}" + fi + mkdir -p "${archives_dir}" - local archive="${archives_dir}/${binary_name}_${build_tag}_${os}_${arch}.tar.gz" - tar -cvzf "${archive}" "${binary_name}" + local archive_base="${archives_dir}/${binary_name}_${build_tag}_${os}_${arch}" + case "${os}" in + linux | macos) + tar -cvzf "${archive_base}.tar.gz" "${binary_name}" + ;; + windows) + mv "${binary_name}" "${binary_name}".exe + 7z a "${archive_base}.zip" "${binary_name}.exe" + ;; + esac } main() { diff --git a/.github/bin/install-zig b/.github/bin/install-zig index 4b1247c0..0708f4fd 100755 --- a/.github/bin/install-zig +++ b/.github/bin/install-zig @@ -44,16 +44,16 @@ case "${os}" in archive_sha256='1c1c6b9a906b42baae73656e24e108fd8444bb50b6e8fd03e9e7a3f8b5f05686' shasum -a 256 -c <<< "${archive_sha256} *${archive}" ;; - *) - echo "${os} not yet supported" >&2 - exit 1 + windows) + archive_sha256='142caa3b804d86b4752556c9b6b039b7517a08afa3af842645c7e2dcd125f652' + # TODO: check windows archive checksum ;; esac # Extract the archive, then remove it. echo "Extracting archive..." >&2 case "${ext}" in - *zip) unzip "${archive}" ;; + *zip) unzip -q "${archive}" ;; *) tar xJf "${archive}" ;; esac rm "${archive}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c063d55..827737a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,6 +87,9 @@ jobs: - runs-on: macos-12 zig_target: aarch64-macos-none + - runs-on: ubuntu-22.04 + zig_target: aarch64-windows-gnu + name: "${{ matrix.zig_target }}" runs-on: ${{ matrix.runs-on }} permissions: @@ -103,9 +106,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install Zig + shell: bash run: ./.github/bin/install-zig - name: Cross-compile + shell: bash run: ./.github/bin/cross-compile env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/cli.nim b/src/cli.nim index c6859051..32b287d5 100644 --- a/src/cli.nim +++ b/src/cli.nim @@ -116,8 +116,7 @@ func genShortKeys: array[Opt, char] = result[opt] = ($opt)[0] const - repoRootDir = currentSourcePath().parentDir().parentDir() - configletVersion = staticRead(repoRootDir / "configlet.version").strip() + configletVersion = staticRead("../configlet.version").strip() short = genShortKeys() optsNoVal = {optHelp, optVersion, optFmtSyncUpdate, optFmtSyncYes, optInfoSyncOffline, optSyncDocs, optSyncFilepaths, optSyncMetadata} diff --git a/src/completion/completion.nim b/src/completion/completion.nim index a322786e..fe5a7851 100644 --- a/src/completion/completion.nim +++ b/src/completion/completion.nim @@ -6,7 +6,13 @@ proc readCompletions: array[Shell, string] = const repoRootDir = currentSourcePath().parentDir().parentDir().parentDir() const completionsDir = repoRootDir / "completions" for shell in sBash .. result.high: - result[shell] = staticRead(completionsDir / &"configlet.{shell}").compress() + # When cross-compiling for Windows from Linux, replace the `\\` DirSep with `/`. + var path = completionsDir / &"configlet.{shell}" + when defined(windows) and defined(zig) and staticExec("uname") == "Linux": + for c in path.mitems: + if c == '\\': + c = '/' + result[shell] = staticRead(path).compress() proc completion*(shellKind: Shell) = const completions = readCompletions()