Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 1282600

Browse files
authored
Merge pull request #24 from aryan9600/libgit2-only
2 parents 00cf5cd + 22f29d4 commit 1282600

File tree

8 files changed

+438
-76
lines changed

8 files changed

+438
-76
lines changed

.github/workflows/build.yaml

+56-22
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,15 @@ jobs:
2222
steps:
2323
- name: Checkout
2424
uses: actions/checkout@v2
25-
- name: Test build script for darwin-amd64
25+
- name: Test build script for darwin-amd64 - libgit2-all
2626
run: |
27-
TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64 \
28-
BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
29-
./hack/static.sh all
27+
make dev-test
28+
rm -rf ${GITHUB_WORKSPACE}/build rm -rf ${GITHUB_WORKSPACE}/libgit2
3029
env:
3130
MACOSX_DEPLOYMENT_TARGET: 10.15
32-
- name: Test cross compile script for darwin-arm64
31+
- name: Test build script for darwin-amd64 - libgit2-only
3332
run: |
34-
TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64 \
35-
BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/arm \
36-
TARGET_ARCH=arm64 \
37-
CMAKE_APPLE_SILICON_PROCESSOR=arm64 \
38-
./hack/static.sh all
33+
LIBGIT2_ONLY=true make dev-test
3934
env:
4035
MACOSX_DEPLOYMENT_TARGET: 10.15
4136

@@ -83,24 +78,37 @@ jobs:
8378
restore-keys: |
8479
${{ runner.os }}-buildx-ghcache-
8580
- run: cat ./hack/static.sh
86-
- name: Build candidate image
87-
id: build_candidate
81+
- name: Build candidate image - libgit2 compiled with libssh2 and openssl
82+
id: build_candidate_libgit2_all
8883
uses: docker/build-push-action@v2
8984
with:
9085
context: .
9186
file: Dockerfile
9287
platforms: ${{ env.PLATFORMS }}
9388
push: true
94-
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2:latest
89+
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-all:latest
9590
cache-from: type=local,src=/tmp/.buildx-cache
9691
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
97-
- name: Inspect candidate image
92+
- name: Build candidate image - libgit2 only
93+
id: build_candidate_libgti2_only
94+
uses: docker/build-push-action@v2
95+
with:
96+
context: .
97+
file: Dockerfile.libgit2-only
98+
platforms: ${{ env.PLATFORMS }}
99+
push: true
100+
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
101+
cache-from: type=local,src=/tmp/.buildx-cache
102+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
103+
- name: Inspect candidate images
98104
run: |
99-
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2:latest
100-
- name: Test candidate image
105+
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-all:latest
106+
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
107+
- name: Test candidate images
101108
id: test_candidate
102109
run: |
103-
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2 make test
110+
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-all make test
111+
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only LIBGIT2_ONLY=true make test
104112
- # Temp fix
105113
# https://github.com/docker/build-push-action/issues/252
106114
# https://github.com/moby/buildkit/issues/1896
@@ -115,21 +123,21 @@ jobs:
115123
registry: ghcr.io
116124
username: ${{ github.repository_owner }}
117125
password: ${{ secrets.GITHUB_TOKEN }}
118-
- name: Compose release candidate metadata
119-
id: meta
126+
- name: Compose release candidate metadata - golang-with-libgit2-all
127+
id: meta_libgit2_all
120128
uses: docker/metadata-action@v3
121129
if: github.event_name != 'pull_request'
122130
with:
123131
images: |
124-
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2
132+
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2-all
125133
tags: |
126134
type=schedule
127135
type=ref,event=branch
128136
type=ref,event=tag
129137
type=sha
130138
type=sha,format=long
131-
- name: Release candidate image
132-
id: release_candidate
139+
- name: Release candidate image - golang-with-libgit2-all
140+
id: release_candidate_libgit2_all
133141
if: github.event_name != 'pull_request'
134142
uses: docker/build-push-action@v2
135143
with:
@@ -140,3 +148,29 @@ jobs:
140148
tags: ${{ steps.meta.outputs.tags }}
141149
labels: ${{ steps.meta.outputs.labels }}
142150
cache-from: type=local,src=/tmp/.buildx-cache
151+
152+
- name: Compose release candidate metadata - golang-with-libgit2-only
153+
id: meta_libgit2_only
154+
uses: docker/metadata-action@v3
155+
if: github.event_name != 'pull_request'
156+
with:
157+
images: |
158+
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2-only
159+
tags: |
160+
type=schedule
161+
type=ref,event=branch
162+
type=ref,event=tag
163+
type=sha
164+
type=sha,format=long
165+
- name: Release candidate image - golang-with-libgit2-only
166+
id: release_candidate_libgit2_only
167+
if: github.event_name != 'pull_request'
168+
uses: docker/build-push-action@v2
169+
with:
170+
context: .
171+
file: Dockerfile.libgit2-only
172+
platforms: ${{ env.PLATFORMS }}
173+
push: true
174+
tags: ${{ steps.meta.outputs.tags }}
175+
labels: ${{ steps.meta.outputs.labels }}
176+
cache-from: type=local,src=/tmp/.buildx-cache

