Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

ci: add goreleaser config #3

Merged
merged 6 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: release

on:
push:
branches:
- main
pull_request:

jobs:
release:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: WillAbides/[email protected]
with:
go-version: ^1.20
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: go-semantic-release/action@v1
with:
allow-initial-development-versions: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go mod download -x
- name: Define goreleaser flags
run: test -n "$(git tag --points-at HEAD)" || echo "GORELEASER_FLAGS=--snapshot" >> $GITHUB_ENV
- uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean ${{ env.GORELEASER_FLAGS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_OWNER: ${{ github.repository_owner }}
5 changes: 3 additions & 2 deletions .github/workflows/test.yaml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: WillAbides/setup-go-faster@v1.11.0
- uses: WillAbides/setup-go-faster@v1.12.0
with:
go-version: ^1.18
go-version: ^1.20
- uses: actions/checkout@v4
with:
fetch-depth: 1
Expand All @@ -35,3 +35,4 @@ jobs:
install-go: false
- run: go test -v ./... -race -bench=. -benchmem -cover -coverprofile cover.out 2>&1 | tee test.out
- run: go tool cover -func cover.out
- uses: wagoid/commitlint-github-action@v5
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
57 changes: 57 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
builds:
- main: .
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
mod_timestamp: "{{ .CommitTimestamp }}"
universal_binaries:
- replace: false
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- typo
release:
prerelease: auto
dockers:
- image_templates:
- "ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-amd64"
dockerfile: Dockerfile
use: buildx
extra_files:
- ./
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- image_templates:
- "ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-arm64v8"
goarch: arm64
dockerfile: Dockerfile
use: buildx
extra_files:
- ./
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
docker_manifests:
- name_template: ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-arm64v8
- name_template: ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-arm64v8
28 changes: 14 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# syntax=docker/dockerfile:1
FROM golang:1-alpine AS builder

FROM golang:1.20
RUN apk add -U git ca-certificates && update-ca-certificates

# Set destination for COPY
WORKDIR /app

# Download Go modules
WORKDIR /usr/local/src/zenduty-calendar
COPY go.mod go.sum ./
RUN go mod download
RUN go mod download -x
COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o /usr/local/bin/zenduty-calendar

FROM alpine:latest
USER "guest"

# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/engine/reference/builder/#copy
COPY *.go *.html ./
ADD internal ./internal
WORKDIR /tmp
HEALTHCHECK CMD wget -U "Healthcheck" --quiet --tries=1 --spider http://localhost:3000/metrics || exit 1

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -o /zenduty-calendar
COPY --from=builder /usr/local/bin/zenduty-calendar /usr/local/bin/zenduty-calendar

EXPOSE 3000

# Run
CMD ["/zenduty-calendar"]
ENTRYPOINT ["/usr/local/bin/zenduty-calendar"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Exposes a Zenduty schedule as an ICS calendar. Multiple endpoints are possible:

```
/calendar/:team/:schedule/:member
/calendar/:teamUUID/:scheduleUUID/:memberEmail
```

Return the specific zenduty team schedule as an ICS calendar. Only keep events
Expand Down