diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..d23a6391cd --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,80 @@ +name: Docker images + +# The images are built for every push to master and for pull requests, to verify that they can be built. +# When a version tag (e.g. v1.2.3) is pushed, they are built for all supported platforms and published +# to Docker Hub with the version (1.2.3) and 'latest' as tags. +# Publishing requires the repository secrets DOCKERHUB_USERNAME and DOCKERHUB_TOKEN. + +on: + push: + branches: + - master + tags: + - 'v*' + pull_request: + +jobs: + build: + name: ${{ matrix.image }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - image: openmu + dockerfile: src/Startup/Dockerfile + - image: openmu-admin + dockerfile: src/Dapr/AdminPanel.Host/Dockerfile + - image: openmu-chat + dockerfile: src/Dapr/ChatServer.Host/Dockerfile + - image: openmu-connect + dockerfile: src/Dapr/ConnectServer.Host/Dockerfile + - image: openmu-friend + dockerfile: src/Dapr/FriendServer.Host/Dockerfile + - image: openmu-game + dockerfile: src/Dapr/GameServer.Host/Dockerfile + - image: openmu-guild + dockerfile: src/Dapr/GuildServer.Host/Dockerfile + - image: openmu-login + dockerfile: src/Dapr/LoginServer.Host/Dockerfile + + env: + PUBLISH: ${{ startsWith(github.ref, 'refs/tags/v') }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + if: env.PUBLISH == 'true' + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + if: env.PUBLISH == 'true' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Determine the image tags + id: meta + uses: docker/metadata-action@v5 + with: + images: munique/${{ matrix.image }} + tags: | + type=semver,pattern={{version}} + type=ref,event=branch + type=ref,event=pr + + - name: Build and publish + uses: docker/build-push-action@v6 + with: + context: src + file: ${{ matrix.dockerfile }} + platforms: ${{ env.PUBLISH == 'true' && 'linux/amd64,linux/arm64,linux/arm/v7' || 'linux/amd64' }} + push: ${{ env.PUBLISH == 'true' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index f5ce6068f3..e26d9be1d8 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -15,3 +15,5 @@ jobs: dotnet-version: 10.0.x - name: Build with dotnet run: dotnet publish src/Startup/MUnique.OpenMU.Startup.csproj --configuration Release -p:ci=true + - name: Test with dotnet + run: dotnet test src/MUnique.OpenMU.sln --configuration Release -p:ci=true diff --git a/README.md b/README.md index dc5508e05b..8976641ce1 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ | Platform |Build Status | |----------------|----------------------| -| Windows | ![Windows Build Status](https://dev.azure.com/MUnique/OpenMU/_apis/build/status/MUnique.OpenMU?branchName=master) | -| Linux (Docker) | [![Docker Build Status](https://dev.azure.com/MUnique/OpenMU/_apis/build/status/MUnique.OpenMU%20Docker?branchName=master)](https://hub.docker.com/r/munique/openmu) | +| Linux | [![Build Status](https://github.com/MUnique/OpenMU/actions/workflows/dotnetcore.yml/badge.svg?branch=master)](https://github.com/MUnique/OpenMU/actions/workflows/dotnetcore.yml) | +| Linux (Docker) | [![Docker Build Status](https://github.com/MUnique/OpenMU/actions/workflows/docker.yml/badge.svg?branch=master)](https://hub.docker.com/r/munique/openmu) | | NuGet Packages | | |----------------|---| diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index dc2185a7df..0000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,36 +0,0 @@ -# ASP.NET Core -# Build and test ASP.NET Core projects targeting .NET Core. -# Add steps that run tests, create a NuGet package, deploy, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core - -trigger: -- master - -pool: - vmImage: 'windows-2022' - -variables: - buildConfiguration: 'Release' - -steps: -- task: UseDotNet@2 - displayName: 'Install .NET Core SDK' - inputs: - version: 10.0.x - performMultiLevelLookup: true - includePreviewVersions: true # Required for preview versions - -- script: dotnet restore - workingDirectory: src - displayName: 'dotnet restore' - -- script: dotnet build --configuration $(buildConfiguration) -p:ci=true - workingDirectory: src - displayName: 'dotnet build $(buildConfiguration)' - -- task: DotNetCoreCLI@2 - displayName: 'dotnet test' - inputs: - command: test - projects: 'tests/*Tests/*.csproj' - arguments: '--configuration $(buildConfiguration) --no-build' diff --git a/src/MUnique.OpenMU.sln b/src/MUnique.OpenMU.sln index 98a8bb5491..d2dd8e0be9 100644 --- a/src/MUnique.OpenMU.sln +++ b/src/MUnique.OpenMU.sln @@ -46,7 +46,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig ..\.gitignore = ..\.gitignore - ..\azure-pipelines.yml = ..\azure-pipelines.yml + ..\.github\workflows\docker.yml = ..\.github\workflows\docker.yml Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props ..\.github\workflows\dotnetcore.yml = ..\.github\workflows\dotnetcore.yml