Skip to content

Build Octopus Clients #1698

Build Octopus Clients

Build Octopus Clients #1698

Workflow file for this run

name: "Build Octopus Clients"
# Controls when the action will run.
on:
push:
# Triggers the workflow on pull request events and merges/pushes to master
branches:
- master
- release/*
tags-ignore:
- '**'
pull_request:
types: [opened, synchronize, reopened]
schedule:
# Daily 5am australian/brisbane time
- cron: '0 19 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Pass branch and patch number to Nuke OctoVersion
# (for pull_request events we override the /refs/pull/xx/merge branch to the PR's head branch)
env:
OCTOVERSION_CurrentBranch: ${{ github.head_ref || github.ref }}
OCTOVERSION_Patch: ${{ github.run_number }}
AssentNonInteractive: true
jobs:
build:
name: Build Octopus Clients
runs-on: windows-latest
outputs:
octoversion_fullsemver: ${{ steps.build.outputs.octoversion_fullsemver }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # all
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Append OCTOVERSION_CurrentBranch with -nightly (for scheduled)
if: github.event_name == 'schedule'
run: echo "OCTOVERSION_CurrentBranch=${{ env.OCTOVERSION_CurrentBranch }}-nightly-$(Get-Date -Format 'yyyyMMddHHmmss')" >> $env:GITHUB_ENV
# Note: Because this step runs on Windows, this will also run all of the tests on Windows
- name: Nuke Build 🏗
id: build
shell: bash
run: ./build.cmd
# Unit test reports
- name: Windows .NET 4.6.2 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .Net 4.6.2 unit test results
path: ./TestResults/Win_net462_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 4.8 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows.Net 4.8 unit test results
path: ./TestResults/Win_net48_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 6.0 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .Net 6.0 unit test results
path: ./TestResults/Win_net6.0_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 8.0 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .Net 8.0 unit test results
path: ./TestResults/Win_net8.0_*.trx
reporter: dotnet-trx
fail-on-error: true
# E2E test reports
- name: Windows .NET 4.6.2 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 4.6.2 E2E test results
path: ./TestResults/Win-E2E_net462_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 4.8 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 4.8 E2E test results
path: ./TestResults/Win-E2E_net48_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 6.0 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 6.0 E2E test results
path: ./TestResults/Win-E2E_net6.0_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .NET 8.0 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .NET 8.0 E2E test results
path: ./TestResults/Win-E2E_net8.0_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v3
with:
name: OctoClientsNuget
path: ./artifacts/*.nupkg
- name: Tag release (when not pre-release) 🏷️
id: github-tag
if: ${{ !contains( steps.build.outputs.octoversion_fullsemver, '-' ) }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.build.outputs.octoversion_fullsemver }}",
sha: context.sha
})
test-linux:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Run unit tests 🏗
shell: bash
run: dotnet test ./source/Octopus.Client.Tests/Octopus.Client.Tests.csproj --configuration:Release --logger:"trx;LogFilePrefix=Linux" --results-directory ./TestResults
- name: Linux unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Linux unit tests results
path: ./TestResults/*.trx
reporter: dotnet-trx
fail-on-error: true
test-macos:
name: Unit test on Mac OS
needs: build
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Update Dylib Path
run: echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/homebrew/lib/" >> $GITHUB_ENV
# TODO(tmm): Tests were failing until homebrew library was added to libray path
- name: Update Dylib Path
run: echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/homebrew/lib/" >> $GITHUB_ENV
- name: Run unit tests 🏗
shell: bash
run: dotnet test ./source/Octopus.Client.Tests/Octopus.Client.Tests.csproj --configuration:Release --logger:"trx;LogFilePrefix=Mac" --results-directory ./TestResults
- name: Mac OS unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Mac OS unit test results
path: ./TestResults/*.trx
reporter: dotnet-trx
fail-on-error: true
outcome:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Build and test outcome
needs: [ build, test-linux, test-macos ]
steps:
- if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}
run: exit 1
deploy_nuget:
name: Upload nuget packages to Octopus Deploy
runs-on: ubuntu-latest
permissions:
id-token: write # Required to obtain the ID token from GitHub Actions
actions: read # Required to download artifact
env:
OCTOPUS_SPACE: "Core Platform"
needs: [ build, test-linux, test-macos ]
steps:
- name: Download nuget package artifact
uses: actions/download-artifact@v3
with:
name: OctoClientsNuget
path: ./artifacts/
- name: Login to Octopus Deploy 🐙
uses: OctopusDeploy/login@v1
with:
server: ${{ secrets.OCTOPUS_URL }}
service_account_id: 8b5a7f0f-c2c9-48de-a0f6-74d83669accf
- name: Push to Octopus 🐙
uses: OctopusDeploy/push-package-action@v3
with:
packages: |
./artifacts/Octopus.Client.${{ needs.build.outputs.octoversion_fullsemver }}.nupkg
./artifacts/Octopus.Server.Client.${{ needs.build.outputs.octoversion_fullsemver }}.nupkg
- name: Create Release in Octopus 🐙
uses: OctopusDeploy/create-release-action@v3
with:
project: "Octopus.Client"
packages: |
Octopus.Client:${{ needs.build.outputs.octoversion_fullsemver }}