Skip to content
Open
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
83 changes: 46 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
name: CI Pipeline

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

jobs:
ci:
name: Continuous Integration
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache-dependency-path: "go.sum"


- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

- name: Build binary
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o immich-linux-amd64 -ldflags="-s -w -extldflags=-static" main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o immich-linux-arm64 -ldflags="-s -w -extldflags=-static" main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o immich-windows-amd64.exe -ldflags="-s -w -extldflags=-static" main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o immich-darwin-amd64 -ldflags="-s -w -extldflags=-static" main.go

- name: Run tests
run: |
go test --race -v -count=1 -coverprofile=coverage.out ./...
ci:
name: Continuous Integration
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache-dependency-path: "go.sum"

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

- name: Build binary
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o immich-linux-amd64 -ldflags="-s -w -extldflags=-static" main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o immich-linux-arm64 -ldflags="-s -w -extldflags=-static" main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o immich-windows-amd64.exe -ldflags="-s -w -extldflags=-static" main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o immich-darwin-amd64 -ldflags="-s -w -extldflags=-static" main.go

- name: Upload binaries as artifact
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
immich-linux-amd64
immich-linux-arm64
immich-windows-amd64.exe
immich-darwin-amd64

- name: Run tests
run: |
go test --race -v -count=1 -coverprofile=coverage.out ./...
26 changes: 26 additions & 0 deletions .github/workflows/ci_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: docker image ci

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build Docker Image
uses: docker/build-push-action@v6
with:
push: false
tags: ${{github.repository_owner}}/immich-go
87 changes: 87 additions & 0 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: publish docker image

on:
workflow_dispatch:
push:
# Publish when tagging
tags: [ '*' ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
GH_IMAGE_NAME: ${{github.repository_owner}}/immich-go
DH_IMAGE_NAME: ${{github.repository_owner}}/immich-go

jobs:
build:

runs-on: ubuntu-latest
permissions:
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool
# https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/cosign-installer@main #v2.6.0
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Login against a Docker registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.GH_IMAGE_NAME }},${{ env.DH_IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign -y {}@${{ steps.build-and-push.outputs.digest }}

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.23 AS builder

WORKDIR /go/src/app
COPY . .
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /go/bin/immich-go -ldflags="-s -w -extldflags=-static" main.go

FROM gcr.io/distroless/base-debian12

COPY --from=builder /go/bin/immich-go /
CMD ["/immich-go"]