Update Newtonsoft.Json dependency from 13.0.3 to 13.0.4 #2346
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build Octopus Clients" | |
# Controls when the action will run. | |
on: | |
push: | |
# Triggers the workflow on pushes to master | |
branches: | |
- master | |
tags-ignore: | |
- '**' | |
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 | |
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 | |
env: | |
# These codesigning env vars must match the parameter names in Build.cs | |
AzureKeyVaultUrl: ${{ secrets.AZURE_KEYVAULT_URL }} | |
AzureKeyVaultAppId: ${{ secrets.AZURE_KEYVAULT_APPID }} | |
AzureKeyVaultAppSecret: ${{ secrets.AZURE_KEYVAULT_APPSECRET }} | |
AzureKeyVaultCertificateName: ${{ secrets.AZURE_KEYVAULT_CERTIFICATENAME }} | |
AzureKeyVaultTenantId: ${{ secrets.AZURE_KEYVAULT_TENANTID }} | |
outputs: | |
octoversion_fullsemver: ${{ steps.build.outputs.octoversion_fullsemver }} | |
skip-release-and-release-note: ${{ steps.github-tag.outputs.skip-release-and-release-note }} | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 # all | |
- name: Setup .NET 8.0 | |
uses: actions/setup-dotnet@v5 | |
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@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1 | |
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@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1 | |
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 8.0 unit test report | |
uses: dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1 | |
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@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1 | |
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@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1 | |
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 8.0 E2E test report | |
uses: dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1 | |
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@v4 | |
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@v8 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const commitMessage = context.payload.head_commit?.message?.trim() || ''; | |
const skipReleaseAndReleaseNote = /^skip-release-and-release-note:\s*true\s*$/mi.test(commitMessage); | |
core.setOutput('skip-release-and-release-note', skipReleaseAndReleaseNote); | |
if (skipReleaseAndReleaseNote) { | |
// Abort early: the commit is marked as not significant enough to trigger a release or be included in | |
// release notes, so we don't need a tag either | |
return; | |
} | |
await 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@v5 | |
- name: Setup .NET 8 | |
uses: actions/setup-dotnet@v5 | |
with: | |
dotnet-version: 8.0.x | |
- name: Run unit tests 🏗 | |
shell: bash | |
run: dotnet test ./source/Octopus.Client.Tests/Octopus.Client.Tests.csproj --framework net8.0 --configuration:Release --logger:"trx;LogFilePrefix=Linux" --results-directory ./TestResults | |
- name: Linux unit test report | |
uses: dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3 # v2.1.1 | |
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 | |
deploy_nuget: | |
name: Upload nuget packages to Octopus Deploy and create release if required | |
runs-on: ubuntu-latest | |
if: >- # Only run if we want a release or if it's a nightly build (nightly pushes to Octopus to exercise the pipeline, but no actual release gets created) | |
${{ | |
needs.build.outputs.skip-release-and-release-note == 'false' || | |
github.event_name == 'schedule' | |
}} | |
permissions: | |
id-token: write # Required to obtain the ID token from GitHub Actions | |
actions: read # Required to download artifact | |
contents: write # Required to create releases | |
env: | |
OCTOPUS_SPACE: "Core Platform" | |
SHOULD_CREATE_RELEASE: ${{ github.ref == 'refs/heads/master' && !contains(needs.build.outputs.octoversion_fullsemver, '-') }} | |
needs: [ build, test-linux ] | |
steps: | |
- if: ${{ env.SHOULD_CREATE_RELEASE == 'true' }} | |
uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 # fetching everything is unfortunately required to get tags | |
- name: Download nuget package artifact | |
uses: actions/download-artifact@v5 | |
with: | |
name: OctoClientsNuget | |
path: ./artifacts/ | |
- name: Login to Octopus Deploy 🐙 | |
uses: OctopusDeploy/login@e485a40e4b47a154bdf59cc79e57894b0769a760 # v1 | |
with: | |
server: ${{ secrets.OCTOPUS_URL }} | |
service_account_id: 8b5a7f0f-c2c9-48de-a0f6-74d83669accf | |
- name: Push to Octopus 🐙 | |
uses: OctopusDeploy/push-package-action@e2050621dbc1f83e223b6a5ca7ff2ec3dd6809e8 # 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@1c58525ed52e1af84afa68eb495486a52661d6da # v3 | |
with: | |
project: "Octopus.Client" | |
packages: | | |
Octopus.Client:${{ needs.build.outputs.octoversion_fullsemver }} | |
# We use jc to convert git log output into something machine readable, as git can't natively do so. | |
# jq is preinstalled in GitHub actions, but jc (https://github.com/kellyjonbrazil/jc) is not. | |
- if: ${{ env.SHOULD_CREATE_RELEASE == 'true' }} | |
name: Set up python | |
uses: actions/setup-python@v6 | |
with: | |
python-version: '3.13' | |
- if: ${{ env.SHOULD_CREATE_RELEASE == 'true' }} | |
name: Install jc | |
run: pip3 install jc==1.25.5 | |
- if: ${{ env.SHOULD_CREATE_RELEASE == 'true' }} | |
name: Create GitHub Release 🚀 | |
uses: actions/github-script@v8 | |
with: | |
script: | | |
const { owner, repo } = context.repo; | |
const tagName = '${{ needs.build.outputs.octoversion_fullsemver }}'; | |
// Look up the tag associated with the last release in order to get commit messages since then, for release notes. | |
let lastReleaseTag = null; | |
try { | |
lastReleaseTag = (await github.rest.repos.getLatestRelease({ owner, repo })).data.tag_name; | |
} catch (error) { | |
if (error.status !== 404) throw error; | |
console.log('No previous release found'); | |
} | |
console.log('Last release tag:', lastReleaseTag); | |
// Use jc to convert git log output into JSON we can reliably parse | |
const gitLogArgs = lastReleaseTag ? [`${lastReleaseTag}..`] : []; | |
const { stdout: gitCommitsJson } = await exec.getExecOutput('jc', ['--raw', 'git', 'log', '--reverse', ...gitLogArgs]); | |
const commitsSinceLastRelease = JSON.parse(gitCommitsJson); | |
// Of the commits since the last release, get the first line of each message that doesn't opt out of release notes | |
const releaseNotes = commitsSinceLastRelease | |
.map(commit => commit.message) | |
.filter(message => !/^\s*skip-release-and-release-note:\s*true\s*$/mi.test(message)) | |
.map(message => `- ${message.split('\n')[0]}`); | |
// Build release body | |
const body = `## Release Notes: | |
${releaseNotes.join('\n')} | |
## NuGet Packages: | |
- [Octopus.Server.Client.${tagName}](https://www.nuget.org/packages/Octopus.Server.Client/${tagName}) | |
- [Octopus.Client.${tagName}](https://www.nuget.org/packages/Octopus.Client/${tagName})`; | |
const release = await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: tagName, | |
name: `Octopus Client Release ${tagName}`, | |
body: body, | |
draft: false, | |
prerelease: false | |
}); | |
console.log(`Release ${tagName} created successfully`); | |
- if: ${{ env.SHOULD_CREATE_RELEASE == 'true' }} | |
name: Attach NuGet packages to release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload '${{ needs.build.outputs.octoversion_fullsemver }}' ./artifacts/*.nupkg |