From 2adf1b89e939f6bd1eb95e2b04375c19b7c8ad0d Mon Sep 17 00:00:00 2001 From: BoiHanny Date: Thu, 25 Jan 2024 12:08:19 +0100 Subject: [PATCH] The most significant changes involve the `main.yml` file and the `MagicChatbox.csproj` file. In the `main.yml` file, the method of extracting the version number from the `csproj` file has been altered. Instead of directly reading the XML, a regular expression is now used. If the version number is not found, an error message is displayed and the process is halted. The `GITHUB_TOKEN` used in the `main.yml` file has also been changed from `secrets.GITHUB_TOKEN` to `secrets.MY_PAT` in the 'Create Release' and 'Upload Release Asset' steps. Additionally, a comment has been added to the `upload_url` in the 'Upload Release Asset' step to indicate that it uses the output from the 'create_release' step. In the `MagicChatbox.csproj` file, the version number has been incremented from `0.8.731` to `0.8.732`. Changes: 1. Updated the `main.yml` file to change the way the version number is extracted from the `csproj` file. It now uses a regular expression to find the version number. If the version number is not found, an error message is displayed and the process is stopped. 2. Changed the `GITHUB_TOKEN` used in the `main.yml` file from `secrets.GITHUB_TOKEN` to `secrets.MY_PAT` in both the 'Create Release' and 'Upload Release Asset' steps. 3. Added a comment to the `upload_url` in the 'Upload Release Asset' step of the `main.yml` file indicating that it uses the output from the 'create_release' step. 4. Incremented the version number in the `MagicChatbox.csproj` file from `0.8.731` to `0.8.732`. --- .github/workflows/main.yml | 21 +++++++++++++++------ vrcosc-magicchatbox/MagicChatbox.csproj | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4407a97..83efcb8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,9 +31,18 @@ jobs: - name: Extract Version from csproj id: get_version run: | - $xml = [xml](Get-Content ${{ env.Project_Path }}) - $version = $xml.Project.PropertyGroup.Version - echo "::set-output name=VERSION::$version" + $csproj = "${{ env.Project_Path }}" + $pattern = '(.*)<\/Version>' + $content = Get-Content $csproj -Raw + $match = [regex]::Match($content, $pattern) + if ($match.Success -and $match.Groups.Count -gt 1) { + $version = $match.Groups[1].Value + echo "VERSION=$version" | Out-File -Append -Encoding utf8 $Env:GITHUB_ENV + echo "::set-output name=VERSION::$version" + } else { + echo "Error: Version not found in csproj file." + exit 1 + } shell: pwsh - name: Create Zip File @@ -43,7 +52,7 @@ jobs: - name: Create Release uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.MY_PAT }} # Replace 'GITHUB_TOKEN' with your secret name + GITHUB_TOKEN: ${{ secrets.MY_PAT }} with: tag_name: v${{ steps.get_version.outputs.VERSION }} release_name: MagicChatbox Pre-v${{ steps.get_version.outputs.VERSION }} @@ -64,9 +73,9 @@ jobs: - name: Upload Release Asset uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.MY_PAT }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} + upload_url: ${{ steps.create_release.outputs.upload_url }} # Use the output from the create_release step asset_path: ./MagicChatbox-${{ steps.get_version.outputs.VERSION }}.zip asset_name: MagicChatbox-${{ steps.get_version.outputs.VERSION }}.zip asset_content_type: application/zip diff --git a/vrcosc-magicchatbox/MagicChatbox.csproj b/vrcosc-magicchatbox/MagicChatbox.csproj index d5d457b..6b22e0f 100644 --- a/vrcosc-magicchatbox/MagicChatbox.csproj +++ b/vrcosc-magicchatbox/MagicChatbox.csproj @@ -2,7 +2,7 @@ WinExe - 0.8.731 + 0.8.732 net6.0-windows10.0.22000.0 vrcosc_magicchatbox enable