From 008c01e2bdee7d18361bbf052715bf7118695166 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Sun, 14 Apr 2024 11:41:25 -0400 Subject: [PATCH] Update Semantic Release (#3807) * Update Semantic Release Improved CI for producing release packages - Generates and includes version.txt - Extended types for releases and release notes - unity-packer is executed by semantic-release - releaserc fully rewritten with comments * fixed typos --- .github/workflows/Semantic.yml | 20 +++----- .releaserc.yml | 87 +++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/.github/workflows/Semantic.yml b/.github/workflows/Semantic.yml index b40004f60..ceba82523 100644 --- a/.github/workflows/Semantic.yml +++ b/.github/workflows/Semantic.yml @@ -15,28 +15,22 @@ jobs: with: fetch-depth: 0 - - name: Delete Tests - run: | - Remove-Item -Recurse -Force Assets\Mirror\Tests - Remove-Item -Recurse -Force Assets\Mirror\Tests.meta - - name: Setup dotnet uses: actions/setup-dotnet@v4 with: dotnet-version: '3.1.100' # Installs nuget package from https://www.nuget.org/packages/unity-packer + # Used by Semantic Release to create the Unity package. - name: Install unity-packer run: dotnet tool install -g unity-packer + + # Install conventional-changelog-conventionalcommits + # Required for Semantic Release Notes Generator + - name: Install conventional-changelog-conventionalcommits + run: npm i -D conventional-changelog-conventionalcommits - - name: Package - run: unity-packer pack Mirror.unitypackage Assets/Mirror Assets/Mirror Assets/ScriptTemplates Assets/ScriptTemplates LICENSE Assets/Mirror/LICENSE - - - uses: actions/upload-artifact@v4 - with: - name: Mirror.unitypackage - path: Mirror.unitypackage - + # See .releaserc.yml for configuration of semantic-release - name: Release uses: cycjimmy/semantic-release-action@v4 with: diff --git a/.releaserc.yml b/.releaserc.yml index 81fc32852..b5a43b6ef 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -1,33 +1,54 @@ -{ - verifyConditions: ["@semantic-release/github"], - prepare: [ - { - "path": "@semantic-release/exec", - "prepareCmd": "echo ${nextRelease.version} > Assets/Mirror/version.txt" - } - ], - publish: [ - { - "path": "@semantic-release/github", - "assets": [ - {"path": "Mirror.unitypackage", "label": "Mirror Unity Package", "name": "Mirror-${nextRelease.version}.unitypackage"} - ] - } - ], - "plugins": [ - ["@semantic-release/commit-analyzer", { - "preset": "angular", - "releaseRules": [ - {"type": "breaking", "release": "major"}, - {"type": "feature", "release": "minor"}, - ] - }], - ['@semantic-release/release-notes-generator', { - "preset": "angular", - "releaseRules": [ - {"type": "breaking", "release": "major"}, - {"type": "feature", "release": "minor"}, - ] - }], - ] -} +verifyConditions: + - "@semantic-release/github" + +plugins: + # Determines the type of release to create, if any. + # See https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type + # More types can be added here and in release-notes-generator below. + - - '@semantic-release/commit-analyzer' + - preset: "angular" + releaseRules: + - type: "breaking" + release: "major" + - type: "release" + release: "major" + - type: "feature" + release: "minor" + + # Extends the behavior of semantic-release to generate release notes. + # 'fix' and 'feat' are built in and don't need to be defined here. + # More types can be added to correspond with commit-analyzer above. + - - '@semantic-release/release-notes-generator' + - preset: "conventionalcommits" + presetConfig: + types: + - type: "breaking" + section: "Breaking Changes" + hidden: false + - type: "release" + section: "Release" + hidden: false + - type: "feature" + section: "Features" + hidden: false + + # Write the new version in version.txt + - - '@semantic-release/exec' + - prepareCmd: "echo ${nextRelease.version} > Assets/Mirror/version.txt" + + # Remove Test folder so it's excluded from Unity package + # -f: force, -r: recursive, -q: quiet + - - '@semantic-release/exec' + - prepareCmd: "rm -f -r -q Assets/Mirror/Tests + && rm -f -q Assets/Mirror/Tests.meta" + + # Create Unity package with Mirror, ScriptTemplates, and LICENSE + - - '@semantic-release/exec' + - prepareCmd: "unity-packer pack Mirror.unitypackage Assets/Mirror Assets/Mirror Assets/ScriptTemplates Assets/ScriptTemplates LICENSE Assets/Mirror/LICENSE" + + # Create a new release on GitHub + - - '@semantic-release/github' + - assets: + - path: "Mirror.unitypackage" + label: "Mirror Unity Package" + name: "Mirror-${nextRelease.version}.unitypackage"