Skip to content

Commit

Permalink
Fix issues in publish workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
PereViader committed Aug 24, 2024
1 parent f1fe14c commit 0b83352
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
36 changes: 24 additions & 12 deletions .github/workflows/PublishNugetPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Publish Nuget Package

on:
workflow_call:

env:
version_file: ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj

jobs:
PublishNugetPackage:
Expand All @@ -13,15 +16,24 @@ jobs:
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0'

- name: Build Common Project
run: dotnet build --configuration Release

- name: Publish Common
uses: tedd/publish-nuget-neo@v1
with:
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
PROJECT_FILE_PATH: ManualDi.Main/ManualDi.Main.csproj
REBUILD_PROJECT: false
TAG_COMMIT: true
TAG_FORMAT: Nuget/*

- id: get-version
run: |
version=$(grep -oP '(?<=<Version>)[^<]+' "${{ env.version_file }}")
echo "version=$version" >> $GITHUB_OUTPUT
- name: Publish Nuget and Tag Commit
run: |
dotnet build ManualDi.Main --configuration Release
dotnet pack ManualDi.Main --configuration Release --output NugetPackageRelease
set +e # Disable immediate exit on error
dotnet nuget push "NugetPackageRelease/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key "${{secrets.NUGET_API_KEY}}"
push_result=$?
set -e # Enable immediate exit on error
if [ $push_result -ne 0 ]; then
echo "Package could not be pushed, assuming a package with that version is already present"
exit 0
fi
echo "NuGet package pushed successfully"
12 changes: 6 additions & 6 deletions .github/workflows/PublishUnity3dPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_call:

env:
version_file: ManualDi.Main/ManualDi.Main.csproj
version_file: ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj

jobs:
PublishUnity3dPackage:
Expand Down Expand Up @@ -38,18 +38,18 @@ jobs:
if: ${{ steps.release-exists.outputs.exists == 'false' }}
uses: softprops/action-gh-release@v2
with:
tag_name: Unity3d/${{ steps.get-version.outputs.version }}
tag_name: v${{ steps.get-version.outputs.version }}
name: Unity3d ManualDi.Main ${{ steps.get-version.outputs.version }}
files: |
UnityPackageRelease/me.pereviader.manualdi.main-${{ steps.get-version.outputs.version }}.tgz
UnityPackageRelease/com.pereviader.manualdi.unity3d-${{ steps.get-version.outputs.version }}.tgz
- name: Trigger Unity3d Repo Workflow
if: ${{ steps.release-exists.outputs.exists == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.WORKFLOW_UNITY3D }}
run: |
gh workflow run PublishUnity3dPackage.yml \
--repo PereViader/ManualDi.Unity3d \
--ref main \
-f release-tag=Unity3d/${{ steps.get-version.outputs.version }}
-f file-name=me.pereviader.manualdi.main-${{ steps.get-version.outputs.version }}.tgz
-f release-tag=v${{ steps.get-version.outputs.version }} \
-f file-name=com.pereviader.manualdi.unity3d-${{ steps.get-version.outputs.version }}.tgz
4 changes: 2 additions & 2 deletions GenerateUnityPackage/GeneratePackage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ while [[ "$#" -gt 0 ]]; do
shift
done

# Path to the .csproj file and package.json
# Path to the .csproj file
CSPROJ_FILE="ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj"

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

cp "GenerateUnityPackage\package.json" "UnityPackageRelease\package.json"
cp "GenerateUnityPackage/package.json" "UnityPackageRelease/package.json"
echo "Copy package files to the package root"
sed -i "s/\"version\": \"\$version\"/\"version\": \"$version\"/g" "UnityPackageRelease/package.json"
echo "Version in package.json updated to $version"
Expand Down
2 changes: 1 addition & 1 deletion ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\ManualDi.Main.Generators\bin\$(Configuration)\netstandard2.0\ManualDi.Main.Generators.dll"
<None Include="$(SolutionDir)ManualDi.Main.Generators\bin\$(Configuration)\netstandard2.0\ManualDi.Main.Generators.dll"
Pack="true"
PackagePath="analyzers/dotnet/cs"
Visible="false" />
Expand Down

0 comments on commit 0b83352

Please sign in to comment.