From 1094e73c1ce1c048eb4e3141bd5d5cd138dfee0d Mon Sep 17 00:00:00 2001 From: Goran Lazarevski Date: Wed, 2 Apr 2025 23:07:51 +0200 Subject: [PATCH] Allow paths as inputs --- .gitea/workflows/create-release.yml | 88 +++++++++++++++++++---------- .gitea/workflows/unreal-build.yml | 6 +- 2 files changed, 62 insertions(+), 32 deletions(-) diff --git a/.gitea/workflows/create-release.yml b/.gitea/workflows/create-release.yml index effef28c..555b5af2 100644 --- a/.gitea/workflows/create-release.yml +++ b/.gitea/workflows/create-release.yml @@ -2,7 +2,19 @@ name: Unreal Release on: workflow_dispatch: - + inputs: + windows_build_path: + description: 'Absolute path to the Windows build zip file' + required: true + default: 'E:\LuckyWorld\LuckyRobots\UNREAL_PROJECTS\Luckyrobots\Builds\Windows\LuckyRobots-Windows.zip' + linux_build_path: + description: 'Absolute path to the Linux build zip file' + required: true + default: 'E:\LuckyWorld\LuckyRobots\UNREAL_PROJECTS\Luckyrobots\Builds\Linux\LuckyRobots-Linux.zip' + mac_build_path: + description: 'Absolute path to the Mac build zip file' + required: true + default: 'E:\LuckyWorld\LuckyRobots\UNREAL_PROJECTS\Luckyrobots\Builds\Mac\LuckyRobots-Mac.zip' jobs: build: @@ -12,56 +24,74 @@ jobs: uses: actions/upload-artifact@v3 with: name: LuckyRobots-Linux - path: E:\LuckyWorld\LuckyRobots\UNREAL_PROJECTS\Luckyrobots\Builds\Linux\LuckyRobots-Linux.zip - retention-days: 14 + path: ${{ github.event.inputs.linux_build_path }} + retention-days: 365 - name: Upload Windows Build Artifact uses: actions/upload-artifact@v3 with: name: LuckyRobots-Windows - path: E:\LuckyWorld\LuckyRobots\UNREAL_PROJECTS\Luckyrobots\Builds\Windows\LuckyRobots-Windows.zip - retention-days: 14 + path: ${{ github.event.inputs.windows_build_path }} + retention-days: 365 + + - name: Upload Mac Build Artifact + uses: actions/upload-artifact@v3 + with: + name: LuckyRobots-Mac + path: ${{ github.event.inputs.mac_build_path }} + retention-days: 365 - name: Get Release Tag + shell: pwsh run: | # Fetch all tags git fetch --tags - # Get the latest version tag - LATEST_TAG=$(git tag -l "v[0-9]*.[0-9]*.[0-9]*" | sort -V | tail -n1) + # Get the latest version tag, if any + # Uses Sort-Object with a version comparison scriptblock + $latestTag = git tag -l "v[0-9]*.[0-9]*.[0-9]*" | Sort-Object -Property @{Expression={[version]($_ -replace 'v')}} | Select-Object -Last 1 - if [ -z "$LATEST_TAG" ]; then - NEW_VERSION="1.0.0" - else - VERSION=${LATEST_TAG#v} - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) - PATCH=$((PATCH + 1)) - NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" - fi + $newVersion = "1.0.0" # Default start version - TAG="v${NEW_VERSION}" - echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV - echo "Using release tag: $TAG" + if ($null -ne $latestTag -and $latestTag -ne '') { + Write-Host "Latest tag found: $latestTag" + # Strip 'v' prefix + $versionString = $latestTag -replace '^v' + + # Split version into parts + $versionParts = $versionString.Split('.') + if ($versionParts.Length -eq 3) { + $major = [int]$versionParts[0] + $minor = [int]$versionParts[1] + $patch = [int]$versionParts[2] + + # Auto-increment patch version + $patch++ + $newVersion = "$major.$minor.$patch" + Write-Host "Auto-incremented patch version from $versionString to $newVersion" + } else { + Write-Host "Could not parse version from tag: $latestTag. Defaulting to 1.0.0" + } + } else { + Write-Host "No previous version tags found, starting with 1.0.0" + } + + # Final tag with v prefix + $tag = "v$newVersion" + + # Set environment variable for subsequent steps + echo "RELEASE_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Host "Using release tag: $tag" - name: Create Release uses: https://gitea.com/actions/gitea-release-action@main with: - files: |- - PackagedReleases/build-info.json - PackagedReleases/downloads.html token: '${{ secrets.GITEA_TOKEN }}' title: 'Release ${{ env.RELEASE_TAG }}' body: | ## LuckyRobots Game Release ${{ env.RELEASE_TAG }} - ### Download Links - - Download builds from our CI artifacts: - - - [Windows Build](https://luckyrobots.com/luckyrobots/luckyworld/actions/runs/${{ github.run_id }}/artifacts/LuckyRobots-Windows) - - [Linux Build](https://luckyrobots.com/luckyrobots/luckyworld/actions/runs/${{ github.run_id }}/artifacts/LuckyRobots-Linux) + Windows, Linux and Mac builds are attached below. ### Build Information diff --git a/.gitea/workflows/unreal-build.yml b/.gitea/workflows/unreal-build.yml index 589489ef..ae03d688 100644 --- a/.gitea/workflows/unreal-build.yml +++ b/.gitea/workflows/unreal-build.yml @@ -64,7 +64,7 @@ jobs: with: name: LuckyRobots-Windows path: PackagedReleases/LuckyRobots-Windows.zip - retention-days: 14 + retention-days: 365 - name: Upload Linux Build Artifact uses: actions/upload-artifact@v3 @@ -72,7 +72,7 @@ jobs: with: name: LuckyRobots-Linux path: PackagedReleases/LuckyRobots-Linux.zip - retention-days: 14 + retention-days: 365 - name: Create Tag if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' @@ -321,7 +321,7 @@ jobs: with: name: LuckyRobots-macOS path: PackagedReleases/*-macOS.zip - retention-days: 14 + retention-days: 365 - name: Create Release Note run: |