Skip to content

Commit

Permalink
Go1.21.0 (#691)
Browse files Browse the repository at this point in the history
* Update Go 1.21.0

* Add docker build actions

* Add docker build actions

* Add docker build actions

* Add docker build actions

* Add docker build actions
  • Loading branch information
robbydyer authored Aug 22, 2023
1 parent 5ca6d7a commit 287d7ae
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 30 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/dockerbuild-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Linter Image
on:
pull_request:
paths:
- Dockerfile.lint

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all

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

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: get sha256
id: sha
run: echo "sha=$(sha256sum Dockerfile.lint | awk '{print $1}')" >> $GITHUB_OUTPUT

- name: build linter
uses: docker/build-push-action@v4
with:
push: true
file: Dockerfile.lint
tags: robbydyer/rgbmatrixlint:${{steps.sha.outputs.sha}}
platforms: linux/amd64,linux/arm64/v8
39 changes: 39 additions & 0 deletions .github/workflows/dockerbuild-protoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Protoc Image
on:
pull_request:
paths:
- Dockerfile.protoc

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all

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

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: get sha256
id: sha
run: echo "sha=$(sha256sum Dockerfile.protoc | awk '{print $1}')" >> $GITHUB_OUTPUT

- name: build linter
uses: docker/build-push-action@v4
with:
push: true
file: Dockerfile.protoc
tags: robbydyer/protoc:${{steps.sha.outputs.sha}},robbydyer/protoc:latest
platforms: linux/amd64,linux/arm64/v8
57 changes: 57 additions & 0 deletions .github/workflows/dockerbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build Docker Images
on:
pull_request:
paths:
- Dockerfile.pibuilder

jobs:
build:
strategy:
matrix:
arch:
- aarch64
- armv7l
- amd64
os:
- bullseye
- buster
include:
- arch: aarch64
base: arm64
- arch: armv7l
base: armhf
- arch: amd64
base: amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all

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

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: get sha256
id: sha
run: echo "sha=$(sha256sum Dockerfile.pibuilder | awk '{print $1}')" >> $GITHUB_OUTPUT

- name: Build ${{matrix.arch}}
uses: docker/build-push-action@v4
with:
push: true
file: Dockerfile.pibuilder
tags: robbydyer/pibuilder-${{matrix.arch}}-${{matrix.os}}:${{steps.sha.outputs.sha}}
build-args: |
BASE=multiarch/debian-debootstrap:${{matrix.base}}-${{matrix.os}}-slim
platforms: linux/amd64,linux/arm64/v8
11 changes: 11 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ name: Go
on:
pull_request:
branches: [ master ]
paths:
- 'cmd/**'
- 'internal/**'
- 'vendor/**'
- go.mod
- go.sum
- 'web/**'
- 'proto/**'
- 'pkg/**'
- 'Dockerfile.pibuilder'
- 'Dockerfile.lint'

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.lint
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ COPY ./internal/rgbmatrix-rpi/lib/rpi-rgb-led-matrix.BASE /tmp/rpi-rgb-led-matri
RUN cd /tmp/rpi-rgb-led-matrix && \
make

FROM golangci/golangci-lint:v1.52.2
FROM golangci/golangci-lint:v1.54.2

COPY --from=builder /tmp/rpi-rgb-led-matrix /sportslibs/rpi-rgb-led-matrix
11 changes: 3 additions & 8 deletions Dockerfile.pibuilder
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 2023-05 10:11
# 2023-05-26 16:16
ARG BASE=multiarch/debian-debootstrap:arm64-bullseye-slim

FROM $BASE
# Replace shell with bash so we can source files
SHELL ["/bin/bash", "--login", "-ce"]

ARG GOVERSION=1.20.4
ARG GOVERSION=1.21.0

RUN apt-get update && \
apt-get install -y \
Expand All @@ -16,6 +16,7 @@ RUN apt-get update && \
gcc \
git \
g++ \
python3 \
rsync

RUN update-ca-certificates -f
Expand All @@ -37,12 +38,6 @@ COPY .nvmrc /root/.nvmrc
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
RUN cd /root && nvm install

RUN mkdir -p /src/internal/rgbmatrix-rpi/lib /src/web
COPY ./web /src/web
RUN cd /src/web && \
npm install


COPY ./internal/rgbmatrix-rpi/lib/rpi-rgb-led-matrix.BASE /sportsmatrix_lib/rpi-rgb-led-matrix

RUN cd /sportsmatrix_lib/rpi-rgb-led-matrix && \
Expand Down
5 changes: 3 additions & 2 deletions script/common
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

ROOT="$(dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ))"
DOCKERCONF="${ROOT}/.dockerconfig"
GO_VERSION="1.20.4"
GO_VERSION="1.21.0"

getsha() {
if uname -s | grep -i darwin &> /dev/null; then
Expand All @@ -15,6 +15,7 @@ getsha() {

latestpibuilder() {
arch="$1"
buildos="${2:-bullseye}"
case "${arch}" in
amd64|x86_64)
arch=amd64
Expand All @@ -25,7 +26,7 @@ latestpibuilder() {
*)
;;
esac
echo "robbydyer/pibuilder-${arch}:$(getsha "${ROOT}/Dockerfile.pibuilder")"
echo "robbydyer/pibuilder-${arch}-${buildos}:$(getsha "${ROOT}/Dockerfile.pibuilder")"
}

latestlinter() {
Expand Down
20 changes: 1 addition & 19 deletions script/update-go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ROOT="$(dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ))"
cd "${ROOT}"

go_ver="$(curl -L https://golang.org/VERSION?m=text | sed 's,go,,g')"
go_ver="$(curl -L https://golang.org/VERSION?m=text | head -1 | sed 's,go,,g')"
lint_ver="$(curl https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name)"

echo "Updating Go to ${go_ver}, Linter ${lint_ver}"
Expand All @@ -12,21 +12,3 @@ gsed -i "s,GOVERSION=.*,GOVERSION=${go_ver},g" Dockerfile.pibuilder
gsed -i "s,golang:[^\s]* ,golang:${go_ver} ," Dockerfile.protoc
gsed -i "s,GO_VERSION=.*,GO_VERSION=\"${go_ver}\",g" script/common
gsed -i "s,golangci/golangci-lint:.*,golangci/golangci-lint:${lint_ver},g" Dockerfile.lint

if ! git diff --exit-code Dockerfile.pibuilder; then
script/build-builder
else
echo "No go version change detected"
fi

if ! git diff --exit-code Dockerfile.lint; then
script/build-linter
else
echo "No linter version change detected"
fi

if ! git diff --exit-code Dockerfile.protoc; then
script/proto-gen
else
echo "No go version change detected for protoc"
fi

0 comments on commit 287d7ae

Please sign in to comment.