@@ -12,111 +12,147 @@ on:
1212 default : ' rc'
1313 required : true
1414
15-
1615permissions :
1716 contents : write # needed to write releases
1817 id-token : write # needed for keyless signing
1918
2019jobs :
21-
22- linux-amd64-release :
20+ linux-x86_64-all-libs :
2321 runs-on : ubuntu-latest
2422 steps :
2523 - name : Checkout
2624 uses : actions/checkout@v3
2725 - name : Build static libraries - libgit2 compiled with libssh2 and openssl
2826 run : |
29- TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-linux \
27+ TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-linux-all-libs \
3028 BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
3129 ./hack/static.sh all
32-
33- mkdir -p ./libgit2-linux-libgit2- all/
34- mv ${GITHUB_WORKSPACE}/build/libgit2-linux/include ./libgit2-linux-libgit2- all/
35- mv ${GITHUB_WORKSPACE}/build/libgit2-linux/share ./libgit2-linux-libgit2- all/
36- mv ${GITHUB_WORKSPACE}/build/libgit2-linux/lib ./libgit2-linux-libgit2- all/
37- mv ${GITHUB_WORKSPACE}/build/libgit2-linux/lib64 ./libgit2-linux-libgit2- all/
38-
39- tar -zcvf linux-x86_64-libgit2- all-libs.tar.gz libgit2-linux-libgit2- all
30+
31+ mkdir -p ./libgit2-linux-all-libs /
32+ mv ${GITHUB_WORKSPACE}/build/libgit2-linux-all-libs /include ./libgit2-linux-all-libs /
33+ mv ${GITHUB_WORKSPACE}/build/libgit2-linux-all-libs /share ./libgit2-linux-all-libs /
34+ mv ${GITHUB_WORKSPACE}/build/libgit2-linux-all-libs /lib ./libgit2-linux-all-libs /
35+ mv ${GITHUB_WORKSPACE}/build/libgit2-linux-all-libs /lib64 ./libgit2-linux-all-libs /
36+
37+ tar -zcvf linux-x86_64-all-libs.tar.gz libgit2-linux-all-libs
4038 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
39+ - uses : actions/upload-artifact@v3
40+ with :
41+ name : release-artifact
42+ path : " *.tar.gz"
43+ if-no-files-found : error
4144
45+ linux-x86_64-libgit2-only :
46+ runs-on : ubuntu-latest
47+ steps :
48+ - name : Checkout
49+ uses : actions/checkout@v3
4250 - name : Build static libraries - libgit2 only
4351 run : |
44- TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-linux \
52+ TARGET_DIR=${GITHUB_WORKSPACE}/build/build_libgit2_only \
4553 BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
4654 ./hack/static.sh build_libgit2_only
4755
48- mkdir -p ./libgit2- linux-libgit2-only/
49- mv ${GITHUB_WORKSPACE}/build/libgit2-linux /include ./libgit2- linux-libgit2-only/
50- mv ${GITHUB_WORKSPACE}/build/libgit2-linux /lib ./libgit2- linux-libgit2-only/
56+ mkdir -p ./linux-libgit2-only/
57+ mv ${GITHUB_WORKSPACE}/build/build_libgit2_only /include ./linux-libgit2-only/
58+ mv ${GITHUB_WORKSPACE}/build/build_libgit2_only /lib ./linux-libgit2-only/
5159
52- tar -zcvf linux-x86_64-libgit2-only-lib .tar.gz libgit2- linux-libgit2-only
60+ tar -zcvf linux-x86_64-libgit2-only.tar.gz linux-libgit2-only
5361 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
5462 - uses : actions/upload-artifact@v3
5563 with :
5664 name : release-artifact
57- path : ' *.tar.gz'
65+ path : " *.tar.gz"
5866 if-no-files-found : error
5967
60- darwin-release :
68+ darwin-all-libs :
6169 # This job builds and releases "universal libraries" that are
6270 # supported by both darwin-amd64 and darwin-arm64.
6371 #
6472 # First builds in amd64, then cross-compile in arm64. Later combining
6573 # both outcomes onto a single binary for each static library.
6674 #
6775 # `macos-11` has been picked as support for arm64 was only added on Xcode 12.
68- # Although some minor versions of Catalina 10.15 can support it, at the time
69- # of testing, GitHub's macos-10.15 did not seem to.
76+ # Although some minor versions of Catalina 10.15 can support it, at the time
77+ # of testing, GitHub's macos-10.15 did not seem to.
7078 # Cross-compiling to arm64 on that runner consistently failed.
7179 runs-on : macos-11
7280 steps :
7381 - name : Checkout
7482 uses : actions/checkout@v3
7583 - name : Build universal static libraries for Darwin - libgit2 compiled with libssh2 and openssl
7684 run : |
77- TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64 \
85+ # The amd64 is used as base, using the target dir name (darwin-all-libs)
86+ # instead of the platform specific one, removes the need of replacing the
87+ # path in the .pc files.
88+ TARGET_DIR=${GITHUB_WORKSPACE}/build/darwin-all-libs \
7889 BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
7990 ./hack/static.sh all
80-
91+
8192 TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64 \
8293 BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/arm \
8394 TARGET_ARCH=arm64 \
8495 CMAKE_APPLE_SILICON_PROCESSOR=arm64 \
8596 ./hack/static.sh all
8697
87- mkdir -p ./libgit2-darwin-libgit2-all/lib
88- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./libgit2-darwin-libgit2-all/
89- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/share ./libgit2-darwin-libgit2-all/
90- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/cmake ./libgit2-darwin-libgit2-all/lib/
91- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/engines-3 ./libgit2-darwin-libgit2-all/lib/
92- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/ossl-modules ./libgit2-darwin-libgit2-all/lib/
93- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/pkgconfig ./libgit2-darwin-libgit2-all/lib/
9498
95- libtool -static -o ./libgit2-darwin-libgit2-all/lib/libcrypto.a \
96- ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libcrypto.a \
99+ LIBGIT2_SED="s;-L/Applications/Xcode.* ;;g"
100+ LIBGIT2PC="${GITHUB_WORKSPACE}/build/darwin-all-libs/lib/pkgconfig/libgit2.pc"
101+
102+ # pkgconfig includes absolute paths that are specific to the runner machine.
103+ # We need to remove the absolute path for iconv, so when the libgit2 library
104+ # is consumed pkgconfig will automatically try to find it through the default
105+ # search paths on the target machine.
106+ if command -v gsed &> /dev/null; then
107+ gsed -i "${LIBGIT2_SED}" "${LIBGIT2PC}"
108+ else
109+ sed -i "" "${LIBGIT2_SED}" "${LIBGIT2PC}"
110+ fi
111+
112+ mkdir -p ./darwin-all-libs/lib
113+ mv ${GITHUB_WORKSPACE}/build/darwin-all-libs/include ./darwin-all-libs/
114+ mv ${GITHUB_WORKSPACE}/build/darwin-all-libs/share ./darwin-all-libs/
115+ mv ${GITHUB_WORKSPACE}/build/darwin-all-libs/lib/cmake ./darwin-all-libs/lib/
116+ mv ${GITHUB_WORKSPACE}/build/darwin-all-libs/lib/engines-3 ./darwin-all-libs/lib/
117+ mv ${GITHUB_WORKSPACE}/build/darwin-all-libs/lib/ossl-modules ./darwin-all-libs/lib/
118+ mv ${GITHUB_WORKSPACE}/build/darwin-all-libs/lib/pkgconfig ./darwin-all-libs/lib/
119+
120+ libtool -static -o ./darwin-all-libs/lib/libcrypto.a \
121+ ${GITHUB_WORKSPACE}/build/darwin-all-libs/lib/libcrypto.a \
97122 ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libcrypto.a
98123
99- libtool -static -o ./libgit2- darwin-libgit2- all/lib/libgit2.a \
100- ${GITHUB_WORKSPACE}/build/libgit2- darwin-amd64 /lib/libgit2.a \
124+ libtool -static -o ./darwin-all-libs /lib/libgit2.a \
125+ ${GITHUB_WORKSPACE}/build/darwin-all-libs /lib/libgit2.a \
101126 ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libgit2.a
102127
103- libtool -static -o ./libgit2- darwin-libgit2- all/lib/libssh2.a \
104- ${GITHUB_WORKSPACE}/build/libgit2- darwin-amd64 /lib/libssh2.a \
128+ libtool -static -o ./darwin-all-libs /lib/libssh2.a \
129+ ${GITHUB_WORKSPACE}/build/darwin-all-libs /lib/libssh2.a \
105130 ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libssh2.a
106131
107- libtool -static -o ./libgit2- darwin-libgit2- all/lib/libssl.a \
108- ${GITHUB_WORKSPACE}/build/libgit2- darwin-amd64 /lib/libssl.a \
132+ libtool -static -o ./darwin-all-libs /lib/libssl.a \
133+ ${GITHUB_WORKSPACE}/build/darwin-all-libs /lib/libssl.a \
109134 ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libssl.a
110135
111- libtool -static -o ./libgit2- darwin-libgit2- all/lib/libz.a \
112- ${GITHUB_WORKSPACE}/build/libgit2- darwin-amd64 /lib/libz.a \
136+ libtool -static -o ./darwin-all-libs /lib/libz.a \
137+ ${GITHUB_WORKSPACE}/build/darwin-all-libs /lib/libz.a \
113138 ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libz.a
114139
115- tar -zcvf darwin-libgit2- all-libs.tar.gz libgit2- darwin-libgit2- all
140+ tar -zcvf darwin-all-libs.tar.gz darwin-all-libs
116141 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
117142 env :
118143 MACOSX_DEPLOYMENT_TARGET : 10.15
144+ - uses : actions/upload-artifact@v3
145+ with :
146+ name : release-artifact
147+ path : " *.tar.gz"
148+ if-no-files-found : error
119149
150+ # similar to darwin-all-libs, but only compiles libgit2.
151+ darwin-libgit2-only :
152+ runs-on : macos-11
153+ steps :
154+ - name : Checkout
155+ uses : actions/checkout@v3
120156 - name : Build universal static libraries for Darwin - libgit2 only
121157 run : |
122158 TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64 \
@@ -129,27 +165,46 @@ jobs:
129165 CMAKE_APPLE_SILICON_PROCESSOR=arm64 \
130166 ./hack/static.sh build_libgit2_only
131167
132- mkdir -p ./libgit2-darwin-libgit2-only/lib
133- mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./libgit2-darwin-libgit2-only/
168+ LIBGIT2_SED="s;-L/Applications/Xcode.* ;;g"
169+ LIBGIT2PC="${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/pkgconfig/libgit2.pc"
170+
171+ # pkgconfig includes absolute paths that are specific to the runner machine.
172+ # We need to remove the absolute path for iconv, so when the libgit2 library
173+ # is consumed pkgconfig will automatically try to find it through the default
174+ # search paths on the target machine.
175+ if command -v gsed &> /dev/null; then
176+ gsed -i "${LIBGIT2_SED}" "${LIBGIT2PC}"
177+ else
178+ sed -i "" "${LIBGIT2_SED}" "${LIBGIT2PC}"
179+ fi
180+
181+ mkdir -p ./darwin-libgit2-only/lib
182+ mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./darwin-libgit2-only/
134183
135- libtool -static -o ./libgit2- darwin-libgit2-only/lib/libgit2.a \
184+ libtool -static -o ./darwin-libgit2-only/lib/libgit2.a \
136185 ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libgit2.a \
137186 ${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libgit2.a
138187
139- tar -zcvf darwin-libs- libgit2-only.tar.gz libgit2- darwin-libgit2-only
188+ tar -zcvf darwin-libgit2-only.tar.gz darwin-libgit2-only
140189 rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
141190 env :
142191 MACOSX_DEPLOYMENT_TARGET : 10.15
143192 - uses : actions/upload-artifact@v3
144193 with :
145194 name : release-artifact
146- path : ' *.tar.gz'
195+ path : " *.tar.gz"
147196 if-no-files-found : error
148197
149198 goreleaser :
150199 runs-on : ubuntu-latest
151- needs : [linux-amd64-release, darwin-release]
152- if : ${{ always() && contains(join(needs.*.result, ','), 'success') }}
200+ needs :
201+ [
202+ linux-x86_64-all-libs,
203+ linux-x86_64-libgit2-only,
204+ darwin-all-libs,
205+ darwin-libgit2-only,
206+ ]
207+ if : ${{ always() && contains(join(needs.*.result, ','), 'success') }}
153208 steps :
154209 - uses : actions/checkout@v3
155210 with :
0 commit comments