Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@ jobs:
with:
environmentVariablesYaml: |
ZF_NUGET_PUBLISH_SOURCE: ${{ (startsWith(github.ref, 'refs/tags/') || github.event.inputs.forcePublicNugetDestination == 'true') && 'https://api.nuget.org/v3/index.json' || format('https://nuget.pkg.github.com/{0}/index.json', github.repository_owner) }}
# NuGet.org takes a short-lived key from Trusted Publishing (GitHub Actions OIDC), which the Publish job asks
# for: no long-lived key is stored. The policy on nuget.org (owner corvus-dotnet) names this repository and
# build.yml, and NUGET_TRUSTED_PUBLISHING_USER is the nuget.org profile name of the user who created it.
ZF_BUILD_DOTNET_NUGET_USE_TRUSTED_PUBLISHING: "${{ startsWith(github.ref, 'refs/tags/') || github.event.inputs.forcePublicNugetDestination == 'true' }}"
ZF_BUILD_DOTNET_NUGET_TRUSTED_PUBLISHING_USER: "${{ vars.NUGET_TRUSTED_PUBLISHING_USER }}"
BUILDVAR_BuildWebsite: "false"
BUILDVAR_IsPreviewDeployment: "${{ github.event_name == 'pull_request' }}"
BUILDVAR_BasePathPrefix: "${{ github.event_name == 'pull_request' && format('/{0}/pr-preview/pr-{1}', github.event.repository.name, github.event.pull_request.number) || format('/{0}', github.event.repository.name) }}"
secretsYaml: |
NUGET_API_KEY: "${{ startsWith(github.ref, 'refs/tags/') && secrets.NUGET_APIKEY || secrets.BUILD_PUBLISHER_PAT }}"
# GitHub Packages only: NuGet.org uses Trusted Publishing (above), which ignores this key.
NUGET_API_KEY: "${{ secrets.BUILD_PUBLISHER_PAT }}"
# TODO: Review approach to enable Vellum to be downloaded
VELLUM_DOWNLOAD_TOKEN: "${{ secrets.ENDJIN_PACKAGES_TOKEN }}"
secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }}
Expand Down Expand Up @@ -182,6 +188,10 @@ jobs:
testPhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }}
packagePhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }}
publishPhaseEnv: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }}
# The shared pipeline's Publish job cannot ask for an OIDC token (it does not have 'id-token: write', and adding
# it there would stop every caller that does not grant it), so it runs an empty task and the Publish job below
# publishes.
publishPhaseTasks: RunFirst
additionalCachePaths: ${{ needs.setCachePathsConfig.outputs.additionalCachePaths }}
# Build the documentation website in a parallel post-compile job
postCompilePhaseTasks: BuildWebsite
Expand All @@ -201,6 +211,50 @@ jobs:
postCompilePhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }}
secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }}

# Publishes the packages the build's package phase made, as the shared pipeline's Publish job would, but in a job of
# this workflow, so that it can have 'id-token: write' for NuGet.org Trusted Publishing (ZeroFailed.Build.DotNet's
# PublishNuGetPackages exchanges the OIDC token for a key valid for an hour). The packages come from the run's
# Actions cache: the paths and the cross-OS setting are the package phase's, which a restore must match. The
# repository's PrePublish task fails a publish that finds no packages.
publish:
name: Publish
needs:
- prepareConfig
- setCachePathsConfig
- build
if: >-
!cancelled() && needs.build.result == 'success' &&
(github.event.inputs.forcePublish == 'true' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
permissions:
contents: write # the GitHub release
packages: write # GitHub Packages
id-token: write # NuGet.org Trusted Publishing
steps:
- uses: endjin/Endjin.RecommendedPractices.GitHubActions/actions/common-pre-scripted-build@main
with:
additionalEnvVars: ${{ needs.prepareConfig.outputs.RESOLVED_ENV_VARS }}
additionalSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }}
secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }}
- uses: endjin/Endjin.RecommendedPractices.GitHubActions/actions/run-scripted-build@main
with:
displayName: Publish Packages
buildScriptPath: ./build.ps1
netSdkVersion: '11.0.100-rc.1.26425.128'
additionalNetSdkVersion: |
8.0.x
9.0.x
10.0.x
tasks: Publish
inputCacheKeySuffix: package
inputCachePaths: |
_packages
${{ needs.setCachePathsConfig.outputs.additionalCachePaths }}
enableCrossOsCaching: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_API_KEY: ${{ env.NUGET_API_KEY }}

