Skip to content

Commit bdc018f

Browse files
authoredFeb 10, 2021
Merge pull request #260 from ktock/xcompile
2 parents b6c9974 + f40f6be commit bdc018f

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed
 

‎.github/workflows/release.yml

+35-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ env:
1010
jobs:
1111
build:
1212
runs-on: ubuntu-20.04
13-
name: Release
13+
name: Build
14+
strategy:
15+
matrix:
16+
arch: ["amd64", "arm-v7", "arm64", "ppc64le", "s390x"]
1417
env:
1518
OUTPUT_DIR: ${{ github.workspace }}/out
1619
steps:
@@ -21,10 +24,33 @@ jobs:
2124
run: |
2225
mkdir ${OUTPUT_DIR}
2326
RELEASE_TAG="${GITHUB_REF##*/}"
24-
TAR_FILE_NAME="stargz-snapshotter-${RELEASE_TAG}-linux-amd64.tar.gz"
27+
ARCH_ID="${{ matrix.arch }}"
28+
BUILD_ARGS=--build-arg=TARGETARCH=${ARCH_ID}
29+
if [ "${ARCH_ID}" == "arm-v7" ] ; then
30+
BUILD_ARGS="--build-arg=TARGETARCH=arm --build-arg=GOARM=7"
31+
fi
32+
TAR_FILE_NAME="stargz-snapshotter-${RELEASE_TAG}-linux-${ARCH_ID}.tar.gz"
2533
SHA256SUM_FILE_NAME="${TAR_FILE_NAME}.sha256sum"
26-
docker build --target release-binaries -o - . | gzip > "${OUTPUT_DIR}/${TAR_FILE_NAME}"
34+
docker build ${BUILD_ARGS} --target release-binaries -o - . | gzip > "${OUTPUT_DIR}/${TAR_FILE_NAME}"
2735
( cd ${OUTPUT_DIR}; sha256sum ${TAR_FILE_NAME} ) > "${OUTPUT_DIR}/${SHA256SUM_FILE_NAME}"
36+
- name: Save Binary
37+
uses: actions/upload-artifact@v2
38+
with:
39+
name: builds-${{ matrix.arch }}
40+
path: ${{ env.OUTPUT_DIR }}/*
41+
42+
release:
43+
runs-on: ubuntu-20.04
44+
name: Release
45+
needs: [build]
46+
env:
47+
OUTPUT_DIR: ${{ github.workspace }}/builds
48+
steps:
49+
- uses: actions/checkout@v2
50+
- name: Download Builds
51+
uses: actions/download-artifact@v2
52+
with:
53+
path: ${{ env.OUTPUT_DIR }}
2854
- name: Create Release
2955
env:
3056
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -36,5 +62,10 @@ jobs:
3662
(TBD)
3763
EOF
3864
ASSET_FLAGS=()
39-
for F in ${OUTPUT_DIR}/*; do ASSET_FLAGS+=("-a" "$F"); done
65+
ls -al ${OUTPUT_DIR}/
66+
for A in "amd64" "arm-v7" "arm64" "ppc64le" "s390x" ; do
67+
for F in ${OUTPUT_DIR}/builds-${A}/* ; do
68+
ASSET_FLAGS+=("-a" "$F")
69+
done
70+
done
4071
hub release create "${ASSET_FLAGS[@]}" -F ${GITHUB_WORKSPACE}/release-note.txt --draft "${RELEASE_TAG}"

‎Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ RUN apt-get update -y && apt-get install -y libseccomp-dev && \
4141

4242
# Build stargz snapshotter
4343
FROM golang-base AS snapshotter-dev
44+
ARG TARGETARCH
45+
ARG GOARM
4446
ARG SNAPSHOTTER_BUILD_FLAGS
4547
ARG CTR_REMOTE_BUILD_FLAGS
4648
COPY . $GOPATH/src/github.com/containerd/stargz-snapshotter
4749
RUN cd $GOPATH/src/github.com/containerd/stargz-snapshotter && \
48-
PREFIX=/out/ GO_BUILD_FLAGS=${SNAPSHOTTER_BUILD_FLAGS} make containerd-stargz-grpc && \
49-
PREFIX=/out/ GO_BUILD_FLAGS=${CTR_REMOTE_BUILD_FLAGS} make ctr-remote
50+
PREFIX=/out/ GOARCH=${TARGETARCH} GO_BUILD_FLAGS=${SNAPSHOTTER_BUILD_FLAGS} make containerd-stargz-grpc && \
51+
PREFIX=/out/ GOARCH=${TARGETARCH} GO_BUILD_FLAGS=${CTR_REMOTE_BUILD_FLAGS} make ctr-remote
5052

5153
# Binaries for release
5254
FROM scratch AS release-binaries

0 commit comments

Comments
 (0)
Please sign in to comment.