.github/workflows/release.yaml

+91-27
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,52 @@ jobs:
4848
steps:
4949
- name: Checkout
5050
uses: actions/checkout@v2
51-
- name: Build static libraries
51+
- name: Build static libraries - libgit2 compiled with libssh2 and openssl
5252
run: |
5353
TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-linux \
5454
BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
5555
./hack/static.sh all
5656
57-
mkdir -p ./libgit2-linux/
58-
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/include ./libgit2-linux/
59-
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/share ./libgit2-linux/
60-
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/lib ./libgit2-linux/
61-
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/lib64 ./libgit2-linux/
57+
mkdir -p ./libgit2-linux-libgit2-all/
58+
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/include ./libgit2-linux-libgit2-all/
59+
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/share ./libgit2-linux-libgit2-all/
60+
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/lib ./libgit2-linux-libgit2-all/
61+
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/lib64 ./libgit2-linux-libgit2-all/
6262
63-
tar -zcvf linux-x86_64-libs.tar.gz libgit2-linux
63+
tar -zcvf linux-x86_64-libgit2-all-libs.tar.gz libgit2-linux-libgit2-all
64+
rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
6465
- name: Upload Release Asset
65-
id: upload-release-asset
66+
id: upload-release-asset-libgit2-all
6667
uses: actions/upload-release-asset@v1
6768
env:
6869
GITHUB_TOKEN: ${{ github.token }}
6970
with:
7071
upload_url: ${{ needs.github_release.outputs.release_upload_url }}
71-
asset_path: ./linux-x86_64-libs.tar.gz
72-
asset_name: linux-x86_64-libs.tar.gz
72+
asset_path: ./linux-x86_64-libgit2-all-libs.tar.gz
73+
asset_name: linux-x86_64-libgit2-all-libs.tar.gz
74+
asset_content_type: application/gzip
75+
76+
- name: Build static libraries - libgit2 only
77+
run: |
78+
TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-linux \
79+
BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
80+
./hack/static.sh build_libgit2_only
81+
82+
mkdir -p ./libgit2-linux-libgit2-only/
83+
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/include ./libgit2-linux-libgit2-only/
84+
mv ${GITHUB_WORKSPACE}/build/libgit2-linux/lib ./libgit2-linux-libgit2-only/
85+
86+
tar -zcvf linux-x86_64-libgit2-only-lib.tar.gz libgit2-linux-libgit2-only
87+
rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
88+
- name: Upload Release Asset
89+
id: upload-release-asset-libgit2-only
90+
uses: actions/upload-release-asset@v1
91+
env:
92+
GITHUB_TOKEN: ${{ github.token }}
93+
with:
94+
upload_url: ${{ needs.github_release.outputs.release_upload_url }}
95+
asset_path: ./linux-x86_64-libgit2-only-lib.tar.gz
96+
asset_name: linux-x86_64-libgit2-only-lib.tar.gz
7397
asset_content_type: application/gzip
7498

7599
darwin-release:
@@ -88,7 +112,7 @@ jobs:
88112
steps:
89113
- name: Checkout
90114
uses: actions/checkout@v2
91-
- name: Build universal static libraries for Darwin
115+
- name: Build universal static libraries for Darwin - libgit2 compiled with libssh2 and openssl
92116
run: |
93117
TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64 \
94118
BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
@@ -100,40 +124,80 @@ jobs:
100124
CMAKE_APPLE_SILICON_PROCESSOR=arm64 \
101125
./hack/static.sh all
102126
103-
mkdir -p ./libgit2-darwin/lib
104-
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./libgit2-darwin/
105-
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/share ./libgit2-darwin/
106-
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/cmake ./libgit2-darwin/lib/
107-
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/engines-3 ./libgit2-darwin/lib/
108-
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/ossl-modules ./libgit2-darwin/lib/
109-
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/pkgconfig ./libgit2-darwin/lib/
127+
mkdir -p ./libgit2-darwin-libgit2-all/lib
128+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./libgit2-darwin-libgit2-all/
129+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/share ./libgit2-darwin-libgit2-all/
130+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/cmake ./libgit2-darwin-libgt2-all/lib/
131+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/engines-3 ./libgit2-darwin-libgit2-all/lib/
132+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/ossl-modules ./libgit2-darwin-libgit2-all/lib/
133+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/pkgconfig ./libgit2-darwin-libgit2-all/lib/
110134
111-
libtool -static -o ./libgit2-darwin/lib/libcrypto.a \
135+
libtool -static -o ./libgit2-darwin-libgit2-all/lib/libcrypto.a \
112136
${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libcrypto.a \
113137
${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libcrypto.a
114-
libtool -static -o ./libgit2-darwin/lib/libgit2.a \
138+
139+
libtool -static -o ./libgit2-darwin-libgit2-all/lib/libgit2.a \
115140
${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libgit2.a \
116141
${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libgit2.a
117-
libtool -static -o ./libgit2-darwin/lib/libssh2.a \
142+
143+
libtool -static -o ./libgit2-darwin-libgit2-all/lib/libssh2.a \
118144
${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libssh2.a \
119145
${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libssh2.a
120-
libtool -static -o ./libgit2-darwin/lib/libssl.a \
146+
147+
libtool -static -o ./libgit2-darwin-libgit2-all/lib/libssl.a \
121148
${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libssl.a \
122149
${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libssl.a
123-
libtool -static -o ./libgit2-darwin/lib/libz.a \
150+
151+
libtool -static -o ./libgit2-darwin-libgit2-all/lib/libz.a \
124152
${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libz.a \
125153
${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libz.a
126154
127-
tar -zcvf darwin-libs.tar.gz libgit2-darwin
155+
tar -zcvf darwin-libgit2-all-libs.tar.gz libgit2-darwin-libgit2-all
156+
rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
157+
env:
158+
MACOSX_DEPLOYMENT_TARGET: 10.15
159+
- name: Upload Release Asset
160+
id: upload-release-asset-libgit2-all
161+
uses: actions/upload-release-asset@v1
162+
env:
163+
GITHUB_TOKEN: ${{ github.token }}
164+
with:
165+
upload_url: ${{ needs.github_release.outputs.release_upload_url }}
166+
asset_path: ./darwin-libgit2-all-libs.tar.gz
167+
asset_name: darwin-libgit2-all-libs.tar.gz
168+
asset_content_type: application/gzip
169+
170+
- name: Build universal static libraries for Darwin - libgit2 only
171+
run: |
172+
TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64 \
173+
BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/amd \
174+
./hack/static.sh build_libgit2_only
175+
176+
TARGET_DIR=${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64 \
177+
BUILD_ROOT_DIR=${GITHUB_WORKSPACE}/libgit2/build/arm \
178+
TARGET_ARCH=arm64 \
179+
CMAKE_APPLE_SILICON_PROCESSOR=arm64 \
180+
./hack/static.sh build_libgit2_only
181+
182+
mkdir -p ./libgit2-darwin-libgit2-only
183+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/include ./libgit2-darwin-libgit2-only/
184+
mv ${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib ./libgit2-darwin-libgit2-only/
185+
186+
libtool -static -o ./libgit2-darwin-libgit2-only/lib/libgit2.a \
187+
${GITHUB_WORKSPACE}/build/libgit2-darwin-amd64/lib/libgit2.a \
188+
${GITHUB_WORKSPACE}/build/libgit2-darwin-arm64/lib/libgit2.a
189+
190+
tar -zcvf darwin-libs-libgit2-only.tar.gz libgit2-darwin-libgit2-only
191+
rm -rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/libgit2
128192
env:
129193
MACOSX_DEPLOYMENT_TARGET: 10.15
130194
- name: Upload Release Asset
131-
id: upload-release-asset
195+
id: upload-release-asset-libgit2-only
132196
uses: actions/upload-release-asset@v1
133197
env:
134198
GITHUB_TOKEN: ${{ github.token }}
135199
with:
136200
upload_url: ${{ needs.github_release.outputs.release_upload_url }}
137-
asset_path: ./darwin-libs.tar.gz
138-
asset_name: darwin-libs.tar.gz
201+
asset_path: ./darwin-libs-libgit2-only.tar.gz
202+
asset_name: darwin-libs-libgit2-only.tar.gz
139203
asset_content_type: application/gzip

Dockerfile.libgit2-only

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This Dockerfile tests the hack/Makefile output against git2go.
2+
ARG BASE_VARIANT=alpine
3+
ARG GO_VERSION=1.17
4+
ARG XX_VERSION=1.1.0
5+
6+
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
7+
8+
FROM --platform=$BUILDPLATFORM ${BASE_VARIANT} AS build-base
9+
10+
RUN apk add --no-cache \
11+
bash \
12+
curl \
13+
build-base \
14+
linux-headers \
15+
perl \
16+
cmake \
17+
pkgconfig \
18+
gcc \
19+
musl-dev \
20+
clang \
21+
lld
22+
23+
COPY --from=xx / /
24+
25+
FROM build-base AS build-cross
26+
27+
ARG TARGETPLATFORM
28+
29+
RUN xx-apk add --no-cache \
30+
build-base \
31+
pkgconfig \
32+
gcc \
33+
musl-dev \
34+
clang \
35+
lld \
36+
llvm \
37+
linux-headers
38+
39+
WORKDIR /build
40+
COPY hack/static.sh .
41+
42+
ENV CC=xx-clang
43+
ENV CXX=xx-clang++
44+
45+
RUN ./static.sh build_libgit2_only
46+
47+
# trimmed removes all non necessary files (i.e. openssl binary).
48+
FROM build-cross AS trimmed
49+
50+
ARG TARGETPLATFORM
51+
RUN mkdir -p /trimmed/usr/local/$(xx-info triple)/ && \
52+
mkdir -p /trimmed/usr/local/$(xx-info triple)/share
53+
54+
RUN cp -r /usr/local/$(xx-info triple)/lib/ /trimmed/usr/local/$(xx-info triple)/ && \
55+
cp -r /usr/local/$(xx-info triple)/include/ /trimmed/usr/local/$(xx-info triple)/
56+
57+
FROM scratch as libs-arm64
58+
COPY --from=trimmed /trimmed/ /
59+
60+
FROM scratch as libs-amd64
61+
COPY --from=trimmed /trimmed/ /
62+
63+
FROM scratch as libs-armv7
64+
COPY --from=trimmed /trimmed/ /
65+
66+
FROM libs-$TARGETARCH$TARGETVARIANT as libs

Dockerfile.test

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ RUN export LIBRARY_PATH="/usr/local/$(xx-info triple)/lib:/usr/local/$(xx-info t
5757
RUN ./static.sh build_libssh2
5858
RUN ./static.sh build_libgit2
5959

60-
6160
# trimmed removes all non necessary files (i.e. openssl binary).
6261
FROM build-cross AS trimmed
6362

0 commit comments

Comments
 (0)