Skip to content
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
28 changes: 28 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG BUILD_CONFIGURATION=Release
ARG APP_VERSION="1.0.0"

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION
ARG APP_VERSION

WORKDIR /code

COPY ["src/Console.csproj", "src/"]

RUN dotnet restore "./src/Console.csproj"

COPY . .
WORKDIR "/code/src"
RUN dotnet build "./Console.csproj" -c ${BUILD_CONFIGURATION} -o /app/build --no-restore

FROM build AS publish
ARG BUILD_CONFIGURATION
ARG APP_VERSION
RUN dotnet publish "./Console.csproj" -c ${BUILD_CONFIGURATION} -o /app/publish /p:UseAppHost=false /p:Version=${APP_VERSION} --runtime "linux-x64"

FROM mcr.microsoft.com/dotnet/aspnet:10.0
USER app
WORKDIR /app
EXPOSE 6264
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "console.dll"]
83 changes: 83 additions & 0 deletions .github/workflows/_build-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Reusable – Build binaries

on:
workflow_call:
inputs:
release_version:
required: true
type: string

defaults:
run:
shell: bash

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os_arch: [x64, x86, arm, arm64]
include:
- os: ubuntu-latest
kind: linux
title: linux
- os: windows-latest
kind: win
title: windows
- os: macos-latest
kind: osx
title: osx
exclude:
- os: windows-latest
os_arch: arm
- os: macos-latest
os_arch: arm
- os: macos-latest
os_arch: x86
- os: ubuntu-latest
os_arch: x86
runs-on: ${{ matrix.os }}
env:
RELEASE_VERSION: ${{ inputs.release_version }}

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'

- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

- name: Publish
run: |
release_name="synentra-${{ matrix.title }}-${{ matrix.os_arch }}"
dotnet publish src/Synentra/Synentra.csproj \
-p:PublishSingleFile=true \
-p:PublishReadyToRun=true \
--runtime "${{ matrix.kind }}-${{ matrix.os_arch }}" \
-c Release --self-contained true \
-p:Version="$RELEASE_VERSION" \
-o "${GITHUB_WORKSPACE}/$release_name"

mkdir -p "${GITHUB_WORKSPACE}/dist"
cd "${GITHUB_WORKSPACE}/$release_name"

