Skip to content

Commit 3e83c96

Browse files
authored
Merge pull request #119 from fluxcd/arm-v7
Publish ARM v7/v8 multi-arch image to GHCR
2 parents e9e9719 + b178534 commit 3e83c96

File tree

2 files changed

+51
-26
lines changed

2 files changed

+51
-26
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- name: Setup Kustomize
1313
uses: fluxcd/pkg/actions/kustomize@master
14-
- name: Get version
15-
id: get_version
16-
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
17-
- name: Generate release asset
14+
- name: Prepare
15+
id: prep
1816
run: |
19-
mkdir -p config/release
20-
cp config/default/* config/release
21-
cd config/release
22-
kustomize edit set image fluxcd/kustomize-controller=fluxcd/kustomize-controller:${{ steps.get_version.outputs.VERSION }}
23-
kustomize build . > kustomize-controller.yaml
24-
- name: Set up QEMU
17+
VERSION=sha-${GITHUB_SHA::8}
18+
if [[ $GITHUB_REF == refs/tags/* ]]; then
19+
VERSION=${GITHUB_REF/refs\/tags\//}
20+
fi
21+
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
22+
echo ::set-output name=VERSION::${VERSION}
23+
- name: Setup QEMU
2524
uses: docker/setup-qemu-action@v1
2625
with:
2726
platforms: all
28-
- name: Set up Docker Buildx
27+
- name: Setup Docker Buildx
2928
id: buildx
3029
uses: docker/setup-buildx-action@v1
3130
with:
@@ -41,35 +40,58 @@ jobs:
4140
with:
4241
username: fluxcdbot
4342
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
44-
- name: Publish amd64 image
43+
- name: Publish AMD64 image
4544
uses: docker/build-push-action@v2
4645
with:
47-
push: ${{ github.event_name != 'pull_request' }}
46+
push: true
4847
builder: ${{ steps.buildx.outputs.name }}
4948
context: .
5049
file: ./Dockerfile
5150
platforms: linux/amd64
5251
tags: |
53-
ghcr.io/fluxcd/kustomize-controller:${{ steps.get_version.outputs.VERSION }}
54-
docker.io/fluxcd/kustomize-controller:${{ steps.get_version.outputs.VERSION }}
55-
- name: Publish arm64 image
52+
ghcr.io/fluxcd/kustomize-controller:${{ steps.prep.outputs.VERSION }}
53+
docker.io/fluxcd/kustomize-controller:${{ steps.prep.outputs.VERSION }}
54+
labels: |
55+
org.opencontainers.image.title=${{ github.event.repository.name }}
56+
org.opencontainers.image.description=${{ github.event.repository.description }}
57+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
58+
org.opencontainers.image.revision=${{ github.sha }}
59+
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
60+
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}
61+
- name: Publish ARM image
5662
uses: docker/build-push-action@v2
5763
with:
58-
push: ${{ github.event_name != 'pull_request' }}
64+
push: true
5965
builder: ${{ steps.buildx.outputs.name }}
6066
context: .
6167
file: ./Dockerfile
62-
platforms: linux/arm64
63-
tags: ghcr.io/fluxcd/kustomize-controller-arm64:${{ steps.get_version.outputs.VERSION }}
68+
platforms: linux/arm/v7,linux/arm64
69+
tags: |
70+
ghcr.io/fluxcd/kustomize-controller-arm64:${{ steps.prep.outputs.VERSION }}
71+
labels: |
72+
org.opencontainers.image.title=${{ github.event.repository.name }}
73+
org.opencontainers.image.description=${{ github.event.repository.description }}
74+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
75+
org.opencontainers.image.revision=${{ github.sha }}
76+
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
77+
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}
6478
- name: Check images
6579
run: |
66-
docker buildx imagetools inspect docker.io/fluxcd/kustomize-controller:${{ steps.get_version.outputs.VERSION }}
67-
docker buildx imagetools inspect ghcr.io/fluxcd/kustomize-controller:${{ steps.get_version.outputs.VERSION }}
68-
docker buildx imagetools inspect ghcr.io/fluxcd/kustomize-controller-arm64:${{ steps.get_version.outputs.VERSION }}
69-
docker pull docker.io/fluxcd/kustomize-controller:${{ steps.get_version.outputs.VERSION }}
70-
docker pull ghcr.io/fluxcd/kustomize-controller:${{ steps.get_version.outputs.VERSION }}
71-
docker pull ghcr.io/fluxcd/kustomize-controller-arm64:${{ steps.get_version.outputs.VERSION }}
80+
docker buildx imagetools inspect docker.io/fluxcd/kustomize-controller:${{ steps.prep.outputs.VERSION }}
81+
docker buildx imagetools inspect ghcr.io/fluxcd/kustomize-controller:${{ steps.prep.outputs.VERSION }}
82+
docker buildx imagetools inspect ghcr.io/fluxcd/kustomize-controller-arm64:${{ steps.prep.outputs.VERSION }}
83+
docker pull docker.io/fluxcd/kustomize-controller:${{ steps.prep.outputs.VERSION }}
84+
docker pull ghcr.io/fluxcd/kustomize-controller:${{ steps.prep.outputs.VERSION }}
85+
- name: Generate release asset
86+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
87+
run: |
88+
mkdir -p config/release
89+
cp config/default/* config/release
90+
cd config/release
91+
kustomize edit set image fluxcd/kustomize-controller=fluxcd/kustomize-controller:${{ steps.prep.outputs.VERSION }}
92+
kustomize build . > kustomize-controller.yaml
7293
- name: Create release
94+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
7395
id: create_release
7496
uses: actions/create-release@latest
7597
env:
@@ -82,6 +104,7 @@ jobs:
82104
body: |
83105
[CHANGELOG](https://github.com/fluxcd/kustomize-controller/blob/master/CHANGELOG.md)
84106
- name: Upload artifacts
107+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
85108
id: upload-release-asset
86109
uses: actions/upload-release-asset@v1
87110
env:

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ WORKDIR /workspace
66

77
RUN apk add --no-cache ca-certificates curl
88

9-
RUN arch=${TARGETPLATFORM:-linux/amd64} && kubectl_ver=1.19.0 && \
9+
RUN kubectl_ver=1.19.2 && \
10+
arch=${TARGETPLATFORM:-linux/amd64} && \
11+
if [ "$TARGETPLATFORM" == "linux/arm/v7" ]; then arch="linux/arm"; fi && \
1012
curl -sL https://storage.googleapis.com/kubernetes-release/release/v${kubectl_ver}/bin/${arch}/kubectl \
1113
-o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl
1214

0 commit comments

Comments
 (0)