# A change to the documentation alone builds the website without the .NET build, its test matrix and its packages:
# the code-sample catalog check that the .NET build runs first, then BuildWebsite with BUILDVAR_WebsiteBuildsDotNet,
# so that docs/website/build.ps1 compiles the libraries it documents itself. The website-output artifact is the one
Expand Down
18 changes: 15 additions & 3 deletions VERSIONHISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Version History

## V5.8.3
## V5.8.4

V5.8.4 is the first release published to NuGet.org since V5.8.0, and it publishes with NuGet.org Trusted Publishing. V5.8.1, V5.8.2 and V5.8.3 were tagged, and have GitHub releases, but their packages were never published to NuGet.org: the API key the release build used had expired, so each tag build's push was refused. Those versions are skipped on NuGet.org. V5.8.4 has no changes of its own beyond how it is published, so it ships everything in the three, which are listed below:

- **V5.8.3:** every `format` check follows the grammar the format names, as the JSON-Schema-Test-Suite now tests it (`date-time`, `time`, `duration`, `email`, `idn-email`, `idn-hostname` with the UTS #46 mapping, `ipv6`, the URI and IRI formats, which the `Utf8Uri` types also check, and `uri-template`), and V4 uses V5's format checks. V4 writes an offset as `+01:00`, never `+01`, and treats `format` as an annotation by default in draft 2019-09.
- **V5.8.2:** a string that is not well-formed text is not valid and never makes validation throw; the code generators set the match limit of the regular expressions they write; generated mutable types have `ApplyDefaults()`; JSON Patch applies to a generated type's mutable element; generated array types are read-only collections of their items; and smaller fixes from the backlog.
- **V5.8.1:** a property lookup that could go stale in a `JsonDocumentBuilder`, and a JSONata string escaped twice in an object or array, are fixed, and JSONata is brought up to date with the official test suite.

### Other changes

- **Releases publish to NuGet.org with Trusted Publishing.** The `Publish` job of `build.yml` exchanges a GitHub Actions OIDC token for a NuGet.org key that is valid for an hour, through ZeroFailed.Build.DotNet, so no long-lived key is stored and none can expire. The policy on nuget.org belongs to the `corvus-dotnet` organisation. [docs/ReleaseProcess.md](docs/ReleaseProcess.md) describes the setup.

## V5.8.3 (not published to NuGet.org; shipped in V5.8.4)

V5.8.3 makes every `format` check read the grammar the format names, as the JSON-Schema-Test-Suite now tests it, and makes the V4 engine use the same checks as V5.

Expand All @@ -11,7 +23,7 @@ V5.8.3 makes every `format` check read the grammar the format names, as the JSON
- **V4 writes an offset with hours and minutes.** `JsonDateTime` and `JsonTime` wrote an offset of whole hours as `+01`, which is not RFC 3339. They write `+01:00`. Issue [#597](https://github.com/corvus-dotnet/Corvus.JsonSchema/issues/597) made `+01` valid in V4.3.7; it is not valid again, as RFC 3339 and the test suite require.
- **In V4, `format` is an annotation by default in draft 2019-09.** A schema without `$schema` asserted `format` in draft 2019-09, because the draft's format vocabulary used the assertion form of the keyword. It now uses the annotation form, as draft 2020-12 and V5 do. Generation with `alwaysAssertFormat` (the default) still asserts it.

## V5.8.2
## V5.8.2 (not published to NuGet.org; shipped in V5.8.4)

V5.8.2 stops validation throwing on a string that is not well-formed text, lets a generation set the match limit of its regular expressions, and gives generated types `ApplyDefaults()`, read-only collections for arrays and JSON Patch support. It also fixes a number of smaller issues from the backlog.

Expand All @@ -36,7 +48,7 @@ V5.8.2 stops validation throwing on a string that is not well-formed text, lets
- The TypeScript and Rust test suite runners check the 73 leap-second cases, and the documents say which exclusions each runner makes. See [#988](https://github.com/corvus-dotnet/Corvus.JsonSchema/issues/988) and [#987](https://github.com/corvus-dotnet/Corvus.JsonSchema/issues/987).
- The regular expression translator pages describe where the translation is still used since V5.8.0, and the pattern conformance page records that TypeScript keeps the host's `RegExp` ([#1026](https://github.com/corvus-dotnet/Corvus.JsonSchema/issues/1026)).

## V5.8.1
## V5.8.1 (not published to NuGet.org; shipped in V5.8.4)

V5.8.1 fixes a property lookup that could go stale in a `JsonDocumentBuilder`, and a JSONata string that was escaped twice when it was placed in an object or array. It also brings the JSONata implementation up to date with the official test suite and fixes the cases where it answered differently.

Expand Down
15 changes: 13 additions & 2 deletions docs/ReleaseProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,22 @@ Branch protection requires the `.NET build gate` job. It passes when the build s

Publishing is conditional based on whether the build was triggered by a tag:

| Trigger | NuGet source | API key |
| Trigger | NuGet source | Authentication |
|---------|-------------|---------|
| Tag (`refs/tags/*`) | `https://api.nuget.org/v3/index.json` | `NUGET_APIKEY` secret |
| Tag (`refs/tags/*`) | `https://api.nuget.org/v3/index.json` | NuGet.org Trusted Publishing (no stored key) |
| Branch / PR | `https://nuget.pkg.github.com/{owner}/index.json` | `BUILD_PUBLISHER_PAT` secret |

NuGet.org publishing uses [Trusted Publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing): the
`Publish` job of `build.yml` (which has `id-token: write`) exchanges a GitHub Actions OIDC token for a NuGet.org key
that is valid for an hour, through ZeroFailed.Build.DotNet's `PublishNuGetPackages`. It needs:

- a Trusted Publishing policy on nuget.org, owned by the `corvus-dotnet` organisation, for the repository owner
`corvus-dotnet`, the repository `Corvus.JsonSchema` and the workflow file `build.yml` (no environment);
- the repository variable `NUGET_TRUSTED_PUBLISHING_USER`, set to the nuget.org profile name (not the email address)
of the user who created the policy, who must stay a member of the organisation.

The shared pipeline's own Publish job runs an empty task (`RunFirst`): it cannot have `id-token: write`.

This means:
- **Stable releases** go to NuGet.org when a version tag is pushed
- **Pre-release packages** go to GitHub Packages for every branch build
Expand Down
10 changes: 5 additions & 5 deletions docs/code-sample-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1501,11 +1501,11 @@ main-docs:
- path: "docs/ReleaseProcess.md"
blocks:
- {index: 0, language: yaml, lines: [18, 36]}
- {index: 1, language: powershell, lines: [124, 132]}
- {index: 2, language: bash, lines: [199, 204]}
- {index: 3, language: sh, lines: [610, 612]}
- {index: 4, language: xml, lines: [745, 749]}
- {index: 5, language: xml, lines: [753, 755]}
- {index: 1, language: powershell, lines: [135, 143]}
- {index: 2, language: bash, lines: [210, 215]}
- {index: 3, language: sh, lines: [621, 623]}
- {index: 4, language: xml, lines: [756, 760]}
- {index: 5, language: xml, lines: [764, 766]}
- path: "docs/RunningTests.md"
blocks:
- {index: 0, language: powershell, lines: [7, 10]}
Expand Down
Loading