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
82 changes: 82 additions & 0 deletions .github/workflows/publish-server-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish server image

# Builds server/Dockerfile and pushes it to GitHub's container registry.
# Packages pushed to ghcr.io start out private — the image stays private
# until its visibility is changed by hand under Packages -> Package settings.

on:
push:
branches:
- main
tags:
- 'v*'
# No paths filter on purpose. It would apply to the tag push as well —
# there is only one push block, and GitHub evaluates the filter for every
# ref in it. Tagging a release on a commit that happens not to touch
# server/ (a docs or client commit, which is the common case) would then
# silently produce no image and no version tags at all.
#
# The cost of dropping it is a rebuild on commits that change nothing in
# the image. That takes well under a minute; a missing release does not
# announce itself.
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Check out
uses: actions/checkout@v4

# ghcr.io rejects upper case names, but repository owners may contain
# them (dmuiX). Normalise before it reaches any tag.
- name: Resolve image name
run: echo "IMAGE=ghcr.io/$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')/unss-server" >> "$GITHUB_ENV"

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

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

- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
# Provided automatically, no secret needs to be configured.
password: ${{ secrets.GITHUB_TOKEN }}

- name: Derive tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha,format=short

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./server
# arm64 is included so the image also runs on a Raspberry Pi.
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

- name: Summary
run: |
echo "### Pushed" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "${{ steps.meta.outputs.tags }}" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ build/
*.nsp
*.xci

# Switch homebrew (build leftovers)
*.map

# Server-side data
savedata/
metadata.sqlite

# Runtime configuration — may contain the server URL including credentials
# (the client accepts https://user:pass@host). Never commit these.
config.ini

# Logs
*.log

# Claude
.claude/
Loading