Skip to content

Commit

Permalink
feat: release workflows (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldietzler authored Sep 2, 2024
1 parent 94e34b6 commit ca767f9
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 21 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy

on:
workflow_dispatch:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
packages: write

jobs:
build_and_push:
name: Build and Push
runs-on: ubuntu-latest
strategy:
# Prevent a failure in one image from stopping the other builds
fail-fast: false
matrix:
include:
- image: uftos-api
context: .
file: server/Dockerfile
platforms: linux/amd64,linux/arm64
device: cpu
- image: immich-web
context: .
file: web/Dockerfile
platforms: linux/amd64,linux/arm64
device: cpu

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3.2.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.6.1

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate docker image tags
id: metadata
uses: docker/metadata-action@v5
with:
images: |
name=ghcr.io/${{ github.repository_owner }}/${{matrix.image}}
name=pse-timetable/${{matrix.image}},enable=${{ github.event_name == 'release' }}
tags: |
# Tag with git tag on release
type=ref,event=tag
type=raw,value=release,enable=${{ github.event_name == 'release' }}
- name: Determine build cache output
id: cache-target
run: |
echo "cache-to=type=registry,mode=max,ref=ghcr.io/${{ github.repository_owner }}/immich-build-cache:${{ matrix.image }}" >> $GITHUB_OUTPUT
- name: Build and push image
uses: docker/build-push-action@v6.7.0
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
platforms: ${{ matrix.platforms }}
# Skip pushing when PR from a fork
push: true
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/uftos-build-cache:${{matrix.image}}
cache-to: ${{ steps.cache-target.outputs.cache-to }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
DEVICE=${{ matrix.device }}
BUILD_ID=${{ github.run_id }}
BUILD_IMAGE=${{ github.event_name == 'release' && github.ref_name || steps.metadata.outputs.tags }}
BUILD_SOURCE_REF=${{ github.ref_name }}
BUILD_SOURCE_COMMIT=${{ github.sha }}
30 changes: 30 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Prepare new release

on:
workflow_dispatch:
inputs:
version:
description: "The version of the release"
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-root
cancel-in-progress: true

jobs:
prepare_release:
runs-on: ubuntu-latest

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

- name: Create draft release
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: ${{ inputs.version }}
generate_release_notes: true
files: |
docker-compose.yml
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dev:
docker compose -f ./docker-compose.yml up
docker compose -f ./docker-compose.dev.yml up
dev-update:
docker compose -f ./docker-compose.yml up --build -V
docker compose -f ./docker-compose.dev.yml up --build -V
test:
cd ./server && ./mvnw -Dtest='!de.uftos.e2e.**,!UftosApplicationTests' test
test-stupid:
Expand Down
52 changes: 52 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
services:
db:
image: postgres:16.3-alpine3.18
container_name: uftos-db
restart: unless-stopped
ports:
- 5432:5432
volumes:
- pgdata:/var/lib/postgresql/data
environment:
POSTGRES_USER: uftos
POSTGRES_PASSWORD: superSecurePassword
POSTGRES_DB: uftos
api:
image: uftos-api-dev:latest
container_name: uftos-api
build:
context: ./
dockerfile: server/Dockerfile
restart: unless-stopped
ports:
- 8080:8080
# debug port
- 5005:5005
volumes:
- ./server:/app
depends_on:
- db
environment:
DB_HOST: db
DB_PORT: 5432
DB_USER: uftos
DB_PASSWORD: superSecurePassword
DB_NAME: uftos
MAIL_HOST: mail.example.org
MAIL_USER: myUser
MAIL_PASSWORD: highlySecurePassword
MAIL_FROM: uftos@example.com
web:
image: uftos-web-dev:latest
container_name: uftos-web
build:
context: ./web
ports:
- 5173:5173
volumes:
- ./web:/app
- /app/node_modules
restart: unless-stopped

volumes:
pgdata:
2 changes: 1 addition & 1 deletion docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
POSTGRES_PASSWORD: superSecurePassword
POSTGRES_DB: uftos
api:
image: uftos-server-dev:latest
image: uftos-api-dev:latest
container_name: uftos-api
build:
context: ./
Expand Down
20 changes: 4 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ services:
POSTGRES_PASSWORD: superSecurePassword
POSTGRES_DB: uftos
api:
image: uftos-server-dev:latest
image: ghcr.io/PSE-timetable/uftos-api:latest
container_name: uftos-api
build:
context: ./
dockerfile: server/Dockerfile
restart: unless-stopped
ports:
- 8080:8080
# debug port
- 5005:5005
volumes:
- ./server:/app
# volumes:
# - ./server:/app
depends_on:
- db
environment:
Expand All @@ -37,15 +30,10 @@ services:
MAIL_PASSWORD: highlySecurePassword
MAIL_FROM: uftos@example.com
web:
image: uftos-web-dev:latest
image: ghcr.io/PSE-timetable/uftos-web:latest
container_name: uftos-web
build:
context: ./web
ports:
- 5173:5173
volumes:
- ./web:/app
- /app/node_modules
restart: unless-stopped

volumes:
Expand Down
4 changes: 2 additions & 2 deletions server/src/test/java/de/uftos/UftosApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Testcontainers
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Suite
@SelectPackages({"de.uftos.e2e"})
@SelectPackages({ "de.uftos.e2e" })
class UftosApplicationTests {

static Network network = Network.newNetwork();
Expand All @@ -29,7 +29,7 @@ class UftosApplicationTests {
.withEnv("POSTGRES_PASSWORD", "superSecurePassword")
.withEnv("POSTGRES_DB", "uftos");

static final GenericContainer<?> server = new GenericContainer<>("uftos-server-dev")
static final GenericContainer<?> server = new GenericContainer<>("uftos-api-dev")
.dependsOn(postgres)
.withNetwork(network)
.withAccessToHost(true)
Expand Down

0 comments on commit ca767f9

Please sign in to comment.