From 8a13752edef08a61c496ba808a2f231e73d7313d Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Mon, 17 Jul 2023 09:38:44 +0200 Subject: [PATCH] Update publish.yml --- .github/workflows/publish.yml | 119 ++++++++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 21 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 558a2cdb..7e3dadf1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,23 +10,51 @@ env: REGISTRY: ghcr.io jobs: - # REQUIRES secrets.NUGET_API_KEY - #publish-packages: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - name: Setup .NET - # uses: actions/setup-dotnet@v1 - # with: - # dotnet-version: 7.0.x - # - name: Restore dependencies - # run: dotnet restore "${{ env.SOLUTION }}" - # - name: Build - # run: dotnet build "${{ env.SOLUTION }}" --configuration Release --no-restore - # - name: Push1 - # run: dotnet nuget push "./src/*/*/bin/Release/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate - # - name: Push2 - # run: dotnet nuget push "./src/*/*/*/bin/Release/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + publish-packages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 7.0.x + - name: Restore dependencies + run: dotnet restore "${{ env.SOLUTION }}" + - name: Build + run: dotnet build "${{ env.SOLUTION }}" --configuration Release --no-restore + - name: Push1 + run: dotnet nuget push "./src/*/*/bin/Release/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + - name: Push2 + run: dotnet nuget push "./src/*/*/*/bin/Release/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + + publish-api-server-image: + name: Publish API Server image + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}-broker + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: './src/core/CloudStreams.Core.Api.Server/Dockerfile' + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} publish-broker-image: name: Publish Broker Image @@ -52,7 +80,7 @@ jobs: uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: context: . - file: './src/broker/server/Dockerfile' + file: './src/broker/CloudStreams.Broker.Api.Server/Dockerfile' push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -81,11 +109,60 @@ jobs: uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: context: . - file: './src/gateway/server/Dockerfile' + file: './src/gateway/CloudStreams.Gateway.Api.Server/Dockerfile' push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + publish-api-server-bin: + name: Publish API Server Binaries + strategy: + matrix: + kind: ['linux', 'windows', 'macOS'] + include: + - kind: linux + os: ubuntu-latest + target: linux-x64 + - kind: windows + os: windows-latest + target: win-x64 + - kind: macOS + os: macos-latest + target: osx-x64 + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Setup + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 7.0.x + - name: Restore + run: dotnet restore + - name: Build + shell: bash + run: | + tag=$(git describe --tags --abbrev=0) + release_name="cloud-streams-broker-${{ matrix.target }}" + # Publish + dotnet publish src/core/CloudStreams.Core.Api.Server/CloudStreams.Core.Api.Server.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" + # Pack + if [ "${{ matrix.target }}" == "win-x64" ]; then + # Pack for Windows + 7z a -tzip "${release_name}.zip" "./${release_name}/*" + else + # Pack for other OS + tar czvf "${release_name}.tar.gz" "$release_name" + fi + # Delete output directory + rm -r "$release_name" + - name: Publish + uses: softprops/action-gh-release@v1 + with: + files: "cloud-streams-api-server*" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish-broker-bin: name: Publish Broker Binaries strategy: @@ -117,7 +194,7 @@ jobs: tag=$(git describe --tags --abbrev=0) release_name="cloud-streams-broker-${{ matrix.target }}" # Publish - dotnet publish src/broker/server/CloudStreams.Broker.Api.Server.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" + dotnet publish src/broker/CloudStreams.Broker.Api.Server/CloudStreams.Broker.Api.Server.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" # Pack if [ "${{ matrix.target }}" == "win-x64" ]; then # Pack for Windows @@ -166,7 +243,7 @@ jobs: tag=$(git describe --tags --abbrev=0) release_name="cloud-streams-gateway-${{ matrix.target }}" # Publish - dotnet publish src/gateway/server/CloudStreams.Gateway.Api.Server.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" + dotnet publish src/gateway/CloudStreams.Gateway.Api.Server/CloudStreams.Gateway.Api.Server.csproj --runtime "${{ matrix.target }}" -c Release -o "$release_name" # Pack if [ "${{ matrix.target }}" == "win-x64" ]; then # Pack for Windows