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