]> git.deb.at Git - rhonda/impostor.git/commitdiff
CI (#1)
authorAeonLucid <aeonlucid@outlook.com>
Mon, 21 Sep 2020 01:36:32 +0000 (03:36 +0200)
committerGitHub <noreply@github.com>
Mon, 21 Sep 2020 01:36:32 +0000 (03:36 +0200)
.github/workflows/deploy.yml [new file with mode: 0644]
.github/workflows/docker.yml [new file with mode: 0644]
.github/workflows/main.yml [new file with mode: 0644]
src/Impostor.Server/Impostor.Server.csproj

diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644 (file)
index 0000000..5a7571d
--- /dev/null
@@ -0,0 +1,68 @@
+name: Deploy
+
+on:
+  push:
+    tags:
+    - 'v*'
+
+jobs:
+  build:
+    name: Build
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          submodules: true
+      - name: Setup .NET Core
+        uses: actions/setup-dotnet@v1
+        with:
+          dotnet-version: 3.1.301
+      - name: Install dependencies
+        run: dotnet restore ./src
+      - name: Build Impostor.Client
+        run: dotnet build --no-restore -c Release -f netcoreapp3.1 ./src/Impostor.Client/Impostor.Client.csproj
+      - name: Build Impostor.Server
+        run: dotnet build --no-restore -c Release -f netcoreapp3.1 ./src/Impostor.Server/Impostor.Server.csproj
+      - name: Test
+        run: dotnet test --no-restore -v normal -f netcoreapp3.1 ./src
+      - name: Publish Impostor.Server (win-x64)
+        run: dotnet publish -c release -o ./build/win-x64 -f netcoreapp3.1 -r win-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj
+      - name: Zip Impostor.Server (win-x64)
+        run: cd ./build/win-x64; zip -r ../win-x64.zip .; cd ./../../
+      - name: Publish Impostor.Server (linux-x64)
+        run: dotnet publish -c release -o ./build/linux-x64 -f netcoreapp3.1 -r linux-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj
+      - name: Zip Impostor.Server (linux-x64)
+        run: cd ./build/linux-x64; zip -r ../linux-x64.zip .; cd ./../../
+      - name: Create Release
+        id: create_release
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: ${{ github.ref }}
+          release_name: Release ${{ github.ref }}
+          body: |
+            Changes in this Release
+            - First Change
+            - Second Change
+          draft: true
+          prerelease: false
+      - name: Upload Release Asset (win-x64)
+        uses: actions/upload-release-asset@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }}
+          asset_path: ./build/win-x64.zip
+          asset_name: Impostor-Server-win-x64.zip
+          asset_content_type: application/zip
+      - name: Upload Release Asset (linux-x64)
+        uses: actions/upload-release-asset@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          upload_url: ${{ steps.create_release.outputs.upload_url }}
+          asset_path: ./build/linux-x64.zip
+          asset_name: Impostor-Server-linux-x64.zip
+          asset_content_type: application/zip
\ No newline at end of file
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644 (file)
index 0000000..68208c3
--- /dev/null
@@ -0,0 +1,64 @@
+name: Docker
+
+on:
+  schedule:
+    - cron: '0 10 * * *'
+  push:
+    branches: [ master, dev ]
+    tags:
+      - 'v*.*.*'
+  pull_request:
+
+jobs:
+  push_to_registry:
+    name: Push Docker image
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          submodules: true
+      - name: Prepare
+        id: prep
+        run: |
+          DOCKER_IMAGE=aeonlucid/impostor
+          VERSION=noop
+          if [ "${{ github.event_name }}" = "schedule" ]; then
+            VERSION=nightly
+          elif [[ $GITHUB_REF == refs/tags/* ]]; then
+            VERSION=${GITHUB_REF#refs/tags/}
+          elif [[ $GITHUB_REF == refs/heads/* ]]; then
+            VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
+            if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
+              VERSION=edge
+            fi
+          elif [[ $GITHUB_REF == refs/pull/* ]]; then
+            VERSION=pr-${{ github.event.number }}
+          fi
+          TAGS="${DOCKER_IMAGE}:${VERSION}"
+          if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
+            MINOR=${VERSION%.*}
+            MAJOR=${MINOR%.*}
+            TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
+          fi
+          echo ::set-output name=version::${VERSION}
+          echo ::set-output name=tags::${TAGS}
+          echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
+      - name: Login to DockerHub
+        if: github.event_name != 'pull_request'
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+      - name: Build and push
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          file: ./Dockerfile
+          platforms: linux/amd64
+          push: ${{ github.event_name != 'pull_request' }}
+          tags: ${{ steps.prep.outputs.tags }}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644 (file)
index 0000000..ad319c2
--- /dev/null
@@ -0,0 +1,39 @@
+name: Build
+
+on:
+  push:
+    branches: [ master, dev ]
+  pull_request:
+    branches: [ master, dev ]
+
+jobs:
+  build:
+    name: Build
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          submodules: true
+      - name: Setup .NET Core
+        uses: actions/setup-dotnet@v1
+        with:
+          dotnet-version: 3.1.301
+      - name: Install dependencies
+        run: dotnet restore ./src
+      - name: Build Impostor.Client
+        run: dotnet build --no-restore -c Release -f netcoreapp3.1 ./src/Impostor.Client/Impostor.Client.csproj
+      - name: Build Impostor.Server
+        run: dotnet build --no-restore -c Release -f netcoreapp3.1 ./src/Impostor.Server/Impostor.Server.csproj
+      - name: Test
+        run: dotnet test --no-restore -v normal -f netcoreapp3.1 ./src
+  deploy:
+    name: Deploy
+    runs-on: ubuntu-latest
+    needs: build
+    if: github.event_name == 'release'
+    steps:
+      - name: Publish Impostor.Server (win-x64)
+        run: dotnet publish -c release -o /build/linux-x64 -f netcoreapp3.1 -r win-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj
+      - name: Publish Impostor.Server (linux-x64)
+        run: dotnet publish -c release -o /build/linux-x64 -f netcoreapp3.1 -r linux-x64 --self-contained --no-restore ./src/Impostor.Server/Impostor.Server.csproj
\ No newline at end of file
index 46ef7fad7c24fbf76100ef7348516be2a9cf2daf..d03494bf46c81e8b6c9a4054db446b5f84ecf7cf 100644 (file)
@@ -3,6 +3,7 @@
     <PropertyGroup>
         <OutputType>Exe</OutputType>
         <TargetFramework>netcoreapp3.1</TargetFramework>
+        <RuntimeIdentifiers>win-x64;linux-x64;linux-musl-x64</RuntimeIdentifiers>
     </PropertyGroup>
 
     <ItemGroup>