-
Notifications
You must be signed in to change notification settings - Fork 13
136 lines (136 loc) · 4.42 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Build
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
pull_request:
env:
WABT_TOOLS: wasm2c wasm2wat wat2wasm wasm-decompile wasm-interp wasm-objdump wasm-stats wasm-strip wasm-validate
jobs:
build:
name: "Build with Emsdk"
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || !contains(github.event.head_commit.message, '[ci skip]')
env:
MAKE_FLAGS: "-j2"
CMAKE_EXE_LINKER_FLAGS: "-sSINGLE_FILE"
steps:
- name: "Set up Emsdk"
run: |
mkdir $HOME/emsdk
git clone --depth 1 https://github.com/emscripten-core/emsdk.git $HOME/emsdk
$HOME/emsdk/emsdk update-tags
$HOME/emsdk/emsdk install latest
$HOME/emsdk/emsdk activate latest
echo "$HOME/emsdk" >> $GITHUB_PATH
- name: "Set up CMake"
run: |
mkdir $HOME/cmake
wget -qO- https://github.com/Kitware/CMake/releases/download/v3.16.0/cmake-3.16.0-Linux-x86_64.tar.gz | tar -xzC $HOME/cmake --strip-components 1
echo "$HOME/cmake/bin" >> $GITHUB_PATH
- name: "Check out repository"
uses: actions/checkout@v1
with:
submodules: true
- name: "Set up repository"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git fetch origin
if [ -z "$GITHUB_HEAD_REF" ]; then
# If not a PR, undo detached head
git checkout "${GITHUB_REF:11}"
fi
git submodule update --init --remote --merge
git submodule foreach 'git submodule update --init'
cd ./wabt
git log -n1
cd ..
- name: "Determine version"
run: |
npm install
VERSION=`node scripts/version`
echo "VERSION=$VERSION" >> $GITHUB_ENV
if [[ $VERSION != *nightly* ]]; then
echo "Building release v$VERSION ...";
TAG=`node scripts/version tag`
echo "Resetting to $TAG ..."
cd ./wabt
git reset --hard "$TAG"
git clean -f
git log -n1
cd ..
echo "RELEASE=1" >> $GITHUB_ENV
else
echo "Building nightly v$VERSION ...";
echo "RELEASE=" >> $GITHUB_ENV
fi
- name: "Build wabt.js"
run: |
mkdir -p ./wabt/build/
cd ./wabt/build
source $HOME/emsdk/emsdk_env.sh
emcc --version
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" ..
emmake make $MAKEFLAGS libwabtjs
cp ./libwabt.js ../../index.js
cd ../..
- name: "Test wabt.js"
run: |
node ./tests
- name: "Build tools"
run: |
mkdir -p ./bin
cd ./wabt/build
source $HOME/emsdk/emsdk_env.sh
emcc --version
for tool in ${{ env.WABT_TOOLS }}; do
emmake make $MAKEFLAGS "$tool"
echo '#!/usr/bin/env node' > "../../bin/$tool"
cat "./$tool.js" >> "../../bin/$tool"
done
cd ../..
chmod +x ./bin/*
node scripts/update-tools ${{ env.WABT_TOOLS }}
- name: "Test tools"
run: |
for tool in ${{ env.WABT_TOOLS }}; do
"./bin/$tool" --help
done
- name: "Push changes to GitHub"
if: github.event_name == 'schedule'
run: |
git add ./wabt ./index.js ./bin/*
npm version $VERSION --no-git-tag-version --force
if [ $RELEASE ]; then
echo "Committing release ("$VERSION") ..."
git add ./package.json ./package-lock.json
git commit -m "Release v$VERSION"
else
echo "Committing nightly ("$VERSION") ..."
git commit -m "Nightly v$VERSION [ci skip]"
fi
git push -u origin main
echo "Creating tag v$VERSION ..."
git tag "v$VERSION"
git push -u origin "v$VERSION"
- name: "Publish to npm"
if: github.event_name == 'schedule'
env:
NPM_REGISTRY: "registry.npmjs.org"
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm config set "//${NPM_REGISTRY}/:_authToken=${NPM_AUTH_TOKEN}"
if [ $RELEASE ]; then
echo "Publishing release ..."
npm publish
else
echo "Publishing nightly ..."
npm publish --tag nightly
fi