|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: "Release" |
| 10 | + env: |
| 11 | + ASPNETCORE_ENVIRONMENT: "Production" |
| 12 | + |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2.3.4 |
| 17 | + |
| 18 | + - name: Get the version |
| 19 | + id: get_version |
| 20 | + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
| 21 | + |
| 22 | + - name: Restore Nuget Packages |
| 23 | + run: dotnet restore FileProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json |
| 24 | + |
| 25 | + - name: Build Code |
| 26 | + run: dotnet build FileProcessor.sln --configuration Release |
| 27 | + |
| 28 | + - name: Run Unit Tests |
| 29 | + run: | |
| 30 | + echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" |
| 31 | + dotnet test "FileProcessor.BusinessLogic.Tests\EstateManagement.BusinessLogic.Tests.csproj" |
| 32 | +
|
| 33 | + - name: Build Docker Images |
| 34 | + run: | |
| 35 | + docker build . --file FileProcessor/Dockerfile --tag stuartferguson/fileprocessor:latest --tag stuartferguson/fileprocessor:${{ steps.get_version.outputs.VERSION }} |
| 36 | +
|
| 37 | + - name: Publish Images to Docker Hub |
| 38 | + run: | |
| 39 | + docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }} |
| 40 | + docker push stuartferguson/fileprocessor:latest |
| 41 | + docker push stuartferguson/fileprocessor:${{ steps.get_version.outputs.VERSION }} |
| 42 | +
|
| 43 | + - name: Publish API |
| 44 | + run: dotnet publish "FileProcessor\FileProcessor.csproj" --configuration Release --output publishOutput |
| 45 | + |
| 46 | + - name: Install Octopus CLI |
| 47 | + run: | |
| 48 | + sudo apt update && sudo apt install --no-install-recommends gnupg curl ca-certificates apt-transport-https && \ |
| 49 | + curl -sSfL https://apt.octopus.com/public.key | sudo apt-key add - && \ |
| 50 | + sudo sh -c "echo deb https://apt.octopus.com/ stable main > /etc/apt/sources.list.d/octopus.com.list" && \ |
| 51 | + sudo apt update && sudo apt install octopuscli |
| 52 | +
|
| 53 | + - name: Pack Files for Octopus |
| 54 | + run: >- |
| 55 | + octo pack |
| 56 | + --outFolder /home/runner/work/FileProcessor/FileProcessor |
| 57 | + --basePath /home/runner/work/FileProcessor/FileProcessor/publishOutput |
| 58 | + --id FileProcessor |
| 59 | + --version ${{ steps.get_version.outputs.VERSION }} |
| 60 | + --format zip |
| 61 | + --verbose |
| 62 | + --logLevel=verbose |
| 63 | +
|
| 64 | + - name: Push Package to Octopus |
| 65 | + run: >- |
| 66 | + octo push |
| 67 | + --server ${{ secrets.OCTOPUS_URL }} |
| 68 | + --apiKey ${{ secrets.OCTOPUS_APIKEY }} |
| 69 | + --package /home/runner/work/FileProcessor/FileProcessor/FileProcessor.${{ steps.get_version.outputs.VERSION }}.zip |
| 70 | + --overwrite-mode IgnoreIfExists |
| 71 | + |
| 72 | + - name: Get Release |
| 73 | + id: getrelease |
| 74 | + uses: octokit/request-action@v2.0.17 |
| 75 | + with: |
| 76 | + route: GET /repos/StuartFerguson/FileProcessor/releases/tags/${{ steps.get_version.outputs.VERSION }} |
| 77 | + env: |
| 78 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + |
| 80 | + - name: Build Release Notes |
| 81 | + id: buildreleasenotes |
| 82 | + uses: gr2m/get-json-paths-action@v1.x |
| 83 | + with: |
| 84 | + json: ${{ steps.getrelease.outputs.data }} |
| 85 | + releasenote: "body" |
| 86 | + |
| 87 | + - name: Create & Deploy Release in Octopus |
| 88 | + run: >- |
| 89 | + octo create-release |
| 90 | + --server ${{ secrets.OCTOPUS_URL }} |
| 91 | + --apiKey ${{ secrets.OCTOPUS_APIKEY }} |
| 92 | + --project "File Processor" |
| 93 | + --version ${{ steps.get_version.outputs.VERSION }} |
| 94 | + --channel Default |
| 95 | + --deployTo Development |
| 96 | + --waitfordeployment |
| 97 | + --deploymenttimeout 00:05:00 |
| 98 | + --releasenotes "${{ steps.buildreleasenotes.outputs.releasenote }}" |
| 99 | + |
| 100 | + #- name: Build and Publish Nuget Packages |
| 101 | + # run: | |
| 102 | + # dotnet pack "EstateManagement.Client\EstateManagement.Client.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release |
| 103 | + # dotnet nuget push Nugets/EstateManagement.Client.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package |
| 104 | + # dotnet pack "EstateManagement.Estate.DomainEvents\EstateManagement.Estate.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release |
| 105 | + # dotnet nuget push Nugets/EstateManagement.Estate.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package |
| 106 | + # dotnet pack "EstateManagement.Merchant.DomainEvents\EstateManagement.Merchant.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release |
| 107 | + # dotnet nuget push Nugets/EstateManagement.Merchant.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package |
| 108 | + # dotnet pack "EstateManagement.Contract.DomainEvents\EstateManagement.Contract.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release |
| 109 | + # dotnet nuget push Nugets/EstateManagement.Contract.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package |
0 commit comments