# Original script from totoa553/OpenTaiko and DragonRatTiger/OpenTaiko name: Build OpenTaiko on: push: branches: - main jobs: build: runs-on: windows-latest permissions: # Give the default GITHUB_TOKEN write permission to commit and push the # added or changed files to the repository. contents: write steps: - name: Checkout Repository uses: actions/checkout@v2 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - name: Observe the Directory shell: cmd run: | dir - name: Get commit subject for version checking id: get-latest-commit run: | $latestCommitMessage = git log -1 --pretty=format:%s echo "::set-output name=latest_commit_message::$latestCommitMessage" - name: Extract version from commit message id: extract-version run: | if ('${{ steps.get-latest-commit.outputs.latest_commit_message }}' -match '^(?[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s-\s') { $version = $matches['version'] Write-Host "Extracted version is: $version" echo "::set-output name=version::$version" } else { Write-Host "No valid version found in the latest commit message. Skipping bump." echo "::set-output name=version::" } - name: Bump OpenTaiko version if necessary if: steps.extract-version.outputs.version != '' run: | $newVersion = "${{ steps.extract-version.outputs.version }}" Write-Host "Updating version in OpenTaiko.csproj to $newVersion" (Get-Content OpenTaiko/OpenTaiko.csproj) -replace '.*<\/Version>', "$newVersion" | Set-Content OpenTaiko/OpenTaiko.csproj - name: Get version uses: kzrnm/get-net-sdk-project-versions-action@v2 id: get-version with: proj-path: OpenTaiko/OpenTaiko.csproj - name: Get current date id: get-date run: | $date = Get-Date -Format "yyyy-MM-dd" echo "::set-output name=date::$date" - name: Get changelogs from commit description id: get-commit-message run: | $message = git log -1 --pretty=%b echo "::set-output name=message::$message" - name: Update CHANGELOG.md run: | $version = '${{steps.get-version.outputs.version}}' $date = '${{steps.get-date.outputs.date}}' $message = '${{steps.get-commit-message.outputs.message}}' $changelogPath = "CHANGELOG.md" # Read CHANGELOG.md content $changelog = Get-Content -Path $changelogPath # Split the message into individual items, trim whitespace, and format $messageArray = $message -split '-' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" } # Format each item to have a leading dash $message = ($messageArray | ForEach-Object { "- $_" }) -join "`n" # Check if the version already exists if ($changelog -match "## \[$version\]") { if ($message) { # Capture the existing content under the version heading $changelog = $changelog -replace "(## \[($version)\] .* \(Beta\))", "`$1`n`n$message" } } else { # Insert new version under '# Changelog' $changelog = $changelog -replace "(# Changelog)", "`$1`n`n## [$version] - $date (Beta)`n`n$message" } # Write updated content back to CHANGELOG.md Set-Content -Path $changelogPath -Value $changelog - name: Commit CHANGELOG.md and OpenTaiko.csproj changes run: | git config --global user.name "github-actions" git config --global user.email "actions@github.com" git add OpenTaiko/OpenTaiko.csproj git add CHANGELOG.md git commit -m "Update changelog for version ${{steps.get-version.outputs.version}}" git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} HEAD:${{ github.ref }} - name: Build for Windows x64 shell: cmd run: | build-win-x64.bat - name: Create Archive (Win x64) shell: cmd run: | cd OpenTaiko\bin\Release\net8.0\win-x64\ 7z a ../../../../../OpenTaiko.Win.x64.zip publish/ -xr!publish/Songs/ -xr!publish/FFmpeg/ -xr!publish/System/ -xr!publish/Libs/ 7z u ../../../../../OpenTaiko.Win.x64.zip "publish/Libs/win-x64/*" "publish/FFmpeg/win-x64/*" "publish/Songs/L2 Custom Charts/*" "publish/Songs/L3 Downloaded Songs/*" "publish/Songs/S1 Dan-i Dojo/box.def" "publish/Songs/S2 Taiko Towers/box.def" "publish/Songs/X1 Favorite/*" "publish/Songs/X2 Recent/*" "publish/Songs/X3 Search By Difficulty/*" cd ..\..\..\..\..\ - name: Build for Linux x64 shell: cmd run: | build-linux-x64.bat - name: Create Archive (Linux x64) shell: cmd run: | cd OpenTaiko\bin\Release\net8.0\linux-x64\ 7z a ../../../../../OpenTaiko.Linux.x64.zip publish/ -xr!publish/Songs/ -xr!publish/FFmpeg/ -xr!publish/System/ -xr!publish/Libs/ 7z u ../../../../../OpenTaiko.Linux.x64.zip "publish/Libs/linux-x64/*" "publish/FFmpeg/linux-x64/*" "publish/Songs/L2 Custom Charts/*" "publish/Songs/L3 Downloaded Songs/*" "publish/Songs/S1 Dan-i Dojo/box.def" "publish/Songs/S2 Taiko Towers/box.def" "publish/Songs/X1 Favorite/*" "publish/Songs/X2 Recent/*" "publish/Songs/X3 Search By Difficulty/*" cd ..\..\..\..\..\ - name: Check if tag exists uses: mukunku/tag-exists-action@v1.6.0 id: check-tag with: tag: "${{steps.get-version.outputs.version}}" - name: Create Release if: steps.check-tag.outputs.exists == 'false' uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: "${{steps.get-version.outputs.version}}" release_name: OpenTaiko v${{steps.get-version.outputs.version}} body: | Note: The releases do not contain skins nor songs. Please download/update through the OpenTaiko Hub: https://github.com/OpenTaiko/OpenTaiko-Hub/releases draft: false prerelease: false - name: Upload All Builds uses: xresloader/upload-to-github-release@v1.4.2 with: file: "OpenTaiko.Win.x64.zip;OpenTaiko.Linux.x64.zip" overwrite: true tag_name: "${{steps.get-version.outputs.version}}" draft: false token: ${{ secrets.GITHUB_TOKEN }}