From 723ea252fa9f8202904663516080439fd14845e9 Mon Sep 17 00:00:00 2001 From: Kalle Minkner Date: Mon, 11 Nov 2024 12:19:56 +0100 Subject: [PATCH] fix: automatic build only on version.cs change --- .github/workflows/release.yml | 19 +++++++++++-------- src/Cosmetics.cs | 1 - src/Version.cs | 10 ++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 src/Version.cs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4dd3adc..85bb2d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,15 +1,18 @@ -name: Create Release +name: Build Release + +env: + REPOSITORY_FOLDER: "src" # subfolder with source code + PLUGIN_NAME: "Cosmetics" # main file of the project on: push: branches: - main + paths: + - 'src/Version.cs' # only on change of the file with the version number string in it workflow_dispatch: -env: - REPOSITORY_FOLDER: "src" # subfolder with source code - PLUGIN_NAME: "Cosmetics" # main file of the project - +# job to create a new release jobs: create-release: runs-on: ubuntu-latest @@ -21,10 +24,10 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 - - name: Get Current Project Version Number From ${{ env.PLUGIN_NAME }}.cs + - name: Get Current Project Version Number From Version.cs id: get_version run: | - version=$(grep -oP '(?<=ModuleVersion => ")[^"]*' ${{ env.REPOSITORY_FOLDER }}/${{ env.PLUGIN_NAME }}.cs) + version=$(grep -oP '(?<=ModuleVersion => ")[^"]*' ${{ env.REPOSITORY_FOLDER }}/Version.cs) echo "version=$version" >> $GITHUB_ENV - name: Get Current Release Version Number @@ -56,7 +59,7 @@ jobs: if: env.new_version == 'true' run: dotnet publish -c Release - - name: Prepare CS2-UpdateManager ${{ env.REPOSITORY_NAME }}.info + - name: Prepare ${{ env.REPOSITORY_NAME }}.info if: env.new_version == 'true' run: | echo "version: ${{ env.version }}" > /home/runner/work/${{ env.REPOSITORY_NAME }}/${{ env.REPOSITORY_NAME }}/${{ env.REPOSITORY_FOLDER }}/bin/Release/net8.0/publish/${{ env.PLUGIN_NAME }}.info diff --git a/src/Cosmetics.cs b/src/Cosmetics.cs index 0ddfde0..920ce48 100644 --- a/src/Cosmetics.cs +++ b/src/Cosmetics.cs @@ -7,7 +7,6 @@ public partial class Cosmetics : BasePlugin, IPluginConfig { public override string ModuleName => "Cosmetics"; public override string ModuleAuthor => "Jon-Mailes Graeffe / Kalle "; - public override string ModuleVersion => "1.0.1"; private string _currentMap = ""; private Random _random = new Random(); diff --git a/src/Version.cs b/src/Version.cs new file mode 100644 index 0000000..979a53a --- /dev/null +++ b/src/Version.cs @@ -0,0 +1,10 @@ +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Modules.Utils; + +namespace Cosmetics +{ + public partial class Cosmetics : BasePlugin + { + public override string ModuleVersion => "1.0.1"; + } +}