@halospv3/hce.shared-config 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [2.0.1](https://github.com/halospv3/hce.shared/compare/v2.0.0...v2.0.1) (2024-03-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @semantic-release/commit-analyzer to v12 ([87c6d12](https://github.com/halospv3/hce.shared/commit/87c6d12c3ab5243e50a0c1b0cf3dafd6c4c20ffa))
7
+ * **dotnet:** try making the '$(RepoRoot)/publish' directory before zipping ([0241146](https://github.com/halospv3/hce.shared/commit/024114698c89f557513a61400729a609d7637bf0))
8
+
1
9
  ## [2.0.0](https://github.com/halospv3/hce.shared/compare/v1.2.7...v2.0.0) (2024-03-17)
2
10
 
3
11
 
package/README.md CHANGED
@@ -3,74 +3,53 @@ Infrastructure resources shared with other HaloSPV3 repositories.
3
3
 
4
4
  It is recommended to "install" this repo via [Node Package Manager](#npm)
5
5
 
6
- ## NPM
6
+ ## Usage
7
7
 
8
- ### Usage
9
8
 
10
- `npm install --save-dev HaloSPV3/HCE.Shared`
9
+ ### 1. Install `@halospv3/hce.shared-config`
11
10
 
12
- See [package.json](package.json), [src/index.ts](src/index.ts), and [static/.releaserc.yml](static/.releaserc.yml)
11
+ This project is packaged and published via NPM. As such...
12
+ ```sh
13
+ npm install --save-dev @halospv3/hce.shared-config
14
+ ```
15
+
16
+ ### 2. Customize Semantic Release
17
+
18
+ WARNING! Defining a property will *overwrite* the previous value. Arrays and objects are *not* merged. You can...
19
+ - Assign to top-level variables to avoid modifying the plugins array.
20
+ - Write your config in CJS to manually merge objects and arrays.
21
+
22
+ Configs:
23
+ - `hce.shared-config`: [static/.releaserc.yml](static/.releaserc.yml)
24
+ - [dotnet/.releaserc.cjs](dotnet/.releaserc.cjs) based on [BinToss/GroupBox.Avalonia's Semantic Release config](https://github.com/BinToss/GroupBox.Avalonia).
13
25
 
14
- #### Set Up CommitLint
26
+ ### 3. Set Up CommitLint
15
27
 
16
28
  ```json
17
29
  // package.json
30
+ // body-max-line-length is now a Warning instead of an Error.
18
31
  {
19
32
  "commitlint": {
20
33
  "extends": [
21
- "@commitlint/config-conventional"
22
- ]
34
+ "@commitlint/config-conventional"
35
+ ],
36
+ "rules": {
37
+ "body-max-line-length": [
38
+ 1,
39
+ "always",
40
+ 100
41
+ ]
42
+ }
23
43
  }
24
44
  }
25
45
  ```
26
46
 
27
- ```bash
28
- npx husky install
47
+ ```sh
48
+ npx husky
29
49
  npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'
30
50
  ```
31
51
 
32
- ### Help
33
-
34
- #### Need your VersionInfo before the actual release?
35
-
36
- Make sure you are synced up before doing a dry-run! Semantic-release will fail before printing the version if you aren't synced with the remote!
37
- Yes, I know that's ridiculous.
38
- Run `npx semantic-release --dry-run --plugins "@semantic-release/commit-analyzer,semantic-release-export-data"`
39
- 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.
40
- The [second plugin](https://github.com/felipecrs/semantic-release-export-data#readme) will export the next version and other information as GitHub Action Step exports.
41
-
42
- #### Don't want to publish a Node package?
43
-
44
- Add the following to your `package.json`:
45
- ```json
46
- {
47
- "private": true,
48
- }
49
- ```
50
-
51
- ## .NET
52
-
53
- See [dotnet/](dotnet/)
54
-
55
- GitHub Actions workflow examples are in [dotnet/.github/workflows/](dotnet/.github/workflows/).
56
-
57
- #### TODO:
58
-
59
- Eventually, I hope to make boilerplate workflows useable from via relative paths e.g.
60
- ```yml
61
- jobs:
62
- release:
63
- steps:
64
- - uses: actions/checkout@v3
65
- - name: dotnet build/publish; copy release artifacts to './publish/'
66
- uses: ./node_modules/@halospv3/hce.shared/dotnet/.github/workflows/dotnet-release.yml
67
- with:
68
- projects:
69
- - src/lib/lib.csproj
70
- - src/lib-sample/sample.csproj
71
- ```
72
-
73
- ### Directory.Build.props
52
+ ### 4. (dotnet) Add/Edit Directory.Build.props
74
53
 
75
54
  Add the file `Directory.Build.props` to your repository's root directory or solution directory if you haven't already.
76
55
  Then, add the following properties:
@@ -78,7 +57,7 @@ Then, add the following properties:
78
57
  <Project>
79
58
  <PropertyGroup>
80
59
  <ProjectRootDir>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), '.git/index'))</ProjectRootDir>
81
- <HCESharedDir>$(ProjectRootDir)/node_modules/@halospv3/hce.shared/</HCESharedDir>
60
+ <HCESharedDir>$(ProjectRootDir)/node_modules/@halospv3/hce.shared-config/</HCESharedDir>
82
61
  </PropertyGroup>
83
62
  </Project>
84
63
  ```
@@ -87,10 +66,12 @@ These may evaluate to the following:
87
66
  | Property | Evaluated Value|
88
67
  | - | - |
89
68
  |`ProjectRootDir` | `c:\Repos\HaloSPV3\HCE.Shared\` |
90
- |`HCESharedDir`| `c:\Repos\HaloSPV3\HCE.Shared\node_modules\@halospv3\hce.shared\` |
69
+ |`HCESharedDir`| `c:\Repos\HaloSPV3\HCE.Shared\node_modules\@halospv3\hce.shared-config\` |
91
70
 
92
71
  <br/>
93
72
 
73
+ #### CI/CD-Only Properties
74
+
94
75
  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:
95
76
  ```xml, diff
96
77
  <Project>
@@ -101,16 +82,81 @@ If you want properties set only in a CI/CD environment (e.g. a GitHub workflow),
101
82
  <PropertyGroup Condition=" '$(CI)' == 'true' ">
102
83
  <Configuration>Release</Configuration>
103
84
  <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
85
+ <Deterministic>true</Deterministic>
104
86
  </PropertyGroup>
105
87
  </Project>
106
88
  ```
107
89
  > 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 as `ContinuousIntegrationBuild`.
108
90
 
109
- ### GitVersion
91
+ #### GitVersion
110
92
 
111
93
  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)`.
94
+
95
+ If you're satisfied by [dotnet/GitVersion.yml](dotnet/GitVersion.yml), you can configure GitVersion to use this config file. GitVersion does not have 'extend' functionality typical of Node.js packages.
112
96
  ```xml
113
97
  <PropertyGroup>
114
- <GitVersion_Path>../SiblingDir/GitVersion.yml</GitVersion_Path>
98
+ <GitVersion_Path>$(ProjectRootDir)/node_modules/@halospv3/hce.shared-config/dotnet/GitVersion.yml</GitVersion_Path>
115
99
  </PropertyGroup>
100
+ ```
101
+
102
+ ## Tips
103
+
104
+ ### Need your VersionInfo before the actual release?
105
+
106
+ If you want to use this information in other Semantic Release steps, you'll need `semantic-release-export-data`.
107
+ ```sh
108
+ npm i -D semantic-release-export-data
109
+ ```
110
+
111
+ Run the following to preview the version:
112
+ ```sh
113
+ npx semantic-release --dry-run --plugins "@semantic-release/commit-analyzer,semantic-release-export-data"
114
+ ```
115
+ 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.
116
+ The [second plugin](https://github.com/felipecrs/semantic-release-export-data#readme) will export the next version and other information as GitHub Action Step exports.
117
+
118
+ ### Don't intend to publish a Node package?
119
+
120
+ Add the following to `package.json`:
121
+ ```json
122
+ {
123
+ "private": true,
124
+ }
125
+ ```
126
+
127
+ ## TODO:
128
+
129
+ ### Reusable, configurable GitHub workflows
130
+
131
+ ```yml
132
+ jobs:
133
+ release:
134
+ steps:
135
+ - uses: actions/checkout@v3
136
+ - name: dotnet build/publish; copy release artifacts to './publish/'
137
+ uses: ./node_modules/@halospv3/hce.shared/dotnet/.github/workflows/dotnet-release.yml
138
+ with:
139
+ projects:
140
+ - src/lib/lib.csproj
141
+ - src/lib-sample/sample.csproj
142
+ ```
143
+
144
+ ### Ease Semantic Release Configuration
145
+
146
+ JSON/YAML configs *could* have merge-edit capabilities driven by data from custom, top-level properties. Each property would contain the command moniker and the config data (parameters) similar to RPC implementations.
147
+ This will require quite a bit of datatype validation behind the scenes.
148
+ ```json
149
+ {
150
+ "modify_plugins": {
151
+ "op": "Append",
152
+ "data": [
153
+ [
154
+ "newplugin",
155
+ {
156
+ "newpluginoption": true
157
+ }
158
+ ]
159
+ ]
160
+ }
161
+ }
116
162
  ```
@@ -0,0 +1,34 @@
1
+ # inspired by https://github.com/GitTools/GitVersion/blob/main/.github/workflows/_unit_tests.yml
2
+ on:
3
+ workflow_call:
4
+ env:
5
+ DOTNET_ROLL_FORWARD: "Major"
6
+
7
+ jobs:
8
+ unit_test:
9
+ name: Unit Tests (${{ matrix.os }})
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ os: [windows-latest, ubuntu-latest, macos-latest]
14
+
15
+ runs-on: ${{ matrix.os }}
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - uses: actions/setup-node@v4
22
+ with:
23
+ cache: "npm"
24
+ check-latest: true
25
+ node-version-file: package.json
26
+ - run: npm i -g npm@latest
27
+
28
+ - run: npm ci
29
+
30
+ - uses: actions/setup-dotnet@v4.0.0
31
+ with:
32
+ dotnet-version: "8.x"
33
+
34
+ - run: dotnet test
@@ -0,0 +1,22 @@
1
+ # Inspired by https://github.com/GitTools/GitVersion/blob/main/.github/workflows/ci.yml
2
+
3
+ name: CI
4
+
5
+ on:
6
+ push:
7
+ branches-ignore: # if CI must run on these branches, Release will call CI
8
+ - main
9
+ - develop
10
+ pull_request:
11
+ workflow_call:
12
+
13
+ env:
14
+ DOTNET_ROLL_FORWARD: "Major"
15
+ DOTNET_CLI_TELEMETRY_OPTOUT: 1
16
+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
17
+ DOTNET_NOLOGO: 1
18
+
19
+ jobs:
20
+ unit_test:
21
+ name: Unit Test
22
+ uses: ./.github/workflows/_unit_test.yml
@@ -1,9 +1,8 @@
1
+ # Test changes locally with https://github.com/nektos/act
1
2
  name: dotnet-release
2
3
 
3
4
  # TODO
4
- # - Get AssemblyName, RuntimeIdentifier (RID) from Directory.Build.props, *.csproj
5
5
  # - Allow workflows to be driven by the project(s)
6
- # - support multiple ASSEMBLYNAME parameters for matrices
7
6
 
8
7
  on:
9
8
  push:
@@ -13,60 +12,42 @@ on:
13
12
  - "**/*.md"
14
13
  - "**/*.txt"
15
14
 
16
- permissions:
17
- contents: write
18
- issues: write
19
- pull-requests: write
20
-
21
15
  jobs:
16
+ ci:
17
+ name: CI # run test.yml. If it fails, this job fails.
18
+ uses: ./.github/workflows/ci.yml
22
19
  release:
20
+ needs: [ci] # start 'release' if 'ci' completes successfully
23
21
  runs-on: ubuntu-latest
24
- strategy: # TODO: Get variables from config file(s). May require a parent workflow to allow matrix runs.
25
- matrix:
26
- RID: [ "win-x86", "win-x64" ]
27
- ASSEMBLYNAME: [ "SPV3.Loader", "SPV3.Installer", "HXE" ] #TODO: update
28
- env:
29
- PROJPATH: "./src/${{ matrix.ASSEMBLYNAME }}.csproj"
30
-
22
+ permissions:
23
+ contents: write
24
+ issues: write
25
+ pull-requests: write
31
26
  steps:
32
- - name: Wait for build to succeed
33
- uses: lewagon/wait-on-check-action@v1.3.3
34
- with:
35
- ref: ${{ github.ref }}
36
- check-name: 'Build (${{matrix.RID}}, ${{matrix.ASSEMBLYNAME}})'
37
- repo-token: ${{ secrets.GITHUB_TOKEN }}
38
- wait-interval: 10
39
-
40
27
  ################
41
28
  # SETUP
42
29
  ################
43
30
  - uses: actions/checkout@v4
44
31
  with:
45
- fetch-depth: 0 # Required by GitVersion
32
+ fetch-depth: 0 # Required by GitVersion, Semantic Release
46
33
  submodules: "recursive" # submodule fetch depth unknown
47
- - uses: actions/setup-dotnet@v4
34
+
35
+ - name: Setup Dotnet
36
+ uses: actions/setup-dotnet@v4
37
+
48
38
  - name: Setup Node
49
39
  uses: actions/setup-node@v4
50
- - run: npm ci # Required by Semantic Release
51
40
 
52
- ################
53
- # BUILD
54
- ################
55
- - name: dotnet publish
56
- run: |
57
- dotnet publish ${{ matrix.PROJPATH }} -c Release --no-self-contained -p:ContinuousIntegrationBuild=true
58
- src/.msb.noConfig.ps1
41
+ - name: NPM - Update NPM to Latest
42
+ run: npm install -g npm@latest
59
43
 
60
- # required variables: TargetFramework, RuntimeIdentifier, GitVersion_FullSemVer
61
- # TODO: replace with ZipPublishDir (see Bintoss/GroupBox.Avalonia)
62
- - name: Compress Publish Artifacts
63
- shell: pwsh
64
- run: |
65
- $archiveName = "$env:ASSEMBLYNAME.$env:RID.$env:GitVersion_FullSemVer.zip";
66
- Compress-Archive -Path publish -DestinationPath $archiveName -CompressionLevel Optimal;
44
+ - name: NPM - Clean Install
45
+ run: npm ci # Required by Semantic Release
67
46
 
68
47
  ################
69
48
  # RELEASE
49
+ # `dotnet publish` must be executed by @semantic-release/exec
50
+ # see 'dotnet/.releaserc.cjs'
70
51
  ################
71
52
  # https://github.com/semantic-release/semantic-release
72
53
  - name: Semantic Release
@@ -74,12 +55,6 @@ jobs:
74
55
  env:
75
56
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76
57
 
77
- - name: Upload Artifact
78
- uses: actions/upload-artifact@v4
79
- with:
80
- name: publish-artifacts
81
- path: publish
82
-
83
58
  - name: Publish to GitHub Packages
84
59
  working-directory: publish
85
60
  run: dotnet nuget push *.nupkg -s https://nuget.pkg.github.com/HaloSPV3/index.json -k ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,77 @@
1
+ /** Semantic-Release configuration for GroupBox.Avalonia
2
+ * @extends { hceSharedConfig }
3
+ *
4
+ * <-- TABLE OF CONTENTS -->
5
+ * - Insert-Edit Plugins
6
+ * - Append Plugins
7
+ */
8
+
9
+ /**
10
+ * @typedef { object } PluginOptionsGit
11
+ * @prop { string } message
12
+ * @prop {[ string | [string] | {path:string} ]} assets
13
+ */
14
+
15
+ /**
16
+ * @type {import("semantic-release").Options}
17
+ */
18
+ const hceSharedConfig = require('@halospv3/hce.shared-config')
19
+ if (process.argv.includes("--debug") || process.argv.includes("--verbose")) {
20
+ console.info("hce.shared-config:\n" + JSON.stringify(hceSharedConfig, null, 2))
21
+ }
22
+ /**
23
+ * @type { typeof hceSharedConfig.plugins }
24
+ */
25
+ const newPlugins = hceSharedConfig.plugins;
26
+
27
+ //#region Insert-Edit Plugins
28
+ /* Insert and/or configure plugins. Can be used to load plugin A before plugin B
29
+ or edit a plugin's existing configuration */
30
+ for (var i = 0; i < newPlugins.length; i++) {
31
+ /** e.g.
32
+ //#region Git Options | https://github.com/semantic-release/git#options
33
+ // if defined without plugin options, replace with tuple-like array with assets option defined.
34
+ if (plugins[i] === "@semantic-release/git") {
35
+ plugins[i] = [plugins[i], { assets: ["README.md", "CHANGELOG.md"] }]
36
+ }
37
+ if (plugins[i][0] === "@semantic-release/git") {
38
+ // if assets array undefined, define it
39
+ if (!plugins[i][1].assets) {
40
+ plugins[i][1].assets = [];
41
+ }
42
+ // ensure README.md is in assets array
43
+ if (!plugins[i][1].assets.some(a => a === "README.md" || a.path === "README.md")) {
44
+ plugins[i][1].assets.push("README.md");
45
+ }
46
+ // ensure CHANGELOG.md is in assets array
47
+ if (!plugins[i][1].assets.some(a => a === "CHANGELOG.md" || a.path === "CHANGELOG.md")) {
48
+ plugins[i][1].assets.push("CHANGELOG.md");
49
+ }
50
+ }
51
+ //#endregion Git Options
52
+ */
53
+ }
54
+ //#endregion Insert-Edit Plugins
55
+
56
+ //#region Append Plugins
57
+ newPlugins.push(
58
+ // APPEND this array of [pluginName, pluginConfig] to plugins
59
+ // https://github.com/semantic-release/exec#usage
60
+ ["@semantic-release/exec", {
61
+ // 'ZipPublishDir' zips each publish folder to ./publish/*.zip
62
+ prepareCmd: "dotnet publish ./GroupBox.Avalonia/GroupBox.Avalonia.csproj && dotnet publish ./GroupBox.Avalonia.Sample/GroupBox.Avalonia.Sample.csproj"
63
+ }]
64
+ )
65
+ //#endregion Append Plugins
66
+
67
+ if (process.argv.includes("--debug") || process.argv.includes("--verbose")) {
68
+ console.info("modified plugins array:\n" + JSON.stringify(newPlugins, null, 2))
69
+ }
70
+
71
+ /**
72
+ * @type {import("semantic-release").Options}
73
+ */
74
+ module.exports = {
75
+ extends: "@halospv3/hce.shared-config",
76
+ plugins: newPlugins
77
+ };
@@ -1,17 +1,23 @@
1
1
  <Project>
2
- <!-- https://learn.microsoft.com/en-us/visualstudio/msbuild/zipdirectory-task?view=vs-2022 -->
2
+ <!-- todo: refactor to Task so users can configure input variables e.g. ZipPublishDir_AppendVariantArgs -->
3
3
  <Target Name="ZipPublishDir" AfterTargets="Publish">
4
4
  <PropertyGroup>
5
+ <!-- <ZipPublishDir_AppendVariantArgs>true</ZipPublishDir_AppendVariantArgs> -->
6
+ <!-- "C:/Repos/HaloSPV3/HXE" -->
5
7
  <RepoRoot>$([System.IO.Path]::GetDirectoryName($([MSBuild]::GetPathOfFileAbove('.gitignore', '$(MSBuildProjectDirectory)'))))</RepoRoot>
6
- <Destination>$(RepoRoot)/publish/$(AssemblyName).$(Version)$(PART_RuntimeIdentifier)</Destination>
7
- <Destination Condition="'$(RuntimeIdentifier)' != '' ">$(Destination).$(RuntimeIdentifier)</Destination>
8
+ <!-- " (net6.0 win7-x86)" -->
9
+ <!-- <PART_VariantArgs Condition="$(ZipPublishDir_AppendVariantArgs)"> ($([System.String]::Join(' ', $(TargetFramework), $(RuntimeIdentifier))))</PART_VariantArgs> -->
10
+ <PART_VariantArgs> ($([System.String]::Join(' ', $(TargetFramework), $(RuntimeIdentifier))))</PART_VariantArgs>
11
+
12
+ <!-- e.g. "C:/Repos/HaloSPV3/HXE/publish/HXE 1.2.3-preview.4 (net6.0 win7-x86).zip" -->
13
+ <Destination>$(RepoRoot)/publish/$(AssemblyName) $(Version)$(PART_VariantArgs).zip</Destination>
8
14
  </PropertyGroup>
9
15
 
10
- <!-- https://www.nuget.org/packages/GitInfo -->
16
+ <MakeDir Directories="$(RepoRoot)/publish/"/>
11
17
 
12
18
  <ZipDirectory
13
19
  SourceDirectory="$(PublishDir)"
14
- DestinationFile="$(Destination).zip"
20
+ DestinationFile="$(Destination)"
15
21
  Overwrite="true" />
16
22
  </Target>
17
23
  </Project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halospv3/hce.shared-config",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "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.",
5
5
  "keywords": [
6
6
  "halo",
@@ -44,7 +44,7 @@
44
44
  "@commitlint/cli": "^19.2.0",
45
45
  "@commitlint/config-conventional": "^19.1.0",
46
46
  "@semantic-release/changelog": "^6.0.3",
47
- "@semantic-release/commit-analyzer": "^11.1.0",
47
+ "@semantic-release/commit-analyzer": "^12.0.0",
48
48
  "@semantic-release/git": "^10.0.1",
49
49
  "@semantic-release/github": "^10.0.2",
50
50
  "@semantic-release/npm": "^12.0.0",