feat(action): Add Windows support to actions

This commit is contained in:
zyf722 2024-09-04 13:38:08 +08:00
parent 853bbe8898
commit 264f549c13
2 changed files with 23 additions and 5 deletions

View file

@ -6,12 +6,16 @@ jobs:
name: Spell Check with Typos
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Install wget for Windows
if: matrix.os == 'windows-latest'
run: choco install wget --no-progress
- name: Prepare file with mistakes.
run: echo "Finallizes" > file.txt
- name: Test force pass with mistakes
@ -31,7 +35,7 @@ jobs:
name: Spell Check with Type w/History
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Actions Repository
@ -39,6 +43,10 @@ jobs:
with:
fetch-depth: 0
- name: Install wget for Windows
if: matrix.os == 'windows-latest'
run: choco install wget --no-progress
- name: Prepare file with mistakes.
run: echo "Finallizes" > file.txt
- name: Test force pass with mistakes

View file

@ -27,16 +27,26 @@ if [[ ! -x ${COMMAND} ]]; then
else
ARCH="x86_64"
fi
if [[ "$(uname -s)" == "Darwin" ]]; then
UNAME=$(uname -s)
if [[ "$UNAME" == "Darwin" ]]; then
TARGET_FILE="${ARCH}-apple-darwin"
FILE_EXT="tar.gz"
elif [[ "$UNAME" == CYGWIN* || "$UNAME" == MINGW* || "$UNAME" == MSYS* ]] ; then
TARGET_FILE="${ARCH}-pc-windows-msvc"
FILE_EXT="zip"
else
TARGET_FILE="${ARCH}-unknown-linux-musl"
FILE_EXT="tar.gz"
fi
FILE_NAME="typos-v${VERSION}-${TARGET_FILE}.tar.gz"
FILE_NAME="typos-v${VERSION}-${TARGET_FILE}.${FILE_EXT}"
log "Downloading 'typos' v${VERSION}"
wget --progress=dot:mega "https://github.com/crate-ci/typos/releases/download/v${VERSION}/${FILE_NAME}"
mkdir -p ${_INSTALL_DIR}
tar -xzvf "${FILE_NAME}" -C ${_INSTALL_DIR} ./${CMD_NAME}
if [[ "$FILE_EXT" == "zip" ]]; then
unzip -o "${FILE_NAME}" -d ${_INSTALL_DIR} ${CMD_NAME}.exe
else
tar -xzvf "${FILE_NAME}" -C ${_INSTALL_DIR} ./${CMD_NAME}
fi
rm "${FILE_NAME}"
fi
log "jq: $(jq --version)"