]> git.cameronkatri.com Git - ldid.git/blob - .github/workflows/build.yml
Fix workflow
[ldid.git] / .github / workflows / build.yml
1 name: build
2 on:
3 push:
4 paths:
5 - '*.c'
6 - '*.cpp'
7 pull_request:
8 workflow_dispatch:
9 release:
10 types:
11 - created
12
13 env:
14 LIBPLIST_VERSION: 2.2.0
15 OPENSSL_VERSION: 3.0.0
16 SCCACHE_VERSION: 0.2.15
17
18 jobs:
19 build-linux:
20 runs-on: ubuntu-latest
21 strategy:
22 matrix:
23 triple:
24 - arm-linux-musleabi
25 - aarch64-linux-musl
26 - i486-linux-musl
27 - riscv64-linux-musl
28 - x86_64-linux-musl
29 env:
30 TOOLCHAIN: ${{ matrix.triple }}-cross
31 TRIPLE: ${{ matrix.triple }}
32
33 steps:
34 - uses: actions/checkout@v1
35 with:
36 submodules: recursive
37
38 - uses: actions/cache@v2
39 with:
40 path: |
41 ~/.cache/sccache
42 ~/dep_src
43 key: build-linux-${{ matrix.triple }}-${{ env.GITHUB_SHA }}
44 restore-keys: |
45 build-linux-${{ matrix.triple }}
46
47 - name: setup environment
48 run: |
49 export DOWNLOAD_PATH=${HOME}/dep_src
50 export DEP_PATH=${HOME}/build
51 mkdir -p ${DOWNLOAD_PATH} ${DEP_PATH}
52 echo "DOWNLOAD_PATH=${DOWNLOAD_PATH}" >> $GITHUB_ENV
53 echo "DEP_PATH=${DEP_PATH}" >> $GITHUB_ENV
54 echo "ARCH=$(echo ${{ matrix.triple }} | cut -d- -f 1)" >> $GITHUB_ENV
55
56 - name: setup toolchain
57 run: |
58 # Download Toolchain
59 wget -q -nc -P ${DOWNLOAD_PATH} https://musl.cc/${TOOLCHAIN}.tgz
60 tar xf ${DOWNLOAD_PATH}/${TOOLCHAIN}.tgz -C ${HOME}
61
62 # Download sccache
63 wget -q -nc -P ${DOWNLOAD_PATH} \
64 https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz
65 tar xf ${DOWNLOAD_PATH}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz -C ${HOME}
66 mv ${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache ${HOME}/${TOOLCHAIN}/bin
67 chmod +x ${HOME}/${TOOLCHAIN}/bin/sccache
68
69 echo "${HOME}/${TOOLCHAIN}/bin" >> $GITHUB_PATH
70 echo "CC=sccache ${TRIPLE}-gcc" >> $GITHUB_ENV
71 echo "CXX=sccache ${TRIPLE}-g++" >> $GITHUB_ENV
72 echo "CFLAGS=-Os -static" >> $GITHUB_ENV
73
74 - name: build libplist
75 run: |
76 wget -q -nc -P ${DOWNLOAD_PATH} https://github.com/libimobiledevice/libplist/releases/download/${LIBPLIST_VERSION}/libplist-${LIBPLIST_VERSION}.tar.bz2
77 tar xf ${DOWNLOAD_PATH}/libplist-${LIBPLIST_VERSION}.tar.bz2 -C ${DEP_PATH}
78 cd ${DEP_PATH}/libplist-${LIBPLIST_VERSION}
79 ./configure --host=${TRIPLE} --prefix=/usr --without-cython --enable-static --disable-shared
80 make -j$(nproc)
81
82 echo "CFLAGS=${CFLAGS} -I${DEP_PATH}/libplist-${LIBPLIST_VERSION}/include" >> $GITHUB_ENV
83 echo "LIBPLIST_LIB=${DEP_PATH}/libplist-${LIBPLIST_VERSION}/src/.libs/libplist-2.0.a" >> $GITHUB_ENV
84
85 - name: build openssl
86 run: |
87 export PLATFORM="linux-${ARCH}"
88 case ${ARCH} in
89 arm)
90 export PLATFORM="linux-generic32"
91 ;;
92 i486)
93 export PLATFORM="linux-x86"
94 ;;
95 riscv64)
96 export PLATFORM="linux64-riscv64"
97 ;;
98 esac
99
100 wget -q -nc -P ${DOWNLOAD_PATH} https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
101 tar xf ${DOWNLOAD_PATH}/openssl-${OPENSSL_VERSION}.tar.gz -C ${DEP_PATH}
102 cd ${DEP_PATH}/openssl-${OPENSSL_VERSION}
103 ./config --prefix=/usr --static -static ${PLATFORM}
104 make -j$(nproc) build_generated libcrypto.a
105
106 echo "CFLAGS=${CFLAGS} -I${DEP_PATH}/openssl-${OPENSSL_VERSION}/include" >> $GITHUB_ENV
107 echo "LIBCRYPTO_LIB=${DEP_PATH}/openssl-${OPENSSL_VERSION}/libcrypto.a" >> $GITHUB_ENV
108
109 - name: build
110 run: |
111 export LDID_VERSION=$(echo "$(git describe --tags --abbrev=0)")
112 make -j$(nproc) \
113 VERSION="${LDID_VERSION}" \
114 LIBS="${LIBPLIST_LIB} ${LIBCRYPTO_LIB}"
115 ${TRIPLE}-strip ldid
116
117 - uses: actions/upload-artifact@v1
118 with:
119 name: ldid_linux_${{ env.ARCH }}
120 path: ldid
121
122 - name: Upload Release Asset Linux
123 uses: actions/upload-release-asset@v1
124 if: ${{ github.event_name == 'release' }}
125 env:
126 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127 with:
128 upload_url: ${{ github.event.release.upload_url }}
129 asset_path: ldid
130 asset_name: ldid_linux_${{ env.ARCH }}
131 asset_content_type: application/octet-stream
132
133 build-macos:
134 runs-on: macos-11
135 strategy:
136 matrix:
137 arch:
138 - x86_64
139 - arm64
140 env:
141 ARCH: ${{ matrix.arch }}
142 steps:
143 - uses: actions/checkout@v1
144 with:
145 submodules: recursive
146
147 - uses: actions/cache@v2
148 with:
149 path: |
150 ~/Library/Caches/Mozilla.sccache
151 ~/dep_src
152 key: build-macos-${{ matrix.arch }}-${ { env.GITHUB_SHA } }
153 restore-keys: |
154 build-macos-${{ matrix.arch }}-
155
156 - name: setup environment
157 run: |
158 export DOWNLOAD_PATH=${HOME}/dep_src
159 export DEP_PATH=${HOME}/build
160 mkdir -p ${DOWNLOAD_PATH} ${DEP_PATH}
161 echo "DOWNLOAD_PATH=${DOWNLOAD_PATH}" >> $GITHUB_ENV
162 echo "DEP_PATH=${DEP_PATH}" >> $GITHUB_ENV
163
164 if [ "${ARCH}" = "arm64" ]; then
165 echo "HOST_ARCH=aarch64" >> $GITHUB_ENV
166 else
167 echo "HOST_ARCH=${ARCH}" >> $GITHUB_ENV
168 fi
169
170 - name: setup toolchain
171 run: |
172 brew install libtool autoconf automake
173
174 # Download sccache
175 wget -nc -P ${DOWNLOAD_PATH} \
176 https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin.tar.gz
177 tar xf ${DOWNLOAD_PATH}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin.tar.gz -C ${HOME}
178 chmod +x ${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin/sccache
179
180 echo "${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin" >> $GITHUB_PATH
181 echo "CC=sccache clang -arch ${ARCH} -mmacosx-version-min=10.13" >> $GITHUB_ENV
182 echo "CXX=sccache clang++ -arch ${ARCH} -mmacosx-version-min=10.13" >> $GITHUB_ENV
183 echo "CFLAGS=-Os" >> $GITHUB_ENV
184
185 - name: build libplist
186 run: |
187 wget -q -nc -P ${DOWNLOAD_PATH} https://github.com/libimobiledevice/libplist/releases/download/${LIBPLIST_VERSION}/libplist-${LIBPLIST_VERSION}.tar.bz2
188 tar xf ${DOWNLOAD_PATH}/libplist-${LIBPLIST_VERSION}.tar.bz2 -C ${DEP_PATH}
189 cd ${DEP_PATH}/libplist-${LIBPLIST_VERSION}
190 ./configure --host=${HOST_ARCH}-apple-darwin --without-cython --enable-static --disable-shared
191 make -j$(sysctl -n hw.ncpu)
192
193 echo "CFLAGS=${CFLAGS} -I${DEP_PATH}/libplist-${LIBPLIST_VERSION}/include" >> $GITHUB_ENV
194 echo "LIBPLIST_LIB=${DEP_PATH}/libplist-${LIBPLIST_VERSION}/src/.libs/libplist-2.0.a" >> $GITHUB_ENV
195
196 - name: build openssl
197 run: |
198 wget -q -nc -P ${DOWNLOAD_PATH} https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
199 tar xf ${DOWNLOAD_PATH}/openssl-${OPENSSL_VERSION}.tar.gz -C ${DEP_PATH}
200 cd ${DEP_PATH}/openssl-${OPENSSL_VERSION}
201 ./config --prefix=/usr no-shared darwin64-${ARCH}
202 make -j$(sysctl -n hw.ncpu) build_generated libcrypto.a
203
204 echo "CFLAGS=${CFLAGS} -I${DEP_PATH}/openssl-${OPENSSL_VERSION}/include" >> $GITHUB_ENV
205 echo "LIBCRYPTO_LIB=${DEP_PATH}/openssl-${OPENSSL_VERSION}/libcrypto.a" >> $GITHUB_ENV
206
207 - name: build
208 run: |
209 export LDID_VERSION=$(echo "$(git describe --tags --abbrev=0)")
210 make -j$(sysctl -n hw.ncpu) \
211 CFLAGS="${CFLAGS} -flto=thin" \
212 VERSION="${LDID_VERSION}" \
213 LIBS="${LIBPLIST_LIB} ${LIBCRYPTO_LIB}"
214 strip ldid
215
216 - uses: actions/upload-artifact@v1
217 with:
218 name: ldid_macos_${{ matrix.arch }}
219 path: ldid
220
221 - name: Upload Release Asset Linux
222 uses: actions/upload-release-asset@v1
223 if: ${{ github.event_name == 'release' }}
224 env:
225 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226 with:
227 upload_url: ${{ github.event.release.upload_url }}
228 asset_path: ldid
229 asset_name: ldid_macos_${{ matrix.arch }}
230 asset_content_type: application/octet-stream