]> git.cameronkatri.com Git - ldid.git/blob - .github/workflows/build.yml
Use OpenSSL 1.1.1 in GH actions for now
[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: 1.1.1n
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 "LDFLAGS=-Wl,--gc-sections -Wl,-strip-all -flto" >> $GITHUB_ENV
81
82 - name: build libplist
83 run: |
84 wget -q -nc -P ${DOWNLOAD_PATH} https://github.com/libimobiledevice/libplist/releases/download/${LIBPLIST_VERSION}/libplist-${LIBPLIST_VERSION}.tar.bz2
85 tar xf ${DOWNLOAD_PATH}/libplist-${LIBPLIST_VERSION}.tar.bz2 -C ${DEP_PATH}
86 cd ${DEP_PATH}/libplist-${LIBPLIST_VERSION}
87 ./configure --host=${TRIPLE} --prefix=/usr --without-cython --enable-static --disable-shared
88 make -j$(nproc)
89
90 echo "CPPFLAGS=${CPPFLAGS} -I${DEP_PATH}/libplist-${LIBPLIST_VERSION}/include" >> $GITHUB_ENV
91 echo "LIBPLIST_LIB=${DEP_PATH}/libplist-${LIBPLIST_VERSION}/src/.libs/libplist-2.0.a" >> $GITHUB_ENV
92
93 - name: build openssl
94 run: |
95 export PLATFORM="linux-${ARCH}"
96
97 wget -q -nc -P ${DOWNLOAD_PATH} https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
98 tar xf ${DOWNLOAD_PATH}/openssl-${OPENSSL_VERSION}.tar.gz -C ${DEP_PATH}
99 cd ${DEP_PATH}/openssl-${OPENSSL_VERSION}
100 ./Configure --prefix=/usr --static -static ${PLATFORM}
101 make -j$(nproc) build_generated libcrypto.a
102
103 echo "CPPFLAGS=${CPPFLAGS} -I${DEP_PATH}/openssl-${OPENSSL_VERSION}/include" >> $GITHUB_ENV
104 echo "LIBCRYPTO_LIB=${DEP_PATH}/openssl-${OPENSSL_VERSION}/libcrypto.a" >> $GITHUB_ENV
105
106 - name: build
107 run: |
108 export LDID_VERSION=$(echo "$(git describe --tags --abbrev=0)")
109 make -j$(nproc) \
110 VERSION="${LDID_VERSION}" \
111 LDFLAGS="-static -static-libstdc++ ${LDFLAGS}" \
112 LIBS="${LIBPLIST_LIB} ${LIBCRYPTO_LIB}"
113 ${TRIPLE}-strip ldid
114
115 - uses: actions/upload-artifact@v1
116 with:
117 name: ldid_linux_${{ env.ARCH }}
118 path: ldid
119
120 - name: Upload Release Asset Linux
121 uses: actions/upload-release-asset@v1
122 if: ${{ github.event_name == 'release' }}
123 env:
124 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125 with:
126 upload_url: ${{ github.event.release.upload_url }}
127 asset_path: ldid
128 asset_name: ldid_linux_${{ env.ARCH }}
129 asset_content_type: application/octet-stream
130
131 build-macos:
132 runs-on: macos-11
133 strategy:
134 matrix:
135 arch:
136 - x86_64
137 - arm64
138 env:
139 ARCH: ${{ matrix.arch }}
140 steps:
141 - uses: actions/checkout@v1
142 with:
143 submodules: recursive
144
145 - uses: actions/cache@v2
146 with:
147 path: |
148 ~/Library/Caches/Mozilla.sccache
149 ~/dep_src
150 key: build-macos-${{ matrix.arch }}-${ { env.GITHUB_SHA } }
151 restore-keys: |
152 build-macos-${{ matrix.arch }}-
153
154 - name: setup environment
155 run: |
156 export DOWNLOAD_PATH=${HOME}/dep_src
157 export DEP_PATH=${HOME}/build
158 mkdir -p ${DOWNLOAD_PATH} ${DEP_PATH}
159 echo "DOWNLOAD_PATH=${DOWNLOAD_PATH}" >> $GITHUB_ENV
160 echo "DEP_PATH=${DEP_PATH}" >> $GITHUB_ENV
161
162 if [ "${ARCH}" = "arm64" ]; then
163 echo "HOST_ARCH=aarch64" >> $GITHUB_ENV
164 else
165 echo "HOST_ARCH=${ARCH}" >> $GITHUB_ENV
166 fi
167
168 - name: setup toolchain
169 run: |
170 brew install libtool autoconf automake
171
172 # Download sccache
173 wget -nc -P ${DOWNLOAD_PATH} \
174 https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin.tar.gz
175 tar xf ${DOWNLOAD_PATH}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin.tar.gz -C ${HOME}
176 chmod +x ${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin/sccache
177
178 echo "${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin" >> $GITHUB_PATH
179 echo "CC=sccache clang -arch ${ARCH} -mmacosx-version-min=10.13" >> $GITHUB_ENV
180 echo "CXX=sccache clang++ -arch ${ARCH} -mmacosx-version-min=10.13" >> $GITHUB_ENV
181 echo "CFLAGS=-Os" >> $GITHUB_ENV
182
183 - name: build libplist
184 run: |
185 wget -q -nc -P ${DOWNLOAD_PATH} https://github.com/libimobiledevice/libplist/releases/download/${LIBPLIST_VERSION}/libplist-${LIBPLIST_VERSION}.tar.bz2
186 tar xf ${DOWNLOAD_PATH}/libplist-${LIBPLIST_VERSION}.tar.bz2 -C ${DEP_PATH}
187 cd ${DEP_PATH}/libplist-${LIBPLIST_VERSION}
188 ./configure --host=${HOST_ARCH}-apple-darwin --without-cython --enable-static --disable-shared
189 make -j$(sysctl -n hw.ncpu)
190
191 echo "CFLAGS=${CFLAGS} -I${DEP_PATH}/libplist-${LIBPLIST_VERSION}/include" >> $GITHUB_ENV
192 echo "LIBPLIST_LIB=${DEP_PATH}/libplist-${LIBPLIST_VERSION}/src/.libs/libplist-2.0.a" >> $GITHUB_ENV
193
194 - name: build openssl
195 run: |
196 wget -q -nc -P ${DOWNLOAD_PATH} https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
197 tar xf ${DOWNLOAD_PATH}/openssl-${OPENSSL_VERSION}.tar.gz -C ${DEP_PATH}
198 cd ${DEP_PATH}/openssl-${OPENSSL_VERSION}
199 ./Configure --prefix=/usr no-shared darwin64-${ARCH}-cc
200 make -j$(sysctl -n hw.ncpu) build_generated libcrypto.a
201
202 echo "CFLAGS=${CFLAGS} -I${DEP_PATH}/openssl-${OPENSSL_VERSION}/include" >> $GITHUB_ENV
203 echo "LIBCRYPTO_LIB=${DEP_PATH}/openssl-${OPENSSL_VERSION}/libcrypto.a" >> $GITHUB_ENV
204
205 - name: build
206 run: |
207 export LDID_VERSION=$(echo "$(git describe --tags --abbrev=0)")
208 make -j$(sysctl -n hw.ncpu) \
209 CFLAGS="${CFLAGS} -flto=thin" \
210 VERSION="${LDID_VERSION}" \
211 LIBS="${LIBPLIST_LIB} ${LIBCRYPTO_LIB}"
212 strip ldid
213
214 - uses: actions/upload-artifact@v1
215 with:
216 name: ldid_macos_${{ matrix.arch }}
217 path: ldid
218
219 - name: Upload Release Asset Linux
220 uses: actions/upload-release-asset@v1
221 if: ${{ github.event_name == 'release' }}
222 env:
223 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224 with:
225 upload_url: ${{ github.event.release.upload_url }}
226 asset_path: ldid
227 asset_name: ldid_macos_${{ matrix.arch }}
228 asset_content_type: application/octet-stream