Skip to content

Commit f244371

Browse files
committed
Update version
1 parent f161dbc commit f244371

File tree

9 files changed

+276
-21
lines changed

9 files changed

+276
-21
lines changed

.github/workflows/release.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
id: versions
2828
run: dotnet run -c Release --project ChromeForTesting/ChromeForTesting.VersionManager
2929
env:
30-
VERSION_INCREMENT: '1'
30+
VERSION_INCREMENT: '2'
3131

3232
VerifyTagExists:
3333
needs:
@@ -91,21 +91,21 @@ jobs:
9191
env:
9292
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9393
94-
# - name: Replace Version
95-
# run: |
96-
# set -e
97-
# sed 's/$(FirefoxVersion)/${{ env.FIREFOX_VERSION }}/g' -i packages/nuget/PortableFirefox/PortableFirefox/build/PortableFirefox.targets
98-
# sed 's/$(Version)/${{ env.NUGET_PACKAGE_VERSION }}/g' -i packages/nuget/PortableFirefox/PortableFirefox/build/PortableFirefox.targets
94+
- name: Replace Version
95+
run: |
96+
set -e
97+
sed 's/$(FirefoxVersion)/${{ env.CHROME_VERSION }}/g' -i ChromeForTesting/ChromeForTesting/build/ChromeForTesting.targets
98+
sed 's/$(Version)/${{ env.NUGET_PACKAGE_VERSION }}/g' -i ChromeForTesting/ChromeForTesting/build/ChromeForTesting.targets
9999
100-
# - name: Setup .NET
101-
# uses: actions/setup-dotnet@v4
102-
# with:
103-
# dotnet-version: 6.x
100+
- name: Setup .NET
101+
uses: actions/setup-dotnet@v4
102+
with:
103+
dotnet-version: 6.x
104104

105-
# - name: Pack
106-
# working-directory: packages/nuget/PortableFirefox
107-
# run: dotnet pack PortableFirefox --configuration Release /p:Version=${{ env.NUGET_PACKAGE_VERSION }} /p:FirefoxVersion=${{ env.FIREFOX_VERSION }}
105+
- name: Pack
106+
working-directory: ChromeForTesting
107+
run: dotnet pack ChromeForTesting.csproj --configuration Release /p:Version=${{ env.NUGET_PACKAGE_VERSION }} /p:ChromeVersion=${{ env.CHROME_VERSION }}
108108

