Skip to content

Commit

Permalink
Publish arm64 binaries for linux/mac
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesoconor committed Feb 15, 2024
1 parent edb940e commit b406e4f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 31 deletions.
92 changes: 65 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ jobs:
name: bin

- name: Set permissions to file
run: chmod +x linux/kube-linter
run: chmod +x linux/amd64/kube-linter

- name: Print kube-linter version
run: linux/kube-linter version
run: linux/amd64/kube-linter version

- name: Run kube-linter on a sample file with SARIF output
run: linux/kube-linter lint --format=sarif tests/testdata/splunk.yaml > results.sarif
run: linux/amd64/kube-linter lint --format=sarif tests/testdata/splunk.yaml > results.sarif
continue-on-error: true

- name: Dump output file and check it is not empty
Expand Down Expand Up @@ -141,13 +141,13 @@ jobs:
run: |
# In Windows, the workspace is attached relative to the current directory.
tag="$(./get-tag)"
version_from_bin="$(tmp/windows/kube-linter.exe version)"
version_from_bin="$(tmp/windows/amd64/kube-linter.exe version)"
echo "Expected tag ${tag}, got ${version_from_bin}"
[[ "${tag}" == "${version_from_bin}" ]]
# Make sure the lint command can run without errors.
# TODO: run the full suite of E2E tests on Windows.
tmp/windows/kube-linter.exe lint "tests/checks/access-to-create-pods.yml"
tmp/windows/amd64/kube-linter.exe lint "tests/checks/access-to-create-pods.yml"
image:
if: (github.ref == 'refs/heads/main') || (startsWith(github.ref, 'refs/tags/'))
Expand All @@ -168,10 +168,10 @@ jobs:
name: bin

- name: Set permissions to file
run: chmod +x linux/kube-linter
run: chmod +x linux/amd64/kube-linter

- name: Move binary
run: mv linux/kube-linter image/bin
run: mv linux/amd64/kube-linter image/bin

- name: Print kube-linter version
run: image/bin/kube-linter version
Expand Down Expand Up @@ -297,14 +297,18 @@ jobs:

- name: Set permissions to files
run: |
chmod +x linux/kube-linter
chmod +x darwin/kube-linter
chmod +x linux/amd64/kube-linter
chmod +x linux/arm64/kube-linter
chmod +x darwin/amd64/kube-linter
chmod +x darwin/arm64/kube-linter
- name: copy binaries with OS ending
run: |
bin_name="kube-linter"
for os in darwin linux; do
bin_name="kube-linter"
cp "${os}/${bin_name}" "${os}/${bin_name}-${os}"
for arch in amd64 arm64; do
cp "${os}/${arch}/${bin_name}" "${os}/${bin_name}-${os}-${arch}"
done
done
- name: create linux tar archive
Expand All @@ -323,11 +327,13 @@ jobs:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
run: |
for os in darwin linux windows; do
bin_name="kube-linter-${os}"
if [[ "${os}" == "windows" ]]; then
bin_name="kube-linter.exe"
fi
cosign sign-blob --yes --key cosign.key --output-file "${bin_name}.sig" "${os}/${bin_name}"
for arch in amd64 arm64;
bin_name="kube-linter-${os}-${arch}"
if [[ "${os}" == "windows" ]]; then
bin_name="kube-linter-${arch}.exe"
fi
cosign sign-blob --yes --key cosign.key --output-file "${bin_name}.sig" "${os}/${bin_name}"
done
done
for f in *.{gz,zip}; do \
cosign sign-blob --yes --key cosign.key --output-file "${f}.sig" "${f}"; \
Expand All @@ -337,28 +343,49 @@ jobs:
id: release_drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Binary Linux
id: upload-binary-linux
- name: Upload Binary Linux Amd64
id: upload-binary-linux-amd64
uses: gfreezy/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.release_drafter.outputs.id }}
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: linux/kube-linter-linux
asset_name: kube-linter-linux
asset_path: linux/amd64/kube-linter-linux-amd64
asset_name: kube-linter-linux-amd64
asset_content_type: application/octet-stream
- name: Upload Binary Darwin
id: upload-binary-darwin
- name: Upload Binary Linux Arm64
id: upload-binary-linux-arm64
uses: gfreezy/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.release_drafter.outputs.id }}
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: darwin/kube-linter-darwin
asset_name: kube-linter-darwin
asset_path: linux/arm64/kube-linter-linux-arm64
asset_name: kube-linter-linux-arm64
asset_content_type: application/octet-stream
- name: Upload Binary Darwin Amd64
id: upload-binary-darwin-amd64
uses: gfreezy/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.release_drafter.outputs.id }}
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: darwin/amd64/kube-linter-darwin-amd64
asset_name: kube-linter-darwin-amd64
asset_content_type: application/octet-stream
- name: Upload Binary Darwin Arm64
id: upload-binary-darwin-arm64
uses: gfreezy/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.release_drafter.outputs.id }}
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: darwin/arm64/kube-linter-darwin-arm64
asset_name: kube-linter-darwin-arm64
- name: Upload Binary Windows
id: upload-binary-windows
uses: gfreezy/upload-release-asset@v1.0.2
Expand Down Expand Up @@ -408,16 +435,27 @@ jobs:
asset_path: kube-linter-darwin.sig
asset_name: kube-linter-darwin.sig
asset_content_type: application/octet-stream
- name: Upload Binary Sig Windows
- name: Upload Binary Sig Windows Amd64
id: upload-binary-sig-windows
uses: gfreezy/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.release_drafter.outputs.id }}
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: kube-linter-amd64.exe.sig
asset_name: kube-linter-amd64.exe.sig
asset_content_type: application/octet-stream
- name: Upload Binary Sig Windows Arm64
id: upload-binary-sig-windows
uses: gfreezy/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.release_drafter.outputs.id }}
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: kube-linter.exe.sig
asset_name: kube-linter.exe.sig
asset_path: kube-linter-arm64.exe.sig
asset_name: kube-linter-arm64.exe.sig
asset_content_type: application/octet-stream
- name: Upload sig source code zip
id: upload-release-asset-source-zip-sig
Expand Down
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ifeq ($(UNAME_S),Darwin)
HOST_OS := darwin
endif

ARCH := $(shell go env GOARCH)

TAG := $(shell ./get-tag)

GOBIN := $(CURDIR)/.gobin
Expand Down Expand Up @@ -81,11 +83,14 @@ generated-srcs: go-generated-srcs generated-docs

.PHONY: build
build: source-code-archive
@CGO_ENABLED=0 GOOS=darwin scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOOS=linux scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOOS=windows scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOARCH=arm64 GOOS=darwin scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOARCH=amd64 GOOS=linux scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOARCH=arm64 GOOS=linux scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOARCH=amd64 GOOS=windows scripts/go-build.sh ./cmd/kube-linter
@CGO_ENABLED=0 GOARCH=arm64 GOOS=windows scripts/go-build.sh ./cmd/kube-linter
@mkdir -p "$(GOBIN)"
@cp "bin/$(HOST_OS)/kube-linter" "$(GOBIN)/kube-linter"
@cp "bin/$(HOST_OS)/$(ARCH)/kube-linter" "$(GOBIN)/kube-linter"
@chmod u+w "$(GOBIN)/kube-linter"

$(KUBE_LINTER_BIN):
Expand Down

0 comments on commit b406e4f

Please sign in to comment.