Skip to content

Commit 15202b9

Browse files
committed
arm 64 for macOS
1 parent f491bb1 commit 15202b9

File tree

8 files changed

+157
-92
lines changed

8 files changed

+157
-92
lines changed

.github/workflows/cd.yml

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
name: artifacts
3838
path: artifacts
3939

40-
build-release:
40+
build-release-artifacts:
4141
name: build-release
4242
needs: [create-github-release]
4343
runs-on: ${{ matrix.job.os }}
@@ -48,15 +48,16 @@ jobs:
4848
matrix:
4949
rust: [stable]
5050
job:
51-
- { os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" }
52-
- { os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" }
53-
- { os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux", }
51+
- { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true }
52+
- { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" }
53+
- { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" }
54+
- { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux", }
5455
# seems impossible to build static musl binaries due to XCB dependency. See https://github.com/rust-lang/rust/issues/116348
55-
# - { os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", }
56-
- { os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin jwtui" }
57-
- { os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin jwtui" }
58-
- { os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "arm-gnu", use-cross: true, test-bin: "--bin jwtui" }
59-
- { os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "arm-musl", use-cross: true, test-bin: "--bin jwtui" }
56+
# { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", }
57+
- { name: "aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin jwtui" }
58+
- { name: "aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin jwtui" }
59+
- { name: "arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "arm-gnu", use-cross: true, test-bin: "--bin jwtui" }
60+
- { name: "arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "arm-musl", use-cross: true, test-bin: "--bin jwtui" }
6061

6162
steps:
6263
- name: Checkout repository
@@ -111,7 +112,13 @@ jobs:
111112
args: --release --verbose --target=${{ matrix.job.target }}
112113
toolchain: ${{ matrix.rust }}
113114

115+
- name: Verify file
116+
shell: bash
117+
run: |
118+
file target/${{ matrix.job.target }}/release/jwtui
119+
114120
- name: Test
121+
if: matrix.job.target != 'aarch64-apple-darwin'
115122
uses: actions-rs/cargo@v1
116123
with:
117124
use-cross: ${{ matrix.job.use-cross }}
@@ -171,8 +178,8 @@ jobs:
171178
name: artifacts
172179
path: artifacts
173180

174-
publish-package-formula:
175-
needs: [build-release]
181+
publish-homebrew-formula:
182+
needs: [build-release-artifacts]
176183
name: Update homebrew & scoop formulas
177184
runs-on: ubuntu-latest
178185
steps:
@@ -192,24 +199,24 @@ jobs:
192199
run: |
193200
macos_sha="$(cat ./artifacts/jwtui-macos.sha256 | awk '{print $1}')"
194201
echo "MACOS_SHA=$macos_sha" >> $GITHUB_ENV
202+
macos_sha_arm="$(cat ./artifacts/jwtui-macos-arm64.sha256 | awk '{print $1}')"
203+
echo "MACOS_SHA_ARM=$macos_sha_arm" >> $GITHUB_ENV
195204
linux_sha="$(cat ./artifacts/jwtui-linux.sha256 | awk '{print $1}')"
196205
echo "LINUX_SHA=$linux_sha" >> $GITHUB_ENV
197-
windows_sha="$(cat ./artifacts/jwtui-windows.sha256 | awk '{print $1}')"
198-
echo "WINDOWS_SHA=$windows_sha" >> $GITHUB_ENV
199206
release_version="$(cat ./artifacts/release-version)"
200207
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
201208
202209
- name: Validate release environment variables
203210
run: |
204211
echo "Release SHA macos: ${{ env.MACOS_SHA }}"
212+
echo "Release SHA macos-arm: ${{ env.MACOS_SHA_ARM }}"
205213
echo "Release SHA linux: ${{ env.LINUX_SHA }}"
206-
echo "Release SHA windows: ${{ env.WINDOWS_SHA }}"
207214
echo "Release version: ${{ env.RELEASE_VERSION }}"
208215
209216
- name: Execute Homebrew packaging script
210217
run: |
211218
# run packaging script
212-
python "./deployment/homebrew/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/homebrew/jwt-ui.rb.template" "./jwt-ui.rb" ${{ env.MACOS_SHA }} ${{ env.LINUX_SHA }}
219+
python "./deployment/homebrew/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/homebrew/jwt-ui.rb.template" "./jwt-ui.rb" ${{ env.MACOS_SHA }} ${{ env.MACOS_SHA_ARM }} ${{ env.LINUX_SHA }}
213220
214221
# push to Git
215222
git config --global user.email "[email protected]"
@@ -222,6 +229,35 @@ jobs:
222229
git diff-index --quiet HEAD || git commit -am "Update formula for jwt-ui release ${{ env.RELEASE_VERSION }}"
223230
git push origin main
224231
232+
publish-scoop-formula:
233+
needs: [build-release-artifacts]
234+
name: Update scoop formulas
235+
runs-on: ubuntu-latest
236+
steps:
237+
- name: Checkout repository
238+
uses: actions/checkout@v2
239+
with:
240+
fetch-depth: 1
241+
242+
- name: Get release artifacts
243+
uses: actions/download-artifact@v2
244+
with:
245+
name: artifacts
246+
path: artifacts
247+
248+
- name: Set release assets and version
249+
shell: bash
250+
run: |
251+
windows_sha="$(cat ./artifacts/jwtui-windows.sha256 | awk '{print $1}')"
252+
echo "WINDOWS_SHA=$windows_sha" >> $GITHUB_ENV
253+
release_version="$(cat ./artifacts/release-version)"
254+
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
255+
256+
- name: Validate release environment variables
257+
run: |
258+
echo "Release SHA windows: ${{ env.WINDOWS_SHA }}"
259+
echo "Release version: ${{ env.RELEASE_VERSION }}"
260+
225261
- name: Execute Scoop packaging script
226262
run: |
227263
# run packaging script
@@ -239,6 +275,7 @@ jobs:
239275
git push origin main
240276
241277
publish-cargo:
278+
needs: [build-release-artifacts]
242279
name: Publishing to Cargo
243280
runs-on: ubuntu-latest
244281
steps:
@@ -257,7 +294,7 @@ jobs:
257294
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
258295

259296
publish-docker-image:
260-
needs: [build-release]
297+
needs: [build-release-artifacts]
261298
name: Publishing Docker image to Docker Hub
262299
runs-on: ubuntu-latest
263300
steps:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased - 2023-XX-YY
44

5+
## [1.0.5] - 2024-01-18
6+
7+
- macOS arm64 support
8+
59
## [1.0.4] - 2024-01-15
610

711
- Improved error handling

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jwt-ui"
3-
version = "1.0.4"
3+
version = "1.0.5"
44
authors = ["Deepu K Sasidharan <[email protected]>"]
55
description = """
66
A Terminal UI for decoding/encoding JSON Web Tokens

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ If you are looking for a non TUI CLI, check out [jwt-cli](https://github.com/mik
175175
## Limitations/Known issues
176176

177177
- Copy to clipboard is not supported on `aarch64` and `arm` machines.
178+
- [macOS] KDash looks better on iTerm2 since macOS's default Terminal app makes the colors render weird.
179+
- [Windows] KDash looks better on CMD since Powershell's default theme makes the colors look weird.
178180

179181
## Libraries used
180182

deployment/getLatest.sh

Lines changed: 88 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,104 +13,121 @@ EXE_FILENAME="jwtui"
1313
EXE_DEST_DIR="/usr/local/bin"
1414

1515
bye() {
16-
result=$?
17-
if [ "$result" != "0" ]; then
18-
echo "Fail to install ${GITHUB_USER}/${GITHUB_REPO}"
19-
fi
20-
exit $result
16+
result=$?
17+
if [ "$result" != "0" ]; then
18+
echo "Fail to install ${GITHUB_USER}/${GITHUB_REPO}"
19+
fi
20+
exit $result
2121
}
2222

2323
fail() {
24-
echo "$1"
25-
exit 1
24+
echo "$1"
25+
exit 1
2626
}
2727

2828
find_download_url() {
29-
local SUFFIX=$1
30-
local LATEST_URL="https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/releases/latest"
31-
local URL=$(curl -s "${LATEST_URL}" | grep "browser_download_url.*${SUFFIX}" | cut -d : -f 2,3 |
32-
tr -d \" |
33-
head -n 1)
34-
echo "${URL//[[:space:]]/}"
29+
local SUFFIX=$1
30+
local LATEST_URL="https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/releases/latest"
31+
local URL=$(curl -s "${LATEST_URL}" | grep "browser_download_url.*${SUFFIX}" | cut -d : -f 2,3 | tr -d \" | head -n 1)
32+
echo "${URL//[[:space:]]/}"
3533
}
3634

3735
find_arch() {
38-
local ARCH=$(uname -m)
39-
case $ARCH in
40-
armv5*) ARCH="armv5" ;;
41-
armv6*) ARCH="armv6" ;;
42-
armv7*) ARCH="armv7" ;;
43-
aarch64) ARCH="arm64" ;;
44-
x86) ARCH="386" ;;
45-
# x86_64) ARCH="amd64";;
46-
i686) ARCH="386" ;;
47-
i386) ARCH="386" ;;
48-
esac
49-
echo $ARCH
36+
local ARCH=$(uname -m)
37+
38+
case $ARCH in
39+
armv*) ARCH="arm" ;;
40+
arm64) ARCH="arm64" ;;
41+
aarch64) ARCH="aarch64" ;;
42+
x86_64) ARCH="amd64" ;;
43+
*) fail "Your system architecture is not supported: $ARCH" ;;
44+
esac
45+
46+
echo $ARCH
5047
}
5148

5249
find_os() {
53-
local OS=$(echo $(uname) | tr '[:upper:]' '[:lower:]')
54-
55-
case "$OS" in
56-
# Minimalist GNU for Windows
57-
mingw*) OS='windows' ;;
58-
msys*) OS='windows' ;;
59-
esac
60-
echo $OS
50+
local OS=$(echo $(uname) | tr '[:upper:]' '[:lower:]')
51+
52+
case "$OS" in
53+
# Minimalist GNU for Windows
54+
mingw*) OS='windows' ;;
55+
msys*) OS='windows' ;;
56+
esac
57+
58+
echo $OS
6159
}
6260

6361
find_suffix() {
64-
local OS=$2
65-
local SUFFIX="$OS.tar.gz"
66-
echo $SUFFIX
62+
local ARCH=$1
63+
local OS=$2
64+
local SUFFIX="$OS.tar.gz"
65+
66+
case "$OS" in
67+
"darwin")
68+
case "$ARCH" in
69+
"arm64") SUFFIX="macos-arm64.tar.gz" ;;
70+
*) SUFFIX='macos.tar.gz' ;;
71+
esac
72+
;;
73+
"windows") SUFFIX='windows.tar.gz' ;;
74+
*)
75+
case "$ARCH" in
76+
"arm") SUFFIX="arm-gnu.tar.gz" ;;
77+
"aarch64") SUFFIX="aarch64-gnu.tar.gz" ;;
78+
*) SUFFIX='linux.tar.gz' ;;
79+
esac
80+
;;
81+
esac
82+
83+
echo $SUFFIX
6784
}
6885

6986
download_file() {
70-
local FILE_URL="$1"
71-
local FILE_PATH="$2"
72-
echo "Getting $FILE_URL ....."
73-
httpStatusCode=$(curl -s -w '%{http_code}' -L "$FILE_URL" -o "$FILE_PATH")
74-
if [ "$httpStatusCode" != 200 ]; then
75-
echo "failed to download '${URL}'"
76-
fail "Request fail with http status code $httpStatusCode"
77-
fi
87+
local FILE_URL="$1"
88+
local FILE_PATH="$2"
89+
echo "Getting $FILE_URL ....."
90+
httpStatusCode=$(curl -s -w '%{http_code}' -L "$FILE_URL" -o "$FILE_PATH")
91+
if [ "$httpStatusCode" != 200 ]; then
92+
echo "failed to download '${URL}'"
93+
fail "Request fail with http status code $httpStatusCode"
94+
fi
7895
}
7996

8097
find_exec_dest_path() {
81-
if [ ! -w $EXE_DEST_DIR ]; then
82-
echo "Cannot write to ${EXE_DEST_DIR}. Run with 'sudo' to install to ${EXE_DEST_DIR}. Installing to current directory now ....."
83-
EXE_DEST_DIR=$(pwd)
84-
fi
98+
if [ ! -w $EXE_DEST_DIR ]; then
99+
echo "Cannot write to ${EXE_DEST_DIR}. Run with 'sudo' to install to ${EXE_DEST_DIR}. Installing to current directory now ....."
100+
EXE_DEST_DIR=$(pwd)
101+
fi
85102
}
86103

87104
install_file() {
88-
local FILE_PATH=$1
89-
local EXE_DEST_FILE=$2
90-
TMP_DIR="/tmp/${GITHUB_USER}_${GITHUB_REPO}"
91-
mkdir -p "$TMP_DIR" || true
92-
tar xf "$FILE_PATH" -C "$TMP_DIR"
93-
cp "$TMP_DIR/${EXE_FILENAME}" "${EXE_DEST_FILE}"
94-
chmod +x "${EXE_DEST_FILE}"
95-
rm -rf "$TMP_DIR"
105+
local FILE_PATH=$1
106+
local EXE_DEST_FILE=$2
107+
TMP_DIR="/tmp/${GITHUB_USER}_${GITHUB_REPO}"
108+
mkdir -p "$TMP_DIR" || true
109+
tar xf "$FILE_PATH" -C "$TMP_DIR"
110+
cp "$TMP_DIR/${EXE_FILENAME}" "${EXE_DEST_FILE}"
111+
chmod +x "${EXE_DEST_FILE}"
112+
rm -rf "$TMP_DIR"
96113
}
97114

98115
main() {
99-
find_exec_dest_path
100-
local EXE_DEST_FILE="${EXE_DEST_DIR}/${EXE_FILENAME}"
101-
local ARCH=$(find_arch)
102-
local OS=$(find_os)
103-
local SUFFIX=$(find_suffix $ARCH $OS)
104-
local FILE_URL=$(find_download_url $SUFFIX)
105-
if [ -z "${FILE_URL}" ]; then
106-
fail "Did not find a latest release for your system: $OS $ARCH ($SUFFIX)"
107-
fi
108-
local FILE_PATH="/tmp/${GITHUB_USER}-${GITHUB_REPO}-latest-${SUFFIX}"
109-
download_file "${FILE_URL}" "${FILE_PATH}"
110-
install_file "${FILE_PATH}" "${EXE_DEST_FILE}"
111-
rm -Rf ${FILE_PATH}
112-
echo "executable installed at ${EXE_DEST_FILE}"
113-
bye
116+
find_exec_dest_path
117+
local EXE_DEST_FILE="${EXE_DEST_DIR}/${EXE_FILENAME}"
118+
local ARCH=$(find_arch)
119+
local OS=$(find_os)
120+
local SUFFIX=$(find_suffix $ARCH $OS)
121+
local FILE_URL=$(find_download_url $SUFFIX)
122+
if [ -z "${FILE_URL}" ]; then
123+
fail "Did not find a latest release for your system: $OS $ARCH ($SUFFIX)"
124+
fi
125+
local FILE_PATH="/tmp/${GITHUB_USER}-${GITHUB_REPO}-latest-${SUFFIX}"
126+
download_file "${FILE_URL}" "${FILE_PATH}"
127+
install_file "${FILE_PATH}" "${EXE_DEST_FILE}"
128+
rm -Rf ${FILE_PATH}
129+
echo "executable installed at ${EXE_DEST_FILE}"
130+
bye
114131
}
115132

116133
#TODO check bash is used `readlink /proc/$$/exe`

deployment/homebrew/jwt-ui.rb.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
class JwtUi < Formula
55
desc "A Terminal UI for decoding/encoding JSON Web Tokens"
66
homepage "https://github.com/jwt-rs/jwt-ui"
7-
if OS.mac?
7+
if OS.mac? and Hardware::CPU.arm?
8+
url "https://github.com/jwt-rs/jwt-ui/releases/download/$version/jwtui-macos-arm64.tar.gz"
9+
sha256 "$hash_mac_arm"
10+
elsif OS.mac? and Hardware::CPU.intel?
811
url "https://github.com/jwt-rs/jwt-ui/releases/download/$version/jwtui-macos.tar.gz"
912
sha256 "$hash_mac"
1013
else

0 commit comments

Comments
 (0)