109-
# - name: Publish nuget
110-
# working-directory: packages/nuget/PortableFirefox
111-
# run: dotnet nuget push PortableFirefox/bin/Release/PortableFirefox.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://www.nuget.org --skip-duplicate
109+
- name: Publish nuget
110+
working-directory: ChromeForTesting
111+
run: dotnet nuget push ChromeForTesting/bin/Release/ChromeForTesting.*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://www.nuget.org --skip-duplicate
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using CliWrap;
2+
using CliWrap.Buffered;
3+
4+
namespace ChromeForTesting.Tests;
5+
6+
public class BasicTests
7+
{
8+
[Test]
9+
public async Task Test_Get_Version_Works_Async()
10+
{
11+
BufferedCommandResult res = await Cli.Wrap(ChromeForTestingInstance.ChromePath)
12+
.WithArguments("--version")
13+
.WithValidation(CommandResultValidation.None)
14+
.ExecuteBufferedAsync();
15+
16+
Assert.That(res.ExitCode, Is.EqualTo(0));
17+
Assert.That(res.StandardOutput, Is.Not.Empty);
18+
}
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="ChromeForTesting" Version="125.0.6422.6001" />
14+
<PackageReference Include="CliWrap" Version="3.6.6" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
16+
<PackageReference Include="NUnit" Version="3.13.3"/>
17+
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/>
18+
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>
19+
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global using NUnit.Framework;

ChromeForTesting/ChromeForTesting.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChromeForTesting", "ChromeF
44
EndProject
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChromeForTesting.VersionManager", "ChromeForTesting.VersionManager\ChromeForTesting.VersionManager.csproj", "{0DBA2013-2A31-4F1B-8869-1F47F0B603C6}"
66
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChromeForTesting.Tests", "ChromeForTesting.Tests\ChromeForTesting.Tests.csproj", "{A61C98BC-F4C0-4700-9E79-79D951D057D5}"
8+
EndProject
79
Global
810
GlobalSection(SolutionConfigurationPlatforms) = preSolution
911
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
1820
{0DBA2013-2A31-4F1B-8869-1F47F0B603C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
1921
{0DBA2013-2A31-4F1B-8869-1F47F0B603C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
2022
{0DBA2013-2A31-4F1B-8869-1F47F0B603C6}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{A61C98BC-F4C0-4700-9E79-79D951D057D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{A61C98BC-F4C0-4700-9E79-79D951D057D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{A61C98BC-F4C0-4700-9E79-79D951D057D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{A61C98BC-F4C0-4700-9E79-79D951D057D5}.Release|Any CPU.Build.0 = Release|Any CPU
2127
EndGlobalSection
2228
EndGlobal

ChromeForTesting/ChromeForTesting/ChromeForTesting.csproj

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,44 @@
88
<ChromeVersion Condition=" '$(Configuration)' == 'Debug' ">125.0.6422.60</ChromeVersion>
99
</PropertyGroup>
1010

11+
<PropertyGroup>
12+
<PackageId>ChromeForTesting</PackageId>
13+
<Version Condition=" '$(Configuration)' == 'Debug' ">125.0.6422.6001</Version>
14+
<Authors>MyDesigns Devs</Authors>
15+
<Company>MyDesigns</Company>
16+
<RepositoryUrl>https://github.com/madcoons/chrome-for-testing-nuget.git</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
18+
<PackageReadmeFile>README.md</PackageReadmeFile>
19+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
20+
<PackageTags>Chrome;ChromeForTesting;Browser;Portable;No-Installation;Cross-Platform</PackageTags>
21+
</PropertyGroup>
22+
23+
<Target Name="GenerateVersionConstant" BeforeTargets="BeforeCompile">
24+
<PropertyGroup>
25+
<ChromeInstanceVersionSourceFile>
26+
namespace ChromeForTesting%3B
27+
28+
public partial class ChromeForTestingInstance
29+
{
30+
public const string CHROME_VERSION = "$(ChromeVersion)"%3B
31+
public const string NUGET_PACKAGE_VERSION = "$(Version)"%3B
32+
}
33+
</ChromeInstanceVersionSourceFile>
34+
</PropertyGroup>
35+
<WriteLinesToFile
36+
File="$(IntermediateOutputPath)ChromeForTestingInstance.Version.cs"
37+
Lines="$(ChromeInstanceVersionSourceFile)"
38+
Overwrite="true"
39+
WriteOnlyWhenDifferent="true"/>
40+
</Target>
41+
42+
<ItemGroup>
43+
<None Include="../../README.md" Pack="true" PackagePath="/"/>
44+
<None Include="build/ChromeForTesting.targets" pack="true" PackagePath="build/"/>
45+
<None Include="build/ChromeForTesting.targets" Pack="true" PackagePath="buildMultiTargeting/"/>
46+
<None Include="build/ChromeForTesting.targets" Pack="true" PackagePath="buildTransitive/"/>
47+
<Compile Include="$(IntermediateOutputPath)ChromeForTestingInstance.Version.cs"/>
48+
</ItemGroup>
49+
50+
<Import Project="$(MSBuildThisFileDirectory)/build/ChromeForTesting.targets" Condition=" '$(Configuration)' == 'Debug' " />
1151
</Project>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System.Runtime.InteropServices;
2+
3+
namespace ChromeForTesting;
4+
5+
public partial class ChromeForTestingInstance
6+
{
7+
private enum OS
8+
{
9+
Linux,
10+
MacOS,
11+
Windows
12+
}
13+
14+
public static string ChromePath
15+
=> CurrentPlatform switch
16+
{
17+
(OS.MacOS, _) => Path.Join([
18+
AbsoluteRootPath,
19+
$"chrome-{ChromePlatform}",
20+
"Google Chrome for Testing.app",
21+
"Contents",
22+
"MacOS",
23+
"Google Chrome for Testing"
24+
]),
25+
_ => throw new($"Unsupported platform '{CurrentPlatform}'")
26+
};
27+
28+
private static string AbsoluteRootPath
29+
=> Path.Join(AppDomain.CurrentDomain.BaseDirectory, "chrome-for-testing-" + NUGET_PACKAGE_VERSION);
30+
31+
private static string BinSubDir
32+
=> OperatingSystem.IsLinux()
33+
? Path.Join("firefox-root", "firefox-app")
34+
: OperatingSystem.IsMacOS()
35+
? Path.Join("Firefox.app", "Contents", "MacOS")
36+
: throw new("Unsupported platform.");
37+
38+
private static string ChromePlatform
39+
=> CurrentPlatform switch
40+
{
41+
(OS.Linux, Architecture.X64) => "linux64",
42+
(OS.MacOS, Architecture.X64) => "mac-x64",
43+
(OS.MacOS, Architecture.Arm64) => "mac-arm64",
44+
(OS.Windows, Architecture.X86) => "win32",
45+
(OS.Windows, Architecture.X64) => "win64",
46+
_ => throw new($"Unsupported platform '{CurrentPlatform}'.")
47+
};
48+
49+
private static (OS OS, Architecture Architecture) CurrentPlatform
50+
=> (GetPlatform(), RuntimeInformation.OSArchitecture);
51+
52+
private static OS GetPlatform()
53+
{
54+
if (OperatingSystem.IsLinux())
55+
{
56+
return OS.Linux;
57+
}
58+
59+
if (OperatingSystem.IsMacOS())
60+
{
61+
return OS.MacOS;
62+
}
63+
64+
if (OperatingSystem.IsWindows())
65+
{
66+
return OS.Windows;
67+
}
68+
69+
throw new($"Unsupported operating system '{RuntimeInformation.OSDescription}'.");
70+
}
71+
}

ChromeForTesting/ChromeForTesting/Class1.cs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Cache>$(MSBuildThisFileDirectory)../.cache/</Cache>
5+
</PropertyGroup>
6+
<Target Name="CleanChrome" BeforeTargets="Clean">
7+
<RemoveDir
8+
Directories="$(OutDir)chrome-for-testing-$(Version)"
9+
Condition="Exists('$(OutDir)chrome-for-testing-$(Version)')"
10+
/>
11+
</Target>
12+
<Target Name="DownloadChromeInBuild" AfterTargets="Build">
13+
<MakeDir Directories="$(Cache)" Condition="!Exists('$(Cache)')" />
14+
<MakeDir Directories="$(OutDir)chrome-for-testing-$(Version)"
15+
Condition="!Exists('$(OutDir)chrome-for-testing-$(Version)')" />
16+
<!-- Linux-->
17+
<Exec Command="uname -m" ConsoleToMSBuild="true"
18+
Condition="$([MSBuild]::IsOSPlatform('Linux'))">
19+
<Output TaskParameter="ConsoleOutput" PropertyName="OSArchitecture" />
20+
</Exec>
21+
<Error Text="Only x86_64 is supported on linux"
22+
Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(OSArchitecture)' != 'x86_64'" />
23+
<PropertyGroup>
24+
<ChromePlatrofm Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(OSArchitecture)' == 'x86_64'">linux64</ChromePlatrofm>
25+
</PropertyGroup>
26+
<DownloadFile
27+
Condition="$([MSBuild]::IsOSPlatform('Linux'))"
28+
SourceUrl="https://github.com/madcoons/chrome-for-testing-nuget/releases/download/v$(Version)/chrome-linux64.tar.gz"
29+
DestinationFolder="$(Cache)"
30+
DestinationFileName="chrome-linux64.tar.gz">
31+
</DownloadFile>
32+
<Exec
33+
Command="tar -xf '$(Cache)chrome-linux64.tar.gz' -C '$(OutDir)chrome-for-testing-$(Version)'"
34+
Condition="$([MSBuild]::IsOSPlatform('Linux')) And !Exists('$(OutDir)chrome-for-testing-$(Version)/chrome-root')" />
35+
<!-- MacOS-->
36+
<Exec Command="uname -m" ConsoleToMSBuild="true"
37+
Condition="$([MSBuild]::IsOSPlatform('OSX'))">
38+
<Output TaskParameter="ConsoleOutput" PropertyName="OSArchitecture" />
39+
</Exec>
40+
<Error Text="Only x86_64 and arm64 are supported on mac"
41+
Condition="$([MSBuild]::IsOSPlatform('OSX')) AND '$(OSArchitecture)' != 'x86_64' AND '$(OSArchitecture)' != 'arm64'" />
42+
<PropertyGroup>
43+
<ChromePlatrofm Condition="$([MSBuild]::IsOSPlatform('OSX')) AND '$(OSArchitecture)' == 'arm64'">mac-arm64</ChromePlatrofm>
44+
<ChromePlatrofm Condition="$([MSBuild]::IsOSPlatform('OSX')) AND '$(OSArchitecture)' == 'x86_64'">mac-x64</ChromePlatrofm>
45+
</PropertyGroup>
46+
<DownloadFile
47+
Condition="$([MSBuild]::IsOSPlatform('OSX'))"
48+
SourceUrl="https://storage.googleapis.com/chrome-for-testing-public/$(ChromeVersion)/$(ChromePlatrofm)/chrome-$(ChromePlatrofm).zip"
49+
DestinationFolder="$(Cache)"
50+
DestinationFileName="chrome.zip">
51+
</DownloadFile>
52+
<Exec
53+
Command="unzip '$(Cache)chrome.zip' -d '$(OutDir)chrome-for-testing-$(Version)'"
54+
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(OutDir)chrome-for-testing-$(Version)/chrome-$(ChromePlatrofm)')" />
55+
</Target>
56+
57+
<Target Name="DownloadChromeInPublish" AfterTargets="Publish">
58+
<MakeDir Directories="$(Cache)" Condition="!Exists('$(Cache)')" />
59+
<MakeDir Directories="$(PublishDir)chrome-for-testing-$(Version)"
60+
Condition="!Exists('$(PublishDir)chrome-for-testing-$(Version)')" />
61+
<!-- Linux-->
62+
<Exec Command="uname -m" ConsoleToMSBuild="true"
63+
Condition="$([MSBuild]::IsOSPlatform('Linux'))">
64+
<Output TaskParameter="ConsoleOutput" PropertyName="OSArchitecture" />
65+
</Exec>
66+
<Error Text="Only x86_64 is supported on linux"
67+
Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(OSArchitecture)' != 'x86_64'" />
68+
<PropertyGroup>
69+
<ChromePlatrofm Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(OSArchitecture)' == 'x86_64'">linux64</ChromePlatrofm>
70+
</PropertyGroup>
71+
<DownloadFile
72+
Condition="$([MSBuild]::IsOSPlatform('Linux'))"
73+
SourceUrl="https://github.com/madcoons/chrome-for-testing-nuget/releases/download/v$(Version)/chrome-linux64.tar.gz"
74+
DestinationFolder="$(Cache)"
75+
DestinationFileName="chrome-linux64.tar.gz">
76+
</DownloadFile>
77+
<Exec
78+
Command="tar -xf '$(Cache)chrome-linux64.tar.gz' -C '$(PublishDir)chrome-for-testing-$(Version)'"
79+
Condition="$([MSBuild]::IsOSPlatform('Linux')) And !Exists('$(PublishDir)chrome-for-testing-$(Version)/chrome-root')" />
80+
<!-- MacOS-->
81+
<Exec Command="uname -m" ConsoleToMSBuild="true"
82+
Condition="$([MSBuild]::IsOSPlatform('OSX'))">
83+
<Output TaskParameter="ConsoleOutput" PropertyName="OSArchitecture" />
84+
</Exec>
85+
<Error Text="Only x86_64 and arm64 are supported on mac"
86+
Condition="$([MSBuild]::IsOSPlatform('OSX')) AND '$(OSArchitecture)' != 'x86_64' AND '$(OSArchitecture)' != 'arm64'" />
87+
<PropertyGroup>
88+
<ChromePlatrofm Condition="$([MSBuild]::IsOSPlatform('OSX')) AND '$(OSArchitecture)' == 'arm64'">mac-arm64</ChromePlatrofm>
89+
<ChromePlatrofm Condition="$([MSBuild]::IsOSPlatform('OSX')) AND '$(OSArchitecture)' == 'x86_64'">mac-x64</ChromePlatrofm>
90+
</PropertyGroup>
91+
<DownloadFile
92+
Condition="$([MSBuild]::IsOSPlatform('OSX'))"
93+
SourceUrl="https://storage.googleapis.com/chrome-for-testing-public/$(ChromeVersion)/$(ChromePlatrofm)/chrome-$(ChromePlatrofm).zip"
94+
DestinationFolder="$(Cache)"
95+
DestinationFileName="chrome.zip">
96+
</DownloadFile>
97+
<Exec
98+
Command="unzip '$(Cache)chrome.zip' -d '$(PublishDir)chrome-for-testing-$(Version)'"
99+
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(PublishDir)chrome-for-testing-$(Version)/chrome-$(ChromePlatrofm)')" />
100+
</Target>
101+
</Project>

0 commit comments

Comments
 (0)