Skip to content

Commit 520c62f

Browse files
committed
Fix issues in publish workflows
1 parent f1fe14c commit 520c62f

4 files changed

Lines changed: 35 additions & 23 deletions

File tree

.github/workflows/PublishNugetPackage.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Publish Nuget Package
22

33
on:
44
workflow_call:
5+
6+
env:
7+
version_file: ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj
58

69
jobs:
710
PublishNugetPackage:
@@ -13,15 +16,24 @@ jobs:
1316
- uses: actions/setup-dotnet@v4
1417
with:
1518
dotnet-version: '6.0'
16-
17-
- name: Build Common Project
18-
run: dotnet build --configuration Release
19-
20-
- name: Publish Common
21-
uses: tedd/publish-nuget-neo@v1
22-
with:
23-
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
24-
PROJECT_FILE_PATH: ManualDi.Main/ManualDi.Main.csproj
25-
REBUILD_PROJECT: false
26-
TAG_COMMIT: true
27-
TAG_FORMAT: Nuget/*
19+
20+
- id: get-version
21+
run: |
22+
version=$(grep -oP '(?<=<Version>)[^<]+' "${{ env.version_file }}")
23+
echo "version=$version" >> $GITHUB_OUTPUT
24+
25+
- name: Publish Nuget and Tag Commit
26+
run: |
27+
dotnet build ManualDi.Main --configuration Release
28+
dotnet pack ManualDi.Main --configuration Release --output NugetPackageRelease
29+
set +e # Disable immediate exit on error
30+
dotnet nuget push "NugetPackageRelease/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key "${{secrets.NUGET_API_KEY}}"
31+
push_result=$?
32+
set -e # Enable immediate exit on error
33+
34+
if [ $push_result -ne 0 ]; then
35+
echo "Package could not be pushed, assuming a package with that version is already present"
36+
exit 0
37+
fi
38+
39+
echo "NuGet package pushed successfully"

.github/workflows/PublishUnity3dPackage.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_call:
44

55
env:
6-
version_file: ManualDi.Main/ManualDi.Main.csproj
6+
version_file: ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj
77

88
jobs:
99
PublishUnity3dPackage:
@@ -25,7 +25,7 @@ jobs:
2525
env:
2626
GH_TOKEN: ${{ github.token }}
2727
run: |
28-
release_exists=$(gh release view "Unity3d/${{ steps.get-version.outputs.version }}" &> /dev/null && echo "true" || echo "false")
28+
release_exists=$(gh release view "v${{ steps.get-version.outputs.version }}" &> /dev/null && echo "true" || echo "false")
2929
echo "Release exists $release_exists"
3030
echo "exists=$release_exists" >> $GITHUB_OUTPUT
3131
@@ -38,18 +38,18 @@ jobs:
3838
if: ${{ steps.release-exists.outputs.exists == 'false' }}
3939
uses: softprops/action-gh-release@v2
4040
with:
41-
tag_name: Unity3d/${{ steps.get-version.outputs.version }}
42-
name: Unity3d ManualDi.Main ${{ steps.get-version.outputs.version }}
41+
tag_name: v${{ steps.get-version.outputs.version }}
42+
name: ManualDi Unity3d v${{ steps.get-version.outputs.version }}
4343
files: |
44-
UnityPackageRelease/me.pereviader.manualdi.main-${{ steps.get-version.outputs.version }}.tgz
44+
UnityPackageRelease/com.pereviader.manualdi.unity3d-${{ steps.get-version.outputs.version }}.tgz
4545
4646
- name: Trigger Unity3d Repo Workflow
4747
if: ${{ steps.release-exists.outputs.exists == 'false' }}
4848
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
GITHUB_TOKEN: ${{ secrets.WORKFLOW_UNITY3D }}
5050
run: |
5151
gh workflow run PublishUnity3dPackage.yml \
5252
--repo PereViader/ManualDi.Unity3d \
5353
--ref main \
54-
-f release-tag=Unity3d/${{ steps.get-version.outputs.version }}
55-
-f file-name=me.pereviader.manualdi.main-${{ steps.get-version.outputs.version }}.tgz
54+
-f release-tag=v${{ steps.get-version.outputs.version }} \
55+
-f file-name=com.pereviader.manualdi.unity3d-${{ steps.get-version.outputs.version }}.tgz

GenerateUnityPackage/GeneratePackage.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ while [[ "$#" -gt 0 ]]; do
1717
shift
1818
done
1919

20-
# Path to the .csproj file and package.json
20+
# Path to the .csproj file
2121
CSPROJ_FILE="ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj"
2222

2323
# Extract version from the .csproj file
@@ -36,7 +36,7 @@ mkdir -p "UnityPackageRelease/"
3636
echo Copy License
3737
cp "LICENSE.md" "UnityPackageRelease/LICENSE.md"
3838

39-
cp "GenerateUnityPackage\package.json" "UnityPackageRelease\package.json"
39+
cp "GenerateUnityPackage/package.json" "UnityPackageRelease/package.json"
4040
echo "Copy package files to the package root"
4141
sed -i "s/\"version\": \"\$version\"/\"version\": \"$version\"/g" "UnityPackageRelease/package.json"
4242
echo "Version in package.json updated to $version"

ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<None Include="..\ManualDi.Main.Generators\bin\$(Configuration)\netstandard2.0\ManualDi.Main.Generators.dll"
20+
<None Include="$(SolutionDir)ManualDi.Main.Generators\bin\$(Configuration)\netstandard2.0\ManualDi.Main.Generators.dll"
2121
Pack="true"
2222
PackagePath="analyzers/dotnet/cs"
2323
Visible="false" />

0 commit comments

Comments
 (0)