diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..62aef73 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,13 @@ +categories: + - title: '🚀 Features' + labels: + - 'feature' + - title: '🐛 Bug Fixes' + labels: + - 'bug' + - title: '🧰 Maintenance' + label: 'maintenance' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +template: | + ## Changes + $CHANGES diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml new file mode 100644 index 0000000..8095324 --- /dev/null +++ b/.github/workflows/createrelease.yml @@ -0,0 +1,127 @@ +name: Release + +on: + release: + types: [published] + +jobs: + build: + name: "Release" + env: + ASPNETCORE_ENVIRONMENT: "Production" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + + - name: Setup .NET Core 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + + - name: Restore Nuget Packages + run: dotnet restore MessagingService.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json + + - name: Build Code + run: dotnet build MessagingService.sln --configuration Release + + #- name: Run Unit Tests + # run: | + # echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" + # dotnet test "MessagingService.BusinessLogic.Tests\MessagingService.BusinessLogic.Tests.csproj" + # dotnet test "MessagingService.EmailAggregate.Tests\MessagingService.EmailAggregate.Tests.csproj" + # dotnet test "MessagingService.Tests\MessagingService.Tests.csproj" + + #- name: Build Docker Image + # run: docker build . --file MessagingService/Dockerfile --tag stuartferguson/messagingservice:latest --tag stuartferguson/messagingservice:${{ steps.get_version.outputs.VERSION }} + + #- name: Publish Images to Docker Hub + # run: | + # docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }} + # docker push stuartferguson/messagingservice:latest + # docker push stuartferguson/messagingservice:${{ steps.get_version.outputs.VERSION }} + + #- name: Publish API + # run: dotnet publish "MessagingService\MessagingService.csproj" --configuration Release --output publishOutput + + - name: Setup .NET Core 2.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.0.0 + + - name: Extract Octopus Tools + run: | + mkdir /opt/octo + cd /opt/octo + wget -O /opt/octo/octopus.zip https://download.octopusdeploy.com/octopus-tools/6.12.0/OctopusTools.6.12.0.portable.zip + unzip /opt/octo/octopus.zip + chmod +x /opt/octo/Octo + + - name: Pack Files for Octopus + run: >- + /opt/octo/Octo pack + --outFolder /home/runner/work/MessagingService/MessagingService + --basePath /home/runner/work/MessagingService/MessagingService/publishOutput + --id MessagingService + --version ${{ steps.get_version.outputs.VERSION }} + --format zip + --verbose + --logLevel=verbose + + - name: Push Package to Octopus + run: >- + /opt/octo/Octo push + --server ${{ secrets.OCTOPUS_URL }} + --apiKey ${{ secrets.OCTOPUS_APIKEY }} + --package /home/runner/work/MessagingService/MessagingService/MessagingService.${{ steps.get_version.outputs.VERSION }}.zip + --overwrite-mode IgnoreIfExists + + - name: Get Release + id: getrelease + uses: octokit/request-action@v1.x + with: + route: GET /repos/StuartFerguson/MessagingService/releases/tags/${{ steps.get_version.outputs.VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Release Notes + id: buildreleasenotes + uses: gr2m/get-json-paths-action@v1.x + with: + json: ${{ steps.getrelease.outputs.data }} + releasenote: "body" + + - name: Create & Deploy Release in Octopus + run: >- + /opt/octo/Octo create-release + --server ${{ secrets.OCTOPUS_URL }} + --apiKey ${{ secrets.OCTOPUS_APIKEY }} + --project "Messaging Service" + --version ${{ steps.get_version.outputs.VERSION }} + --channel Default + --deployTo Development + --waitfordeployment + --deploymenttimeout 00:05:00 + --releasenotes "${{ steps.buildreleasenotes.outputs.releasenote }}" + + - name: Setup .NET Core 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + + - name: Build and Publish Nuget Packages + run: | + dotnet pack "MessagingService.EmailMessage.DomainEvents\MessagingService.EmailMessage.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release + dotnet nuget push Nugets/MessagingService.EmailMessage.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package + + #- name: Build and Publish Nuget Packages + # run: | + # dotnet pack "MessagingService.Client\MessagingService.Client.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release + # #dotnet nuget push Nugets/MessagingService.Client.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package + # dotnet pack "MessagingService.EmailMessage.DomainEvents\MessagingService.EmailMessage.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release + # dotnet nuget push Nugets/MessagingService.EmailMessage.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package diff --git a/.github/workflows/prereleasenuget.yml b/.github/workflows/prereleasenuget.yml new file mode 100644 index 0000000..e994f63 --- /dev/null +++ b/.github/workflows/prereleasenuget.yml @@ -0,0 +1,44 @@ +name: Publish Pre-Release Nuget + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + build: + name: "Publish Pre-Release Nugets" + env: + ASPNETCORE_ENVIRONMENT: "Production" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Restore Nuget Packages + run: dotnet restore MessagingService.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json + + - name: Build Code + run: dotnet build MessagingService.sln --configuration Release + + - name: Get the last version + id: get_version + run: echo ::set-output name=VERSION::$(git tag --sort=committerdate | tail -1) + + - name: Print Version + id: next_version + run: echo ::set-output name=VERSION::${{ steps.get_version.outputs.VERSION }}.$GITHUB_RUN_NUMBER + + - name: Build and Publish Nuget Packages + run: | + dotnet pack "MessagingService.EmailMessage.DomainEvents\MessagingService.EmailMessage.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release + dotnet nuget push Nugets/MessagingService.EmailMessage.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package + + #- name: Build and Publish Nuget Packages + # run: | + # dotnet pack "MessagingService.Client\MessagingService.Client.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release + # #dotnet nuget push Nugets/MessagingService.Client.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package + # dotnet pack "MessagingService.EmailMessage.DomainEvents\MessagingService.EmailMessage.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release + # dotnet nuget push Nugets/MessagingService.EmailMessage.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package \ No newline at end of file diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml new file mode 100644 index 0000000..89de793 --- /dev/null +++ b/.github/workflows/pullrequest.yml @@ -0,0 +1,41 @@ +name: Build and Test Pull Requests + +on: + pull_request: + branches: + - master + +jobs: + build: + name: "Build and Test Pull Requests" + env: + ASPNETCORE_ENVIRONMENT: "Production" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.102 + + - name: Restore Nuget Packages + run: dotnet restore MessagingService.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json + + - name: Build Code + run: dotnet build MessagingService.sln --configuration Release + + #- name: Run Unit Tests + # run: | + # echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" + # dotnet test "MessagingService.BusinessLogic.Tests\MessagingService.BusinessLogic.Tests.csproj" + # dotnet test "MessagingService.EmailAggregate.Tests\MessagingService.EmailAggregate.Tests.csproj" + # dotnet test "MessagingService.Tests\MessagingService.Tests.csproj" + + #- name: Build Docker Image + # run: docker build . --file MessagingService/Dockerfile --tag messagingservice:latest + + #- name: Run Integration Tests + # run: dotnet test "MessagingService.IntegrationTests\MessagingService.IntegrationTests.csproj" --filter Category=PRTest diff --git a/.github/workflows/release-management.yml b/.github/workflows/release-management.yml new file mode 100644 index 0000000..83d8d98 --- /dev/null +++ b/.github/workflows/release-management.yml @@ -0,0 +1,16 @@ +name: Release Management + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_draft_release: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: toolmantim/release-drafter@v5.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/act/actions-setup-dotnet@v1 b/act/actions-setup-dotnet@v1 new file mode 160000 index 0000000..b782114 --- /dev/null +++ b/act/actions-setup-dotnet@v1 @@ -0,0 +1 @@ +Subproject commit b7821147f564527086410e8edd122d89b4b9602f