Skip to content

Commit

Permalink
several updates for the release
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Oct 23, 2021
1 parent 08fd379 commit a3e3810
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 36 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Get Repo Owner
id: get_repo_owner
Expand All @@ -31,9 +35,22 @@ jobs:
username: ${{ steps.get_repo_owner.outputs.repo_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
uses: docker/build-push-action@v2.7.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: ${{ github.event_name != 'pull_request' }}
with:
version: latest
args: release --rm-dist --snapshot --skip-sign
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: ${{ github.event_name == 'pull_request' }}
with:
platforms: linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/fan-control:main
version: latest
args: release --rm-dist --snapshot --skip-publish --skip-sign
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
28 changes: 14 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ on:
- created

jobs:
build:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: sigstore/cosign-installer@v1.2.1
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: sigstore/cosign-installer@v1.2.0

- name: Get Repo Owner
id: get_repo_owner
Expand All @@ -35,17 +41,11 @@ jobs:
username: ${{ steps.get_repo_owner.outputs.repo_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
uses: docker/build-push-action@v2.7.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
platforms: linux/arm/v7
push: true
tags: ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/fan-control:${{ steps.get_tag.outputs.release_tag }}

- name: Sign the images
run: |
cosign sign -key=cosign.key ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/fan-control:${{ steps.get_tag.outputs.release_tag }}
docker logout
shell: bash
version: latest
args: release --rm-dist
env:
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
out/
dist/
62 changes: 62 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
project_name: raspi-fan-control

env:
- GO111MODULE=on

before:
hooks:
- go mod tidy

builds:
- id: fan
goos:
- linux
goarch:
- arm
goarm:
- 7
env:
- CGO_ENABLED=0

signs:
- id: fan
signature: "${artifact}.sig"
cmd: cosign
args: ["sign-blob", "--output", "${artifact}.sig", "--key", "./cosign.key", "${artifact}"]
artifacts: binary

dockers:
- id: fan
image_templates:
- "ghcr.io/cpanato/fan-control:{{ .Version }}"
use: buildx
dockerfile: Dockerfile
goos: linux
goarch: arm
goarm: 7
build_flag_templates:
- "--platform=linux/arm/7"

docker_signs:
- artifacts: all
args: [ "sign", "--key", "./cosign.key", "${artifact}" ]

archives:
- format: binary

checksum:
name_template: "{{ .ProjectName }}_checksums.txt"

snapshot:
name_template: SNAPSHOT-{{ .ShortCommit }}

release:
prerelease: allow # remove this when we start publishing non-prerelease or set to auto
draft: true # allow for manual edits
github:
owner: cpanato
name: raspi-fan-control
footer: |
**Image available**: ghcr.io/cpanato/fan-control:{{ .Version }}
extra_files:
- glob: "./cosign.pub"
16 changes: 4 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
FROM golang:1.17 AS build_base
FROM gcr.io/distroless/base:debug

WORKDIR /tmp/fan
COPY raspi-fan-control /bin/raspi-fan-control

COPY . .
USER nobody

RUN GOOS=linux GOARCH=arm GOARM=7 go build -o ./out/fan .

FROM alpine:3.13

RUN apk add ca-certificates

COPY --from=build_base /tmp/fan/out/fan /app/fan

ENTRYPOINT ["/app/fan"]
ENTRYPOINT [ "/bin/raspi-fan-control" ]
2 changes: 1 addition & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func handleFan() error {

tempGauge.Set(temp)

if temp >= 40 {
if temp >= 50 {
log.Printf("Temp is above the threshold. Actual temperature: %f, turning on the fan\n", temp)
pin.High()
fanGauge.Set(1)
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/cpanato/temp/go-rasp
module github.com/cpanato/raspi-fan-control

go 1.17

Expand All @@ -22,5 +22,3 @@ require (
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
google.golang.org/protobuf v1.26.0 // indirect
)

// replace github.com/stianeikelan÷d/go-rpio/v4 => github.com/cpanato/go-rpio/v4 v4.5.2-0.20211022120026-e74e62022556
2 changes: 2 additions & 0 deletions kubernetes/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ spec:
terminationMessagePath: /var/log/termination-log
terminationMessagePolicy: File
securityContext:
runAsGroup: 0
runAsUser: 0
privileged: true
capabilities:
add: ["SYS_RAWIO"]
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/cpanato/temp/go-rasp/cmd"
import "github.com/cpanato/raspi-fan-control/cmd"

func main() {
_ = cmd.Execute()
Expand Down

0 comments on commit a3e3810

Please sign in to comment.