release flannel and upload docker images #31
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
release: | |
types: [published] | |
env: | |
GO_VERSION: "1.19" | |
LINUX_ARCHES: "amd64 arm arm64 s390x ppc64le mips64le" | |
REPOSITORY: flannel/flannel | |
jobs: | |
build-and-push-images: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v3 | |
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 dist/flanneld-$arch | |
file dist/flanneld-$arch | |
done | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REPOSITORY }} | |
flavor: latest=false | |
tags: | | |
type=ref,event=tag | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image for amd64 | |
if: github.repository_owner == 'flannel-io' | |
run: | | |
docker build -f images/Dockerfile.amd64 -t ${{ steps.meta.outputs.tags }}-amd64 . | |
docker push ${{ steps.meta.outputs.tags }}-amd64 | |
- name: Build and push Docker image for arm | |
if: github.repository_owner == 'flannel-io' | |
run: | | |
docker build -f images/Dockerfile.arm -t ${{ steps.meta.outputs.tags }}-arm . | |
docker push ${{ steps.meta.outputs.tags }}-arm | |
- name: Build and push Docker image for arm64 | |
if: github.repository_owner == 'flannel-io' | |
run: | | |
docker build -f images/Dockerfile.arm64 -t ${{ steps.meta.outputs.tags }}-arm64 . | |
docker push ${{ steps.meta.outputs.tags }}-arm64 | |
- name: Build and push Docker image for s390x | |
if: github.repository_owner == 'flannel-io' | |
run: | | |
docker build -f images/Dockerfile.s390x -t ${{ steps.meta.outputs.tags }}-s390x . | |
docker push ${{ steps.meta.outputs.tags }}-s390x | |
- name: Build and push Docker image for ppc64le | |
if: github.repository_owner == 'flannel-io' | |
run: | | |
docker build -f images/Dockerfile.ppc64le -t ${{ steps.meta.outputs.tags }}-ppc64le . | |
docker push ${{ steps.meta.outputs.tags }}-ppc64le | |
- name: Build and push Docker image for mips64le | |
if: github.repository_owner == 'flannel-io' | |
run: | | |
docker build -f images/Dockerfile.mips64le -t ${{ steps.meta.outputs.tags }}-mips64le . | |
docker push ${{ steps.meta.outputs.tags }}-mips64le | |
build-and-push-multi-arch-image: | |
needs: [build-and-push-images] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v3 | |
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 dist/flanneld-$arch | |
file dist/flanneld-$arch | |
done | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REPOSITORY }} | |
flavor: latest=false | |
tags: | | |
type=ref,event=tag | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create and push manifest for multi-arch image | |
if: github.repository_owner == 'flannel-io' | |
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 pull ${{ steps.meta.outputs.tags }}-mips64le | |
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 ${{ steps.meta.outputs.tags }}-mips64le | |
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 annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-mips64le --arch mips64le | |
docker manifest push ${{ steps.meta.outputs.tags }} | |
docker pull ${{ steps.meta.outputs.tags }} | |
docker tag ${{ steps.meta.outputs.tags }} ${{ env.REPOSITORY }}:latest | |
docker push ${{ env.REPOSITORY }}:latest | |
build-and-push-artifacts: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
pages: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: go mod vendor | |
run: go mod vendor | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Build release artifacts | |
run: make release | |
- name: Upload release files | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
dist/flannel* | |
dist/kube-flannel.yml | |
dist/kube-flannel-psp.yml | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: 'chart/' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |