Skip to content

Commit

Permalink
Add automatic upload of artifacts to GitHub packages (MonoGame#7773)
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-cpp authored Apr 30, 2022
1 parent 53dbbc4 commit f3a34a5
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 40 deletions.
45 changes: 44 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ on: [push, pull_request]

jobs:
build:
name: build-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-20.04]
os: [windows-latest, macos-latest, ubuntu-latest]
steps:
- name: Clone repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -55,4 +56,46 @@ jobs:
path: |
Artifacts/MonoGame.Templates.VSExtension/*.vsix
if-no-files-found: error
check-deploy:
runs-on: ubuntu-latest
needs: [ build ]
if: ${{ github.event_name == 'push' }}
outputs:
isGitHubTokenSet: ${{ steps.isGitHubTokenSet.outputs.defined }}
steps:
- id: isGitHubTokenSet
if: "${{ env.GITHUB_TOKEN != '' }}"
run: echo "::set-output name=defined::true"
env:
GITHUB_TOKEN: ${{ secrets.PUSH_NUGET }}
deploy:
name: deploy
runs-on: ubuntu-latest
needs: [ check-deploy ]
if: needs.check-deploy.outputs.isGitHubTokenSet == 'true'
steps:
- name: Download NuGet artifacts from Windows
uses: actions/download-artifact@v3
with:
name: nuget-windows-latest
path: nuget-windows
- name: Download NuGet artifacts from macOS
uses: actions/download-artifact@v3
with:
name: nuget-macos-latest
path: nuget-macos
- name: Download NuGet artifacts from Ubuntu
uses: actions/download-artifact@v3
with:
name: nuget-ubuntu-latest
path: nuget-ubuntu
- name: Move NuGet packages to one folder
run: mkdir nuget && cp -Rf nuget-windows/. nuget && cp -Rf nuget-macos/. nuget && cp -Rf nuget-ubuntu/. nuget
- name: Push packages
run: dotnet nuget push nuget/*.nupkg --source https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --api-key ${GITHUB_TOKEN}
env:
GITHUB_TOKEN: ${{ secrets.PUSH_NUGET }}




Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@


<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="AssimpNet" Version="4.1.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
Expand All @@ -9,15 +8,12 @@
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.1-develop" />
<PackageReference Include="MonoGame.Framework.Android" Version="3.8.1.1-develop" />
</ItemGroup>

<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Icon.ico" />
<EmbeddedResource Include="Icon.bmp" />
</ItemGroup>

<ItemGroup>
<TrimmerRootAssembly Include="MonoGame.Framework" Visible="false" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.1-develop" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.1-develop" />
</ItemGroup>

<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
Expand All @@ -8,24 +7,19 @@
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<TrimmerRootAssembly Include="MonoGame.Framework" Visible="false" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.1.1-develop" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.1-develop" />
</ItemGroup>

<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-ios</TargetFramework>
<OutputType>Exe</OutputType>
<SupportedOSPlatformVersion>11.2</SupportedOSPlatformVersion>
<ImplicitUsings>true</ImplicitUsings>
<CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.1-develop" />
<PackageReference Include="MonoGame.Framework.iOS" Version="3.8.1.1-develop" />
</ItemGroup>

<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.1-develop">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.Content.Pipeline" Version="3.8.1.1-develop">
<PrivateAssets>All</PrivateAssets>
Expand All @@ -13,5 +11,4 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
</Project>
20 changes: 15 additions & 5 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

var target = Argument("build-target", "Default");
var version = Argument("build-version", EnvironmentVariable("BUILD_NUMBER") ?? "3.8.1.1");
var repositoryUrl = Argument("repository-url", "https://github.com/MonoGame/MonoGame");
var configuration = Argument("build-configuration", "Release");

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -60,8 +61,13 @@ private void ParseVersion()
if (!string.IsNullOrEmpty(EnvironmentVariable("GITHUB_ACTIONS")))
{
version = "3.8.1." + EnvironmentVariable("GITHUB_RUN_NUMBER");
if (EnvironmentVariable("GITHUB_REF") != "refs/heads/master")

if (EnvironmentVariable("GITHUB_REPOSITORY") != "MonoGame/MonoGame")
version += "-" + EnvironmentVariable("GITHUB_REPOSITORY_OWNER");
else if (EnvironmentVariable("GITHUB_REF") != "refs/heads/master")
version += "-develop";

repositoryUrl = "https://github.com/" + EnvironmentVariable("GITHUB_REPOSITORY");
}
else
{
Expand Down Expand Up @@ -91,21 +97,25 @@ Task("Prep")
msPackSettings.Restore = true;
msPackSettings.WithProperty("Version", version);
msPackSettings.WithProperty("OutputDirectory", "Artifacts/NuGet");
msPackSettings.WithProperty("RepositoryUrl", repositoryUrl);
msPackSettings.WithTarget("Pack");

mdPackSettings = new MSBuildSettings();
mdPackSettings.Verbosity = Verbosity.Minimal;
mdPackSettings.Configuration = configuration;
mdPackSettings.WithProperty("Version", version);
mdPackSettings.WithProperty("RepositoryUrl", repositoryUrl);
mdPackSettings.WithTarget("PackageAddin");

msBuildSettings = new MSBuildSettings();
msBuildSettings.Verbosity = Verbosity.Minimal;
msBuildSettings.Configuration = configuration;
msBuildSettings.WithProperty("Version", version);
msBuildSettings.WithProperty("RepositoryUrl", repositoryUrl);

dnMsBuildSettings = new DotNetMSBuildSettings();
dnMsBuildSettings.WithProperty("Version", version);
dnMsBuildSettings.WithProperty("RepositoryUrl", repositoryUrl);

dnBuildSettings = new DotNetBuildSettings();
dnBuildSettings.MSBuildSettings = dnMsBuildSettings;
Expand Down Expand Up @@ -240,17 +250,17 @@ Task("BuildTools")
if (IsRunningOnWindows())
{
PublishDotnet("Tools/MonoGame.Content.Builder.Editor/MonoGame.Content.Builder.Editor.Windows.csproj");
DotNetBuild("Tools/MonoGame.Content.Builder.Editor.Launcher/MonoGame.Content.Builder.Editor.Launcher.Windows.csproj", dnBuildSettings);
PackDotnet("Tools/MonoGame.Content.Builder.Editor.Launcher/MonoGame.Content.Builder.Editor.Launcher.Windows.csproj");
}
else if (IsRunningOnMacOs())
{
PackDotnet("Tools/MonoGame.Content.Builder.Editor/MonoGame.Content.Builder.Editor.Mac.csproj");
DotNetBuild("Tools/MonoGame.Content.Builder.Editor.Launcher/MonoGame.Content.Builder.Editor.Launcher.Mac.csproj", dnBuildSettings);
PublishDotnet("Tools/MonoGame.Content.Builder.Editor/MonoGame.Content.Builder.Editor.Mac.csproj");
PackDotnet("Tools/MonoGame.Content.Builder.Editor.Launcher/MonoGame.Content.Builder.Editor.Launcher.Mac.csproj");
}
else
{
PublishDotnet("Tools/MonoGame.Content.Builder.Editor/MonoGame.Content.Builder.Editor.Linux.csproj");
DotNetBuild("Tools/MonoGame.Content.Builder.Editor.Launcher/MonoGame.Content.Builder.Editor.Launcher.Linux.csproj", dnBuildSettings);
PackDotnet("Tools/MonoGame.Content.Builder.Editor.Launcher/MonoGame.Content.Builder.Editor.Launcher.Linux.csproj");
}

PackDotnet("Tools/MonoGame.Content.Builder.Editor.Launcher.Bootstrap/MonoGame.Content.Builder.Editor.Launcher.Bootstrap.csproj");
Expand Down

0 comments on commit f3a34a5

Please sign in to comment.