Skip to content

Commit

Permalink
Merge pull request #18 from manuelbuil/github_release
Browse files Browse the repository at this point in the history
Add release github action
  • Loading branch information
manuelbuil authored Oct 20, 2021
2 parents 2d5ad4b + ba6878b commit fb66800
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/buildTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
for arch in ${LINUX_ARCHES}; do
echo "Building for arch $arch"
ARCH=$arch make build_linux
file bin/flannel-$arch
rm bin/*
file dist/flannel-$arch
rm dist/*
done
- name: build windows
Expand Down
165 changes: 165 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
on:
release:
types: [published]

env:
GO_VERSION: "1.15.15"
LINUX_ARCHES: "amd64 386 arm arm64 s390x mips64le ppc64le"
REPOSITORY: flannelcni/flannel-cni-plugin

jobs:
build-and-push-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: go mod vendor
run: go mod vendor

- name: build linux
run: |
set -e
for arch in ${LINUX_ARCHES}; do
echo "Building for arch $arch"
ARCH=$arch make build_linux
file dist/flannel-$arch
done
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REPOSITORY }}
flavor: latest=false
tags: |
type=ref,event=tag
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image for amd64
if: github.repository_owner == 'flannelcni'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.amd64
push: true
tags: ${{ steps.meta.outputs.tags }}-amd64

- name: Build and push Docker image for arm
if: github.repository_owner == 'flannelcni'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.arm
push: true
tags: ${{ steps.meta.outputs.tags }}-arm

- name: Build and push Docker image for arm64
if: github.repository_owner == 'flannelcni'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.arm64
push: true
tags: ${{ steps.meta.outputs.tags }}-arm64

- name: Build and push Docker image for s390x
if: github.repository_owner == 'flannelcni'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.s390x
push: true
tags: ${{ steps.meta.outputs.tags }}-s390x

- name: Build and push Docker image for ppc64le
if: github.repository_owner == 'flannelcni'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.ppc64le
push: true
tags: ${{ steps.meta.outputs.tags }}-ppc64le

build-and-push-multi-arch-image:
needs: [build-and-push-images]
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: go mod vendor
run: go mod vendor

- name: build linux
run: |
set -e
for arch in ${LINUX_ARCHES}; do
echo "Building for arch $arch"
ARCH=$arch make build_linux
file dist/flannel-$arch
done
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REPOSITORY }}
flavor: latest=false
tags: |
type=ref,event=tag
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create manifest for multi-arch image
if: github.repository_owner == 'flannelcni'
run: |
# get artifacts from previous steps and integrate into one multi-arch manifest
docker pull ${{ steps.meta.outputs.tags }}-amd64
docker pull ${{ steps.meta.outputs.tags }}-arm64
docker pull ${{ steps.meta.outputs.tags }}-arm
docker pull ${{ steps.meta.outputs.tags }}-ppc64le
docker pull ${{ steps.meta.outputs.tags }}-s390x
docker manifest create ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-amd64 ${{ steps.meta.outputs.tags }}-arm64 ${{ steps.meta.outputs.tags }}-arm ${{ steps.meta.outputs.tags }}-ppc64le ${{ steps.meta.outputs.tags }}-s390x
docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-amd64 --arch amd64
docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-arm64 --arch arm64
docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-arm --arch arm
docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-ppc64le --arch ppc64le
docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-s390x --arch s390x
docker manifest push ${{ steps.meta.outputs.tags }}
6 changes: 3 additions & 3 deletions scripts/build_flannel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export GOOS="${GOOS:-linux}"
export GOARCH="${GOARCH:-amd64}"
export GOFLAGS="${GOFLAGS} -mod=vendor"

mkdir -p "${PWD}/bin"
mkdir -p "${PWD}/dist"

echo "Building flannel for ${GOOS} in ${GOARCH}"

if [ "$GOOS" == "linux" ]; then
go build -o "${PWD}/bin/flannel-${GOARCH}" "$@" .
go build -o "${PWD}/dist/flannel-${GOARCH}" "$@" .
else
go build -o "${PWD}/bin/flannel.exe" "$@" .
go build -o "${PWD}/dist/flannel.exe" "$@" .
fi
4 changes: 2 additions & 2 deletions scripts/test_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ make build_linux
echo "Running tests"

function download_cnis {
pushd bin/
pushd dist/
curl -L https://github.com/containernetworking/plugins/releases/download/$CNI_VERSION/cni-plugins-linux-amd64-$CNI_VERSION.tgz | tar -xz
popd
}

function testrun {
download_cnis
sudo -E bash -c "umask 0; PATH=${GOPATH}/bin:$(pwd)/bin:${PATH} go test $@"
sudo -E bash -c "umask 0; PATH=${GOPATH}/dist:$(pwd)/dist:${PATH} go test $@"
}

COVERALLS=${COVERALLS:-""}
Expand Down

0 comments on commit fb66800

Please sign in to comment.