diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17d35fa..e0bc872 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Setup .NET uses: actions/setup-dotnet@v4 with: @@ -27,6 +32,11 @@ jobs: - name: Restore dependencies run: dotnet restore + - name: Run update version + run: node update-version.js + env: + VERSION: ${{ github.event.inputs.version }} + - name: Embed version info run: echo "${{ github.sha }}" > ConfusedPolarBear.Plugin.IntroSkipper/Configuration/version.txt @@ -77,11 +87,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - name: Run validation and update script run: node validate-and-update-manifest.js env: @@ -92,6 +97,6 @@ jobs: run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add manifest.json + git add manifest.json ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj git commit -m "release v${{ github.event.inputs.version }}" git push diff --git a/update-version.js b/update-version.js new file mode 100644 index 0000000..04e392e --- /dev/null +++ b/update-version.js @@ -0,0 +1,22 @@ +const fs = require('fs'); + +// Read csproj +const csprojPath = './ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj'; +if (!fs.existsSync(csprojPath)) { + console.error('ConfusedPolarBear.Plugin.IntroSkipper.csproj file not found'); + process.exit(1); +} + +function updateCsprojVersion() { + const newVersion = process.env.VERSION + const csprojContent = fs.readFileSync(csprojPath, 'utf8'); + + const updatedContent = csprojContent + .replace(/.*<\/AssemblyVersion>/, `${newVersion}`) + .replace(/.*<\/FileVersion>/, `${newVersion}`); + + fs.writeFileSync(csprojPath, updatedContent); + console.log('Updated .csproj file with new version.'); +} + +updateCsprojVersion() \ No newline at end of file