Skip to content

Updated version to 1.1.0 #12

Updated version to 1.1.0

Updated version to 1.1.0 #12

Workflow file for this run

name: Build and Release
on:
push:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'
- name: Get Version
id: get_version
shell: pwsh
run: |
$path = "src/LightSteamAccountSwitcher/LightSteamAccountSwitcher.csproj"
[xml]$xml = Get-Content $path
# Prioritize AssemblyVersion
$ver = $xml.Project.PropertyGroup.AssemblyVersion
if (-not [string]::IsNullOrWhiteSpace($ver)) {
# Try to parse as Version object
try {
$v = [version]$ver
# If we have 4 components (Major.Minor.Build.Revision), take only top 3
if ($v.Revision -ne -1) {
$ver = "$($v.Major).$($v.Minor).$($v.Build)"
}
} catch {
Write-Host "Could not parse version '$ver' as a standard version object. Using raw string."
}
}
if ([string]::IsNullOrWhiteSpace($ver)) { $ver = "1.0.0" }
echo "Detected Version: $ver"
echo "version=$ver" >> $env:GITHUB_OUTPUT
- name: Check and Tag
id: tag_check
shell: bash
env:
VERSION: ${{ steps.get_version.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v$VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists. Skipping release."
echo "new_tag=false" >> "$GITHUB_OUTPUT"
else
echo "Tag $TAG does not exist. Creating..."
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"
echo "new_tag=true" >> "$GITHUB_OUTPUT"
fi
- name: Restore dependencies
if: steps.tag_check.outputs.new_tag == 'true'
run: dotnet restore LightSteamAccountSwitcher.slnx
- name: Publish
if: steps.tag_check.outputs.new_tag == 'true'
run: |
dotnet publish src/LightSteamAccountSwitcher/LightSteamAccountSwitcher.csproj -c Release -r win-x64 -p:DebugType=None -o ./publish
- name: Generate Changelog
if: steps.tag_check.outputs.new_tag == 'true'
id: changelog
shell: bash
run: |
TAG="v${{ steps.get_version.outputs.version }}"
# Find the tag before the current one
PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found. Summarizing all commits up to $TAG."
SUMMARY=$(git log --pretty=format:"- %s (%h)" --no-merges "$TAG")
else
echo "Summarizing commits between $PREV_TAG and $TAG"
SUMMARY=$(git log "$PREV_TAG..$TAG" --pretty=format:"- %s (%h)" --no-merges)
fi
echo "summary<<EOF" >> "$GITHUB_OUTPUT"
echo "$SUMMARY" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create Release
if: steps.tag_check.outputs.new_tag == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Release v${{ steps.get_version.outputs.version }}
files: ./publish/LightSteamAccountSwitcher.exe
body: |
## Changes
${{ steps.changelog.outputs.summary }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}