Skip to content

Commit fcfade4

Browse files
authored
Merge pull request #1095 from zyf722/actions-windows
feat(action): Add Windows support to actions
2 parents 853bbe8 + 264f549 commit fcfade4

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

.github/workflows/test-action.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ jobs:
66
name: Spell Check with Typos
77
strategy:
88
matrix:
9-
os: [ubuntu-latest, macos-latest]
9+
os: [ubuntu-latest, macos-latest, windows-latest]
1010
runs-on: ${{ matrix.os }}
1111
steps:
1212
- name: Checkout Actions Repository
1313
uses: actions/checkout@v4
1414

15+
- name: Install wget for Windows
16+
if: matrix.os == 'windows-latest'
17+
run: choco install wget --no-progress
18+
1519
- name: Prepare file with mistakes.
1620
run: echo "Finallizes" > file.txt
1721
- name: Test force pass with mistakes
@@ -31,14 +35,18 @@ jobs:
3135
name: Spell Check with Type w/History
3236
strategy:
3337
matrix:
34-
os: [ubuntu-latest, macos-latest]
38+
os: [ubuntu-latest, macos-latest, windows-latest]
3539
runs-on: ${{ matrix.os }}
3640
steps:
3741
- name: Checkout Actions Repository
3842
uses: actions/checkout@v4
3943
with:
4044
fetch-depth: 0
4145

46+
- name: Install wget for Windows
47+
if: matrix.os == 'windows-latest'
48+
run: choco install wget --no-progress
49+
4250
- name: Prepare file with mistakes.
4351
run: echo "Finallizes" > file.txt
4452
- name: Test force pass with mistakes

action/entrypoint.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,26 @@ if [[ ! -x ${COMMAND} ]]; then
2727
else
2828
ARCH="x86_64"
2929
fi
30-
if [[ "$(uname -s)" == "Darwin" ]]; then
30+
UNAME=$(uname -s)
31+
if [[ "$UNAME" == "Darwin" ]]; then
3132
TARGET_FILE="${ARCH}-apple-darwin"
33+
FILE_EXT="tar.gz"
34+
elif [[ "$UNAME" == CYGWIN* || "$UNAME" == MINGW* || "$UNAME" == MSYS* ]] ; then
35+
TARGET_FILE="${ARCH}-pc-windows-msvc"
36+
FILE_EXT="zip"
3237
else
3338
TARGET_FILE="${ARCH}-unknown-linux-musl"
39+
FILE_EXT="tar.gz"
3440
fi
35-
FILE_NAME="typos-v${VERSION}-${TARGET_FILE}.tar.gz"
41+
FILE_NAME="typos-v${VERSION}-${TARGET_FILE}.${FILE_EXT}"
3642
log "Downloading 'typos' v${VERSION}"
3743
wget --progress=dot:mega "https://github.com/crate-ci/typos/releases/download/v${VERSION}/${FILE_NAME}"
3844
mkdir -p ${_INSTALL_DIR}
39-
tar -xzvf "${FILE_NAME}" -C ${_INSTALL_DIR} ./${CMD_NAME}
45+
if [[ "$FILE_EXT" == "zip" ]]; then
46+
unzip -o "${FILE_NAME}" -d ${_INSTALL_DIR} ${CMD_NAME}.exe
47+
else
48+
tar -xzvf "${FILE_NAME}" -C ${_INSTALL_DIR} ./${CMD_NAME}
49+
fi
4050
rm "${FILE_NAME}"
4151
fi
4252
log "jq: $(jq --version)"

0 commit comments

Comments
 (0)