Skip to content

Commit 1a377d2

Browse files
committed
build: fix actions.
1 parent 3e5cac5 commit 1a377d2

File tree

3 files changed

+105
-21
lines changed

3 files changed

+105
-21
lines changed

.github/workflows/fns.sh

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
vercomp () {
4+
if [[ $1 == $2 ]]
5+
then
6+
return 0
7+
fi
8+
local IFS=.
9+
local i ver1=($1) ver2=($2)
10+
# fill empty fields in ver1 with zeros
11+
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
12+
do
13+
ver1[i]=0
14+
done
15+
for ((i=0; i<${#ver1[@]}; i++))
16+
do
17+
if [[ -z ${ver2[i]} ]]
18+
then
19+
# fill empty fields in ver2 with zeros
20+
ver2[i]=0
21+
fi
22+
if ((10#${ver1[i]} > 10#${ver2[i]}))
23+
then
24+
return 1
25+
fi
26+
if ((10#${ver1[i]} < 10#${ver2[i]}))
27+
then
28+
return 2
29+
fi
30+
done
31+
return 0
32+
}
33+
34+
install_fibjs() {
35+
local version=$1
36+
if [[ -z "$version" ]]; then
37+
echo "[install_fibjs] version is required"
38+
exit 1
39+
fi
40+
local os=$2
41+
if [[ -z "$os" ]]; then
42+
echo "[install_fibjs] os is required"
43+
exit 1
44+
fi
45+
local arch=$3
46+
if [[ -z "$arch" ]]; then
47+
echo "[install_fibjs] arch is required"
48+
exit 1
49+
fi
50+
51+
vercomp "${version}" "0.37.0"
52+
local lower_than_0_37_0="false"
53+
[ "$?" -eq "2" ] && lower_than_0_37_0="true"
54+
55+
local url_base="https://github.com/fibjs/fibjs/releases/download/v${version}/fibjs-v${version}-${os}-${arch}"
56+
echo "[install_fibjs] Downloading fibjs from ${url_base}"
57+
58+
# in fact, for version <= 0.36.0, there's also non-archived linux fibjs
59+
if [[ "$RUNNER_OS" == "Linux" && "$lower_than_0_37_0" == "true" ]]; then
60+
curl -SL "$url_base.xz" -o ./node_modules/.bin/fibjs.xz;
61+
xz -d ./node_modules/.bin/fibjs.xz;
62+
chmod a+x ./node_modules/.bin/fibjs;
63+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
64+
curl -SL "$url_base" -o ./node_modules/.bin/fibjs;
65+
chmod a+x ./node_modules/.bin/fibjs;
66+
else
67+
curl -SL "$url_base.exe" -o ./node_modules/.bin/fibjs.exe;
68+
fi
69+
}

.github/workflows/run-ci.yml

+15-17
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,24 @@ jobs:
2424
continue-on-error: true
2525
strategy:
2626
matrix:
27-
os:
27+
os:
28+
- windows-2019
2829
- ubuntu-20.04
29-
# since fibjs 0.37.0, windows-2019 not supported
30-
- windows-2022
3130
- macos-11
32-
version: [0.34.0, 0.35.0, 0.36.0, 0.37.0]
31+
fibjs: [0.34.0, 0.35.0, 0.36.0, 0.37.0]
3332
arch: [amd64, i386]
3433
exclude:
35-
- os: windows-2022
34+
- os: windows-2019
3635
arch: i386
3736
- os: macos-11
3837
arch: i386
39-
38+
include:
39+
- os: windows-2022
40+
arch: arm64
41+
fibjs: 0.37.0
42+
- os: macos-11
43+
arch: arm64
44+
fibjs: 0.37.0
4045
steps:
4146
- name: Check out Git repository
4247
uses: actions/checkout@v2
@@ -55,26 +60,19 @@ jobs:
5560
env:
5661
ARCH: ${{ matrix.arch }}
5762
OS: ${{ matrix.os }}
63+
FIBJS_VERSION: ${{ matrix.fibjs }}
5864

5965
- name: Install FIBJS
6066
shell: bash
6167
run: |
6268
mkdir -p ./node_modules/.bin;
6369
rm -rf ./node_modules/.bin/fibjs;
64-
if [[ "$RUNNER_OS" == "Linux" ]]; then
65-
curl -SL "https://github.com/fibjs/fibjs/releases/download/v${FIBJS_VERSION}/fibjs-v${FIBJS_VERSION}-${FIBJS_OS}-${FIBJS_ARCH}.xz" -o ./node_modules/.bin/fibjs.xz;
66-
xz -d ./node_modules/.bin/fibjs.xz;
67-
chmod a+x ./node_modules/.bin/fibjs;
68-
elif [[ "$RUNNER_OS" == "macOS" ]]; then
69-
curl -SL "https://github.com/fibjs/fibjs/releases/download/v${FIBJS_VERSION}/fibjs-v${FIBJS_VERSION}-${FIBJS_OS}-${FIBJS_ARCH}" -o ./node_modules/.bin/fibjs;
70-
chmod a+x ./node_modules/.bin/fibjs;
71-
else
72-
curl -SL "https://github.com/fibjs/fibjs/releases/download/v${FIBJS_VERSION}/fibjs-v${FIBJS_VERSION}-${FIBJS_OS}-${FIBJS_ARCH}.exe" -o ./node_modules/.bin/fibjs.exe;
73-
fi
70+
. ./.github/workflows/fns.sh --source-only
71+
install_fibjs $FIBJS_VERSION $FIBJS_OS $FIBJS_ARCH;
7472
env:
7573
FIBJS_OS: ${{ steps.set-env-vars.outputs.FIBJS_OS }}
7674
FIBJS_ARCH: ${{ steps.set-env-vars.outputs.FIBJS_ARCH }}
77-
FIBJS_VERSION: ${{ matrix.version }}
75+
FIBJS_VERSION: ${{ matrix.fibjs }}
7876

7977
- name: Run CI
8078
shell: bash

.github/workflows/set-env-vars.sh

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
. ./.github/workflows/fns.sh --source-only
2+
13
export GIT_BRANCH=${GITHUB_REF#refs/heads/}
24
echo "::set-output name=GIT_BRANCH::$GIT_BRANCH"
35
export GIT_TAG=$(git tag | grep $(git describe --tags HEAD))
@@ -25,9 +27,20 @@ if [ -z "$IS_GIT_TAG_MATCH_SEMVER" ]; then
2527
fi
2628
echo "::set-output name=RELEASE_TAG::$RELEASE_TAG";
2729

30+
vercomp "${FIBJS_VERSION}" "0.37.0"
31+
lower_than_0_37_0="false"
32+
[ $? -eq 2 ] && lower_than_0_37_0="true"
33+
34+
echo "lower_than_0_37_0: $lower_than_0_37_0"
35+
2836
case "${RUNNER_OS}" in
2937
Windows)
30-
export FIBJS_OS=windows
38+
# lower than 0.37.0
39+
if [[ "$lower_than_0_37_0" -eq "true" ]]; then
40+
export FIBJS_OS=windows
41+
else
42+
export FIBJS_OS=win32
43+
fi
3144
;;
3245
macOS)
3346
export FIBJS_OS=darwin
@@ -43,10 +56,14 @@ esac
4356
echo "::set-output name=FIBJS_OS::$FIBJS_OS";
4457

4558
case "${ARCH}" in
46-
i386)
47-
export FIBJS_ARCH=x86
59+
i386|ia32|x86)
60+
if [[ "$lower_than_0_37_0" -eq "true" ]]; then
61+
export FIBJS_ARCH=x86
62+
else
63+
export FIBJS_ARCH=ia32
64+
fi
4865
;;
49-
amd64)
66+
amd64|x64)
5067
export FIBJS_ARCH=x64
5168
;;
5269
*)

0 commit comments

Comments
 (0)