
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@halospv3/hce.shared-config
Advanced tools
Automate commit message quality, changelogs, and CI/CD releases. Exports a semantic-release shareable configuration deserialized from this package's '.releaserc.yml'. Shared resources for .NET projects are also distributed with this package.
Activity is held up by a rewrite for the
next/3.0.0
branch.A fix for the
2.x
branch may be feasible if all that's wrong is async functions in CJS. The2.x
release channel will not receive feature updates, but fixes and dependency updates are acceptable.
Infrastructure resources shared with other HaloSPV3 repositories.
It is recommended to "install" this repo via Node Package Manager
@halospv3/hce.shared-config
This project is packaged and published via NPM. As such...
npm install --save-dev @halospv3/hce.shared-config
WARNING! Defining a property will overwrite the previous value. Arrays and objects are not merged. You can...
options.preset
) to avoid
modifying the plugins array. Caveat: only some plugins read these properties.extends
. Doing so will allow your IDE to
tell you when a shareable config cannot be found.
- Uses the conventionalcommits preset.
- Releases
main
branch; Pre-releasesdevelop
.- Adds and configures
semantic-release-export-data
to exportnew-release-published
andnew-release-version
to GitHub Actions' outputs.- Adds and configures
@semantic-release/changelog
to update CHANGELOG.md.- Configures
@semantic-release/git
to add README.md and CHANGELOG.md in a release commit if they have changes. Uses GitHub job's token to commit.- Configures
@semantic-release/github
to release all files found in$PWD/publish
.
// releaserc.config.js
import hceSharedConfig from "@halospv3/hce.shared-config"
// modify it however you wish before the export statement!
export default hceSharedConfig;
// releaserc.config.js
export default {
extends: ["@halospv3/hce.shared-config"]
}
// package.json
{
"release": {
"extends": ["@halospv3/hce.shared-config"]
}
}
An extension of our base config. Exports a function with parameters for 'projects to pack' and 'projects to push (to nuget)'. Although
@halospv3/hce.shared-config/semanticReleaseConfigDotnet
can be used viaextends
and configured via thePROJECTS_TO_PUBLISH
andPROJECTS_TO_PACK_AND_PUSH
environment variables, it is recommended to call the function and pass it parameters so errors are caught before they reach production.Differences to the base config:
- Utilizes
@semantic-release/exec
for shell commands.
- Executes
dotnet publish
anddotnet pack
upon the configured projects during theprepare
step.- (WIP) Executes
dotnet nuget sign
duringprepare
upon thedotnet pack
outputs ifprojectsToPackAndPush
is not set tofalse
(default:[]
).- Executes
dotnet nuget push
during thepublish
step.
// releaserc.config.js
import { getConfig } from "@halospv3/hce.shared-config/semanticReleaseConfigDotnet"
/* Caveat: semantic-release will version and release all specified projects under the same Git tags and GitHub releases.
* To version and release them separately, use [https://github.com/pmowrer/semantic-release-monorepo](semantic-release-monorepo).
*/
/* `prepareCmd` will contain command lines to publish
* both Library and Sample to your GitHub release.
* Their `TargetFrameworks` and `RuntimeIdentifiers`
* properties will be evaluated and a command line
* will be added for each unique combination,
* _regardless of compatibility and intended combinations_.
*/
const projectsToPublish = [
"./Library/Library.csproj",
"./Sample/Sample.csproj"
];
/*
* `prepareCmd` will also contain `dotnet pack` and
* `dotnet nuget sign` commands to pack Library to a nupkg.
* `publishCmd` will contain `dotnet nuget push` commands
* to push Library to Nuget.org and GitHub Package Registry.
*/
const projectsToPackAndPush = ["./Library/Library.csproj"];
// runs getConfig and exports its return value
export default getConfig(projectsToPublish, projectsToPackAndPush)
extends
key in a javascript config fileUsing extends
is NOT recommended, but I won't stop you.
Your projects' paths must be assigned to environment variables. See Dotnet Config.
// releaserc.config.js (if {"type": "module"} in package.json)
export default {
extends: ["@halospv3/hce.shared-config"]
}
// releaserc.config.js (if {"type": "commonjs"} in package.json)
module.exports = {
extends: ["@halospv3/hce.shared-config"]
}
release
key in package.json// package.json
// `npm install --save-dev cross-env`
{
"scripts":{
"release":"cross-env PROJECTS_TO_PUBLISH=\"./Library/Library.csproj;./Sample/Sample.csproj\" semantic-release"
},
"release": {
"extends": ["@halospv3/hce.shared-config/semanticReleaseConfigDotnet"]
}
}
Notable Plugin Properties
@semantic-release/commit-analyzer
conventionalcommits
)@semantic-release/release-notes-generator
conventionalcommits
)@semantic-release/changelog
'CHANGELOG.md'
)@semantic-release/git
['README.md', 'CHANGELOG.md', 'package.json', 'package-lock.json', 'npm-shrinkwrap.json']
)@semantic-release/exec
@semantic-release/github
// package.json
{
"commitlint": {
"extends": ["@halospv3/hce.shared-config/commitlintConfig"]
}
}
or
/* eslint-disable import/no-default-export */
import commitlintConfig from '@halospv3/hce.shared-config/commitlintConfig';
export default commitlintConfig;
Then...
npx husky
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'
<Project>
<Import Project="$(HCESharedDir)/dotnet/HCE.Shared.targets"/>
<PropertyGroup>
<RepoRoot Condition="'$(RepoRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), '.git/index'))</RepoRoot>
<HCESharedDir Condition="'$(HCESharedDir)' == ''">$(RepoRoot)node_modules/@halospv3/hce.shared-config/</HCESharedDir>
<!--<GitVersion_Path Condition="'$(GitVersion_Path)' == ''">Path/To/Your/GitVersion.yml</GitVersion_Path>-->
</PropertyGroup>
</Project>
These may evaluate to the following:
Property | Evaluated Value |
---|---|
RepoRootDir | c:\Repos\HaloSPV3\HCE.Shared\ |
HCESharedDir | c:\Repos\HaloSPV3\HCE.Shared\node_modules\@halospv3\hce.shared-config\ |
Note: Already included when importing HCE.Shared.targets If you don't import HCE.Shared.targets, you may import HCE.Shared.CI.props or define your own conditional property group.
If you want properties set only in a CI/CD environment (e.g. a GitHub workflow), add the following conditional property group to the props file:
<Project>
<PropertyGroup>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(CI)' == 'true' ">
<Configuration>Release</Configuration>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
</PropertyGroup>
</Project>
Any properties added to this conditional property group will only be evaluated when
$(CI)
is defined either as a property or as an environment variable. This is most useful for properties such asContinuousIntegrationBuild
.
By default, GitVersion will search only the "current directory" for GitVersion.yml
. GitVersion has
a lesser-known CLI argument, "Path" which allows users to specify the path to GitVersion.yml
. The
NuGet package GitVersion.MSBuild
exposes this as the read-write property $(GitVersion_Path)
.
If you're satisfied by dotnet/GitVersion.yml, you can configure GitVersion to use this config file. GitVersion does not have 'extend' functionality typical of Node.js packages.
You can...
...define it yourself
<Project>
<PropertyGroup>
<GitVersion_Path>$(ProjectRootDir)/node_modules/@halospv3/hce.shared-config/dotnet/GitVersion.yml</GitVersion_Path>
</PropertyGroup>
</Project>
...import HCE.Shared.props
<Project>
<Import Project="$(HCESharedDir)/dotnet/HCE.Shared.props">
</Project>
...import HCE.Shared.Targets (which imports HCE.Shared.props)
<Project>
<Import Project="$(HCESharedDir)/dotnet/HCE.Shared.props">
</Project>
If you want to use this information in other Semantic Release steps, you'll need
semantic-release-export-data
.
Run the following to preview the version:
npx semantic-release --dry-run --plugins "@semantic-release/commit-analyzer,semantic-release-export-data"
If the first plugin doesn't run into any issues and infers a version bump from unreleased commits, it will print the next version to the console. The second plugin will export the next version and other information as GitHub Action Step outputs.
Add the following to package.json
:
{
"private": true,
}
See callable workflows such as dotnet-ci
jobs:
release:
steps:
- uses: actions/checkout@v3
- name: dotnet build/publish; copy release artifacts to './publish/'
uses: ./node_modules/@halospv3/hce.shared/dotnet/.github/workflows/dotnet-release.yml
with:
projects:
- src/lib/lib.csproj
- src/lib-sample/sample.csproj
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.