if [[ "${{ matrix.kind }}" == "win" ]]; then
7z a -tzip "${GITHUB_WORKSPACE}/dist/${release_name}.zip" ./*
else
tar czvf "${GITHUB_WORKSPACE}/dist/${release_name}.tar.gz" ./*
fi

- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: synentra-${{ matrix.title }}-${{ matrix.os_arch }}
path: ${{ github.workspace }}/dist
79 changes: 79 additions & 0 deletions .github/workflows/_docker-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Reusable – Docker Linux

on:
workflow_call:
inputs:
release_version:
required: true
type: string
registry:
required: true
type: string
image_name:
required: true
type: string

defaults:
run:
shell: bash

jobs:
docker-linux:
runs-on: ubuntu-latest
permissions:
packages: write

steps:
- uses: actions/checkout@v4

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Build and push linux/amd64
env:
RELEASE_VERSION: ${{ inputs.release_version }}
REGISTRY: ${{ inputs.registry }}
IMAGE_NAME: ${{ inputs.image_name }}
run: |
IMAGE=${REGISTRY}/${IMAGE_NAME}
docker build \
--platform linux/amd64 \
--file .docker/Dockerfile \
--build-arg APP_VERSION="${RELEASE_VERSION}" \
--build-arg REVISION="${{ github.sha }}" \
--tag ${IMAGE}:${RELEASE_VERSION}-linux-amd64 \
.
docker push ${IMAGE}:${RELEASE_VERSION}-linux-amd64
mkdir -p /tmp/digests
docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE}:${RELEASE_VERSION}-linux-amd64 | awk -F@ '{print $2}' > /tmp/digests/linux-amd64

- name: Build and push linux/arm64
env:
RELEASE_VERSION: ${{ inputs.release_version }}
REGISTRY: ${{ inputs.registry }}
IMAGE_NAME: ${{ inputs.image_name }}
run: |
IMAGE=${REGISTRY}/${IMAGE_NAME}
docker build \
--platform linux/arm64 \
--file .docker/Dockerfile \
--build-arg APP_VERSION="${RELEASE_VERSION}" \
--build-arg REVISION="${{ github.sha }}" \
--tag ${IMAGE}:${RELEASE_VERSION}-linux-arm64 \
.
docker push ${IMAGE}:${RELEASE_VERSION}-linux-arm64
docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE}:${RELEASE_VERSION}-linux-arm64 | awk -F@ '{print $2}' >> /tmp/digests/linux-arm64

- name: Upload linux digests
uses: actions/upload-artifact@v4
with:
name: digests-linux
path: /tmp/digests/*
if-no-files-found: error
59 changes: 59 additions & 0 deletions .github/workflows/_docker-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Reusable – Docker Manifest

on:
workflow_call:
inputs:
release_version:
required: true
type: string
registry:
required: true
type: string
image_name:
required: true
type: string

defaults:
run:
shell: bash

jobs:
docker-manifest:
runs-on: ubuntu-latest
permissions:
packages: write
env:
IMAGE: ${{ inputs.registry }}/${{ inputs.image_name }}
VERSION: ${{ inputs.release_version }}

steps:
- name: Download all digests
uses: actions/download-artifact@v4
with:
pattern: digests-*
path: /tmp/digests
merge-multiple: true

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-platform manifest
run: |
DIGESTS=$(cat /tmp/digests/* | tr '\n' ' ')
REFS=""
for d in $DIGESTS; do
REFS="$REFS ${IMAGE}@${d}"
done

docker manifest create ${IMAGE}:${VERSION} $REFS
docker manifest push ${IMAGE}:${VERSION}

# Only tag latest for stable releases (no pre-release suffix e.g. -rc.1, -beta.1)
if [[ "$VERSION" != *"-"* ]]; then
docker manifest create ${IMAGE}:latest $REFS
docker manifest push ${IMAGE}:latest
fi
48 changes: 48 additions & 0 deletions .github/workflows/_github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Reusable – GitHub Release

on:
workflow_call:
inputs:
release_version:
required: true
type: string
sha:
required: true
type: string

defaults:
run:
shell: bash

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
env:
RELEASE_VERSION: ${{ inputs.release_version }}
ARTIFACT_DIR: ./release

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: synentra-*
path: ${{ env.ARTIFACT_DIR }}
merge-multiple: true

- name: Generate checksums
run: |
cd "${{ env.ARTIFACT_DIR }}"
for file in *; do
sha256sum -b "$file" > "$file.sha256"
done

- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: v${{ env.RELEASE_VERSION }}
name: Synentra v${{ env.RELEASE_VERSION }}
generateReleaseNotes: true
artifacts: "${{ env.ARTIFACT_DIR }}/**"
token: ${{ secrets.GITHUB_TOKEN }}
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Synentra Release

on:
workflow_dispatch:
inputs:
rel_version:
description: 'Release version (examples: 1.9.0-rc.1, 1.9.1)'
required: true
type: string

concurrency:
group: release-${{ github.event.inputs.rel_version }}
cancel-in-progress: true

permissions:
contents: write
packages: write

defaults:
run:
shell: bash

jobs:
sanitize_inputs:
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.set_version.outputs.RELEASE_VERSION }}
steps:
- name: Sanitize release version
id: set_version
env:
INPUT_VERSION: ${{ github.event.inputs.rel_version }}
run: |
# Keep only alphanumeric, dots, hyphens, underscores
SAFE_VERSION=$(echo "$INPUT_VERSION" | tr -cd '[:alnum:]._-')
echo "RELEASE_VERSION=$SAFE_VERSION" >> $GITHUB_ENV
echo "RELEASE_VERSION=$SAFE_VERSION" >> $GITHUB_OUTPUT

build:
needs: sanitize_inputs
uses: ./.github/workflows/_build-binaries.yml
with:
release_version: ${{ needs.sanitize_inputs.outputs.RELEASE_VERSION }}

release:
needs: [sanitize_inputs, build]
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/_github-release.yml
with:
release_version: ${{ needs.sanitize_inputs.outputs.RELEASE_VERSION }}
sha: ${{ github.sha }}
secrets: inherit

docker-linux:
needs: [sanitize_inputs, release]
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/_docker-linux.yml
with:
release_version: ${{ needs.sanitize_inputs.outputs.RELEASE_VERSION }}
registry: ghcr.io
image_name: ${{ github.repository }}
secrets: inherit

docker-manifest:
needs: [sanitize_inputs, docker-linux]
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/_docker-manifest.yml
with:
release_version: ${{ needs.sanitize_inputs.outputs.RELEASE_VERSION }}
registry: ghcr.io
image_name: ${{ github.repository }}
secrets: inherit
Loading