Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
versionprefix_changed: ${{ steps.versionprefix.outputs.changed }}
version: ${{ steps.versionprefix.outputs.version }}
artifact_name: ${{ steps.artifact-name.outputs.name }}
release_needed: ${{ steps.release-check.outputs.release_needed }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -46,6 +47,32 @@ jobs:
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

- name: Check if current version needs release
id: release-check
shell: bash
run: |
if [ "$GITHUB_EVENT_NAME" != "push" ] || [ "$GITHUB_REF" != "refs/heads/main" ]; then
echo "release_needed=false" >> "$GITHUB_OUTPUT"
exit 0
fi

new_version="${{ steps.versionprefix.outputs.version }}"
release_response=$(curl -sS -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2026-03-10" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest")

current_version=$(echo "$release_response" | jq -r '.tag_name // empty')

if [ -z "$current_version" ]; then
echo "release_needed=true" >> "$GITHUB_OUTPUT"
elif [ "$new_version" != "$current_version" ]; then
echo "release_needed=true" >> "$GITHUB_OUTPUT"
else
echo "release_needed=false" >> "$GITHUB_OUTPUT"
fi

- name: Build all configurations
run: |
dotnet build GEffectsLogic/GEffectsLogic.csproj -c Release --no-restore
Expand Down Expand Up @@ -119,22 +146,8 @@ jobs:
release-artifacts:
runs-on: ubuntu-slim
needs: build-artifacts
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build-artifacts.outputs.versionprefix_changed == 'true' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build-artifacts.outputs.release_needed == 'true' }}
steps:
- name: Verify version change
shell: bash
run: |
new_version="${{ needs.build-artifacts.outputs.version }}"
current_version=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/latest" | grep -oP '"tag_name": "\K(.*)(?=")')

echo "csproj version: $new_version"
echo "latest release version: $current_version"

if [ "$new_version" = "$current_version" ]; then
echo "VersionPrefix has not changed since the last release. Skipping release."
exit 1
fi

- name: Download build artifact
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -233,4 +246,4 @@ jobs:
exit 1
fi

echo "Release created and asset uploaded successfully."
echo "Release created and asset uploaded successfully."
2 changes: 1 addition & 1 deletion GEffectsLogic/GEffectsLogic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Configurations>Debug;Release;PerfDebug</Configurations>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>

<VersionPrefix>0.3.2</VersionPrefix>
<VersionPrefix>0.3.3</VersionPrefix>
<Version>$(VersionPrefix)</Version>
<AssemblyVersion>0.3.1.0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
Expand Down
Loading