diff --git a/.github/actions/version/action.yml b/.github/actions/version/action.yml index a00cffe..8f482f4 100644 --- a/.github/actions/version/action.yml +++ b/.github/actions/version/action.yml @@ -6,16 +6,34 @@ outputs: runs: using: 'composite' steps: - - name: Generate/Set Version 🏷️ + - name: Generate Version 🏷️ id: version shell: pwsh run: | - $LATEST_TAG = git describe --tags --abbrev=0 # Get the latest tag name - $COMMIT_COUNT = git rev-list --use-bitmap-index --count "$(git rev-list --tags --no-walk --max-count=1)..HEAD" # Count all commits since the last tag - $NIXOS_WSL_VERSION = "$($LATEST_TAG -replace '(.+)\.(.+)\.(.+)\..+', '$1.$2.$3').${COMMIT_COUNT}" # Compose the NixOS-WSL version number - Write-Output "version=${NIXOS_WSL_VERSION}" >> $env:GITHUB_OUTPUT + if ('${{ github.event_name }}' -eq 'pull_request') { + $version = 'pr-${{ github.event.pull_request.number }}' + $is_numeric = '' + } elseif ('${{ github.ref_name }}' -like 'release-*') { + $latest_tag = git describe --tags --abbrev=0 + $commit_count = git rev-list --use-bitmap-index --count "$(git rev-list --tags --no-walk --max-count=1)..HEAD" + $version = "$($latest_tag -replace '(.+)\.(.+)\.(.+)\..+', '$1.$2.$3').${commit_count}" + $is_numeric = 1 + } else { + $version = '${{ github.ref_name }}' + $is_numeric = '' + } + "version=$version" | Tee-Object -FilePath $env:GITHUB_OUTPUT -Append + "is_numeric=$is_numeric" | Tee-Object -FilePath $env:GITHUB_OUTPUT -Append - Write-Output $NIXOS_WSL_VERSION > ./VERSION - Write-Output $(git rev-parse HEAD) >> ./VERSION - ((Get-Content -path ./Launcher/Launcher/Launcher.csproj -Raw) -replace '1.3.3.7',$NIXOS_WSL_VERSION) | Set-Content -Path ./Launcher/Launcher/Launcher.csproj - ((Get-Content -path ./Launcher/Launcher-Appx/Package.appxmanifest -Raw) -replace '1.3.3.7',$NIXOS_WSL_VERSION) | Set-Content -Path ./Launcher/Launcher-Appx/Package.appxmanifest + - name: Set Version 🏷️ + shell: pwsh + run: | + Write-Output '${{ steps.version.outputs.version }}' | Tee-Object -FilePath ./VERSION + Write-Output "$(git rev-parse HEAD)" | Tee-Object -FilePath ./VERSION -Append + + - name: Set Launcher Version 🏷️ + shell: pwsh + if: ${{ steps.version.outputs.is_numeric }} + run: | + ((Get-Content -path ./Launcher/Launcher/Launcher.csproj -Raw) -replace '1.3.3.7','${{ steps.version.outputs.version }}') | Set-Content -Path ./Launcher/Launcher/Launcher.csproj + ((Get-Content -path ./Launcher/Launcher-Appx/Package.appxmanifest -Raw) -replace '1.3.3.7','${{ steps.version.outputs.version }}') | Set-Content -Path ./Launcher/Launcher-Appx/Package.appxmanifest diff --git a/VERSION b/VERSION index 14b1a51..2083acf 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -DEV_BUILD -dirty +dev-build +unknown