From 83d9196385579af9bfbcf2f60cbfbfe50542ea23 Mon Sep 17 00:00:00 2001 From: NanderTGA <65074195+NanderTGA@users.noreply.github.com> Date: Mon, 27 Nov 2023 01:18:32 +0100 Subject: [PATCH] automate nightly & release builds using github actions and fix #11 (#10) * ci: add github actions ci * ci: upload build artifacts * ci: fix wrong branch name * ci: add artifact names * ci: refactor for easier portability * ci: simplify step * ci: automatically add build result to release * ci: use windows-2019 * fix: twinx and tiki are switched around #11 * ci: fix space in artifact name * ci: update update.xml on release * ci: refactor a bit and actually update & commit * ci: put path to FunkeySelector.exe * ci: attempt to debug * ci: try to push changes * ci: checkout default branch * ci: push to default branch * chore(update): update update.xml * ci: debug null error * chore(update): update update.xml * ci: set correct asset name * ci: use GITHUB_OUTPUT properly * chore(update): update update.xml * revert: "chore(update): update update.xml" This reverts commit 42888e60d58e3c26e58efe32a422e34993d568f7. * ci: set version in AssemblyInfo.cs * chore(update): update update.xml * chore(update): update update.xml * ci: get tag name properly * ci: run on every push & PR * ci: use action to get tag name * ci: run always on push * ci: fetch git tags * ci: unshallow using git fetch * ci: try using other action to get tag * ci: commit changes to AssemblyInfo.cs * ci: clarify commit message * ci: correct description * ci: get version from update.xml * ci: don't care about tags * chore(release): v3.0.7 * ci: add warning about unintended behavior * revert: changes from test releases --------- Co-authored-by: Github Actions Bot <> --- .github/workflows/nightly.yml | 67 +++++++++++++++++++ .github/workflows/release.yml | 95 +++++++++++++++++++++++++++ FunkeySelector/KelpyBasin.Designer.cs | 12 ++-- 3 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/nightly.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..f9220f6 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,67 @@ +# Builds a .NET framework project +name: Nightly builds + +env: + projectName: FunkeySelectorGUI + projectFolder: FunkeySelector + solutionFile: FunkeySelector.sln + +on: + workflow_dispatch: + + push: + branches-ignore: + - "gh-pages" + + pull_request: + branches-ignore: + - "gh-pages" + +jobs: + build: + strategy: + matrix: + configuration: [ Debug, Release ] + runs-on: windows-2019 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1 + + - name: Setup NuGet + uses: NuGet/setup-nuget@v1 + + - name: Restore Packages + run: nuget restore ${{ env.solutionFile }} + + - name: Get version from update.xml + id: getVersion + uses: mavrosxristoforos/get-xml-info@1.2.1 + with: + xml-file: update.xml + xpath: //update/@version + + - name: Normalize the version string into SemVer format (x.x.x) + id: normalizeVersion + run: | + $versionString = "${{ steps.getVersion.outputs.info }}" + $digits = $versionString.Split(".").Length + if ($digits -eq 1) { $versionString += ".0.0" } + elseif ($digits -eq 2) { $versionString += ".0" } + "VERSION=$($versionString)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + + - name: Set version in AssemblyInfo.cs + uses: secondbounce/assemblyinfo-update@v2 + with: + version: "${{ steps.normalizeVersion.outputs.VERSION }}" + + - name: Build solution + run: msbuild ${{ env.solutionFile }} -t:rebuild -property:Configuration=${{ matrix.configuration }} + + - name: Upload the build results as an artifact + uses: actions/upload-artifact@v3 + with: + path: ${{ env.projectFolder }}/bin/${{ matrix.configuration }}/* + name: ${{ env.projectName }}.Nightly.${{ matrix.configuration }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e3da8d9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +# Builds a .NET framework project in Release mode when a new release is created +# and uploads the build results to the newly created release +# then updates update.xml and Properties/AssemblyInfo.cs +name: Publish release + +env: + projectName: FunkeySelectorGUI + projectFolder: FunkeySelector + solutionFile: FunkeySelector.sln + +on: + release: + types: + - released + +jobs: + publish: + permissions: + contents: write + id-token: write + strategy: + matrix: # please please please don't put multiple build configurations in here, it will cause unintended behaviour + configuration: [ Release ] + runs-on: windows-2019 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: "${{ github.event.repository.default_branch }}" + + - name: Setup git configuration + run: | + git config user.name "Github Actions Bot" + git config user.email "<>" + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1 + + - name: Setup NuGet + uses: NuGet/setup-nuget@v1 + + - name: Restore Packages + run: nuget restore ${{ env.solutionFile }} + + - name: Get version from release name + id: version + uses: mad9000/actions-find-and-replace-string@4 + with: + source: "${{ github.event.release.tag_name }}" + find: "v" + replace: "" + + - name: Normalize the version string into SemVer format (x.x.x) + id: normalizeVersion + run: | + $versionString = "${{ steps.version.outputs.value }}" + $digits = $versionString.Split(".").Length + if ($digits -eq 1) { $versionString += ".0.0" } + elseif ($digits -eq 2) { $versionString += ".0" } + "VERSION=$($versionString)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + + - name: Set version in AssemblyInfo.cs + uses: secondbounce/assemblyinfo-update@v2 + with: + version: "${{ steps.normalizeVersion.outputs.VERSION }}" + + - name: Build solution + run: msbuild ${{ env.solutionFile }} -t:rebuild -property:Configuration=${{ matrix.configuration }} + + - name: Upload the build results as an artifact + uses: actions/upload-artifact@v3 + with: + path: ${{ env.projectFolder }}/bin/${{ matrix.configuration }}/* + name: ${{ env.projectName }}.${{ github.event.release.tag_name }}.${{ matrix.configuration }} + + - name: Upload build results to release + uses: svenstaro/upload-release-action@v2 + with: + file: ${{ env.projectFolder }}/bin/${{ matrix.configuration }}/FunkeySelector.exe + asset_name: FunkeySelectorGUI.exe + + - name: Get file size of FunkeySelectorGUI.exe + id: filesize + run: | + "FILESIZE=$((Get-Item ${{ env.projectFolder }}/bin/${{ matrix.configuration }}/FunkeySelector.exe).length)" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + + - name: Update update.xml + run: echo '' > update.xml + + - name: Push the changes made to update.xml + run: | + git add update.xml + git add ${{ env.projectFolder }}/Properties/AssemblyInfo.cs + git commit -m "chore(release): ${{ github.event.release.tag_name }}" + git push origin ${{ github.event.repository.default_branch }} diff --git a/FunkeySelector/KelpyBasin.Designer.cs b/FunkeySelector/KelpyBasin.Designer.cs index 459c9ce..0438336 100644 --- a/FunkeySelector/KelpyBasin.Designer.cs +++ b/FunkeySelector/KelpyBasin.Designer.cs @@ -72,7 +72,7 @@ private void InitializeComponent() this.TwinxVR.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.TwinxVR.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.TwinxVR.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.TwinxVR.FunkeyID = "0000001F"; + this.TwinxVR.FunkeyID = "00000025"; this.TwinxVR.Location = new System.Drawing.Point(390, 448); this.TwinxVR.Name = "TwinxVR"; this.TwinxVR.Size = new System.Drawing.Size(50, 63); @@ -89,7 +89,7 @@ private void InitializeComponent() this.TwinxR.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.TwinxR.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.TwinxR.ForeColor = System.Drawing.SystemColors.ControlLight; - this.TwinxR.FunkeyID = "0000001E"; + this.TwinxR.FunkeyID = "00000024"; this.TwinxR.Location = new System.Drawing.Point(339, 448); this.TwinxR.Name = "TwinxR"; this.TwinxR.Size = new System.Drawing.Size(50, 63); @@ -106,7 +106,7 @@ private void InitializeComponent() this.Twinx.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.Twinx.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Twinx.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.Twinx.FunkeyID = "0000001D"; + this.Twinx.FunkeyID = "00000023"; this.Twinx.Location = new System.Drawing.Point(288, 448); this.Twinx.Name = "Twinx"; this.Twinx.Size = new System.Drawing.Size(50, 63); @@ -198,7 +198,7 @@ private void InitializeComponent() this.TikiVR.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.TikiVR.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.TikiVR.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.TikiVR.FunkeyID = "00000025"; + this.TikiVR.FunkeyID = "0000001F"; this.TikiVR.Location = new System.Drawing.Point(391, 338); this.TikiVR.Name = "TikiVR"; this.TikiVR.Size = new System.Drawing.Size(50, 63); @@ -215,7 +215,7 @@ private void InitializeComponent() this.TikiR.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.TikiR.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.TikiR.ForeColor = System.Drawing.SystemColors.ControlLight; - this.TikiR.FunkeyID = "00000024"; + this.TikiR.FunkeyID = "0000001E"; this.TikiR.Location = new System.Drawing.Point(340, 338); this.TikiR.Name = "TikiR"; this.TikiR.Size = new System.Drawing.Size(50, 63); @@ -232,7 +232,7 @@ private void InitializeComponent() this.Tiki.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.Tiki.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Tiki.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.Tiki.FunkeyID = "00000023"; + this.Tiki.FunkeyID = "0000001D"; this.Tiki.Location = new System.Drawing.Point(289, 338); this.Tiki.Name = "Tiki"; this.Tiki.Size = new System.Drawing.Size(50, 63);