Skip to content

Commit 52e0235

Browse files
Initial commit
1 parent 9621ffb commit 52e0235

34 files changed

+1753
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "external/CYRTextView"]
2+
path = external/CYRTextView
3+
url = https://github.com/codefoco-forks/CYRTextView.git

BuildFunctions.ps1

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
function Get-Current-Branch-Name ()
2+
{
3+
$branch = ([string](git rev-parse --abbrev-ref HEAD)).Trim()
4+
$parts = $branch.Split('/')
5+
$branch = $parts[$parts.Length - 1]
6+
return $branch
7+
}
8+
9+
function Get-Current-Commit-Hash ()
10+
{
11+
return ([string](git log -1 --pretty=%h)).Trim()
12+
}
13+
14+
function Get-Current-Commit-Message ()
15+
{
16+
return ([string](git log -1 --pretty=%B)).Trim()
17+
}
18+
19+
function Test-Should-Deploy ()
20+
{
21+
$nugetGitVersion = Get-Git-Package-Version
22+
$buildMetaData = Get-Git-Build-MetaData
23+
$fullSemVer = Get-Git-Full-Sem-Ver
24+
25+
if (Test-Tag-Build $nugetGitVersion $buildMetaData $fullSemVer) {
26+
return $true
27+
}
28+
return $false
29+
}
30+
31+
function Get-Published-PreRelase-Package ($PackageId)
32+
{
33+
$out = [string](nuget list -PreRelease id:$PackageId)
34+
$version = $out.Split(' ')[1]
35+
return $version
36+
}
37+
38+
function Get-Published-PreRelase-Package-Version ($PackageId)
39+
{
40+
$version = Get-Published-PreRelase-Package $PackageId
41+
$version = $version.Split('-')[0]
42+
return $version
43+
}
44+
45+
function Get-Published-Package ($PackageId)
46+
{
47+
$out = [string](nuget list id:$PackageId)
48+
$version = $out.Split(' ')[1]
49+
return $version
50+
}
51+
52+
function Get-Published-Package-Version ($PackageId)
53+
{
54+
$version = Get-Published-Package $PackageId
55+
$version = $version.Split('-')[0]
56+
return $version
57+
}
58+
59+
function Get-Git-Package-Version ()
60+
{
61+
Update-Ensure-Git-Not-Detached
62+
return [string](gitversion /showvariable MajorMinorPatch)
63+
}
64+
65+
function Get-Git-Build-MetaData ()
66+
{
67+
Update-Ensure-Git-Not-Detached
68+
return [string](gitversion /showvariable BuildMetaData)
69+
}
70+
71+
function Get-Git-Full-Sem-Ver ()
72+
{
73+
Update-Ensure-Git-Not-Detached
74+
75+
return [string](gitversion /showvariable FullSemVer)
76+
}
77+
78+
function Update-NuSpec-Release-Notes($File, $releaseNotes)
79+
{
80+
$File = Resolve-Path $File
81+
82+
[xml] $fileContents = Get-Content -Encoding UTF8 -Path $File
83+
84+
$releaseNotesPath = "package.metadata.releaseNotes"
85+
86+
if ($releaseNotes -ne $null -and $releaseNotes -ne "") {
87+
Set-XmlElementsTextValue -XmlDocument $fileContents -ElementPath $releaseNotesPath -TextValue $releaseNotes
88+
}
89+
$fileContents.Save($File)
90+
}
91+
92+
function Update-NuSpec-Version($File, $Version)
93+
{
94+
$File = Resolve-Path $File
95+
96+
[xml] $fileContents = Get-Content -Encoding UTF8 -Path $File
97+
98+
$versionPath = "package.metadata.version"
99+
100+
if ($Version -ne $null -and $Version -ne "") {
101+
Set-XmlElementsTextValue -XmlDocument $fileContents -ElementPath $versionPath -TextValue $Version
102+
}
103+
104+
$fileContents.Save($File)
105+
}
106+
107+
function Get-XmlNamespaceManager([xml]$XmlDocument, [string]$NamespaceURI = "")
108+
{
109+
# If a Namespace URI was not given, use the Xml document's default namespace.
110+
if ([string]::IsNullOrEmpty($NamespaceURI)) { $NamespaceURI = $XmlDocument.DocumentElement.NamespaceURI }
111+
112+
# In order for SelectSingleNode() to actually work, we need to use the fully qualified node path along with an Xml Namespace Manager, so set them up.
113+
[System.Xml.XmlNamespaceManager]$xmlNsManager = New-Object System.Xml.XmlNamespaceManager($XmlDocument.NameTable)
114+
$xmlNsManager.AddNamespace("ns", $NamespaceURI)
115+
return ,$xmlNsManager # Need to put the comma before the variable name so that PowerShell doesn't convert it into an Object[].
116+
}
117+
118+
function Get-FullyQualifiedXmlNodePath([string]$NodePath, [string]$NodeSeparatorCharacter = '.')
119+
{
120+
return "/ns:$($NodePath.Replace($($NodeSeparatorCharacter), '/ns:'))"
121+
}
122+
123+
function Get-XmlNode([xml]$XmlDocument, [string]$NodePath, [string]$NamespaceURI = "", [string]$NodeSeparatorCharacter = '.')
124+
{
125+
$xmlNsManager = Get-XmlNamespaceManager -XmlDocument $XmlDocument -NamespaceURI $NamespaceURI
126+
[string]$fullyQualifiedNodePath = Get-FullyQualifiedXmlNodePath -NodePath $NodePath -NodeSeparatorCharacter $NodeSeparatorCharacter
127+
128+
# Try and get the node, then return it. Returns $null if the node was not found.
129+
$node = $XmlDocument.SelectSingleNode($fullyQualifiedNodePath, $xmlNsManager)
130+
return $node
131+
}
132+
133+
function Set-XmlElementsTextValue([xml]$XmlDocument, [string]$ElementPath, [string]$TextValue, [string]$NamespaceURI = "", [string]$NodeSeparatorCharacter = '.')
134+
{
135+
# Try and get the node.
136+
$node = Get-XmlNode -XmlDocument $XmlDocument -NodePath $ElementPath -NamespaceURI $NamespaceURI -NodeSeparatorCharacter $NodeSeparatorCharacter
137+
138+
# If the node already exists, update its value.
139+
if ($node)
140+
{
141+
$node.InnerText = $TextValue
142+
}
143+
# Else the node doesn't exist yet, so create it with the given value.
144+
else
145+
{
146+
# Create the new element with the given value.
147+
$elementName = $ElementPath.Substring($ElementPath.LastIndexOf($NodeSeparatorCharacter) + 1)
148+
$element = $XmlDocument.CreateElement($elementName, $XmlDocument.DocumentElement.NamespaceURI)
149+
$textNode = $XmlDocument.CreateTextNode($TextValue)
150+
$element.AppendChild($textNode) > $null
151+
152+
# Try and get the parent node.
153+
$parentNodePath = $ElementPath.Substring(0, $ElementPath.LastIndexOf($NodeSeparatorCharacter))
154+
$parentNode = Get-XmlNode -XmlDocument $XmlDocument -NodePath $parentNodePath -NamespaceURI $NamespaceURI -NodeSeparatorCharacter $NodeSeparatorCharacter
155+
156+
if ($parentNode)
157+
{
158+
$parentNode.AppendChild($element) > $null
159+
}
160+
else
161+
{
162+
throw "$parentNodePath does not exist in the xml."
163+
}
164+
}
165+
}
166+
167+
function Test-Tag-Build ($nugetGitVersion, $buildMetaData, $fullSemVer) {
168+
if ([string]::IsNullOrEmpty($buildMetaData) -and $fullSemVer -eq $nugetGitVersion) {
169+
return $true
170+
}
171+
return $false
172+
}
173+
174+
function Test-Stable-Release ($stableVersion, $preReleaseVersion, $nugetGitVersion, $buildMetaData, $fullSemVer)
175+
{
176+
# This is unlikelly to heppen, but could happen if the tag creation didn't triggered the Package
177+
if ($stableVersion -ne $preReleaseVersion -and $preReleaseVersion -ne $nugetGitVersion) {
178+
return 1
179+
}
180+
if (Test-Tag-Build $nugetGitVersion $buildMetaData $fullSemVer) {
181+
return 2
182+
}
183+
return 0
184+
}
185+
186+
function Set-Forced-Git-Version ($version)
187+
{
188+
Write-Output "next-version: $version" > GitVersion.yml
189+
}
190+
191+
function Get-Prefix-Name ()
192+
{
193+
$branchName = Get-Current-Branch-Name
194+
195+
if ($branchName -ne "master") {
196+
return $branchName
197+
}
198+
return "beta"
199+
}
200+
201+
function Get-Next-Version-String ($PackageId)
202+
{
203+
$stableVersion = Get-Published-Package-Version ($PackageId)
204+
$preReleaseVersion = Get-Published-PreRelase-Package-Version ($PackageId)
205+
206+
$nugetGitVersion = Get-Git-Package-Version
207+
$buildMetaData = Get-Git-Build-MetaData
208+
$fullSemVer = Get-Git-Full-Sem-Ver
209+
210+
$prefix = Get-Prefix-Name
211+
$prefix = $prefix.Replace("-", "")
212+
$prefix = $prefix.Replace("_", "")
213+
$prefix = $prefix.Replace(".", "")
214+
$nextVersion = ""
215+
216+
$stable = Test-Stable-Release $stableVersion $preReleaseVersion $nugetGitVersion $buildMetaData $fullSemVer
217+
if ($stable -eq 1){
218+
$nextVersion = $preReleaseVersion
219+
Set-Forced-Git-Version $nextVersion
220+
} elseif ($stable -eq 2) {
221+
$nextVersion = $nugetGitVersion
222+
} else {
223+
$nextVersion = "$($nugetGitVersion)-$($prefix)-build$($buildMetaData)"
224+
}
225+
return $nextVersion
226+
}
227+
228+
function Test-Version-Stable-Release ($version)
229+
{
230+
$count = $version.Split("-").Length
231+
if ($count -eq 3) {
232+
return $false
233+
}
234+
return $true
235+
}
236+
237+
function Test-Package-Already-Published ($PackageId, $nextVersion)
238+
{
239+
if (Test-Version-Stable-Release $nextVersion) {
240+
$publishedVersion = Get-Published-Package $PackageId
241+
if ($publishedVersion -eq $nextVersion) {
242+
return $true
243+
}
244+
return $false
245+
}
246+
247+
$buildMetaData = Get-Git-Build-MetaData
248+
$currentVersion = $nextVersion.Split('-')[0]
249+
250+
[int]$currentBuild = [Convert]::ToInt32($buildMetaData, 10)
251+
$currentPrefix = Get-Prefix-Name
252+
253+
$version = Get-Published-PreRelase-Package $PackageId
254+
#if the latest pre-relese returned is a stable release
255+
if (Test-Version-Stable-Release $version) {
256+
return $false
257+
}
258+
259+
$publishedVersion = $version.Split('-')[0]
260+
$publishedPrefix = $version.Split('-')[1]
261+
$build = $version.Split('-')[2]
262+
$build = $build.Replace("build", "")
263+
[int]$publishedBuild = [Convert]::ToInt32($build, 10)
264+
265+
if ($currentVersion -ne $publishedVersion) {
266+
return $false
267+
}
268+
if ($currentPrefix -ne $publishedPrefix) {
269+
return $false
270+
}
271+
if ($currentBuild -gt $publishedPrefix) {
272+
return $false
273+
}
274+
return $true
275+
}
276+
277+
function Test-Git-Detached ()
278+
{
279+
$output = [string](git branch | head -1)
280+
$detached = $output.Contains("detached")
281+
return $detached
282+
}
283+
284+
function Get-Git-Current-Tag
285+
{
286+
return [string](git describe --tags | head -1)
287+
}
288+
289+
# GitVersion only works in attached branches, if we try to build a tag from the commit hash gitversion will fail
290+
# so we ensure we are always attached to a branch
291+
function Update-Ensure-Git-Not-Detached ()
292+
{
293+
$detached = Test-Git-Detached
294+
if (!$detached) {
295+
return
296+
}
297+
$currentTag = Get-Git-Current-Tag
298+
& git checkout -B $currentTag
299+
# We are using -B because maybe the branch alrady exist
300+
}

CYRTextView.nuspec

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<metadata>
4+
<id>Codefoco.CYRTextView</id>
5+
<version>0.1.0-beta-build0</version>
6+
<authors>Codefoco</authors>
7+
<owners>Vinicius Jarina</owners>
8+
<licenseUrl>https://github.com/codefoco/CYRTextView/blob/master/LICENSE</licenseUrl>
9+
<projectUrl>https://github.com/codefoco/CYRTextView</projectUrl>
10+
<iconUrl>https://raw.githubusercontent.com/codefoco/CYRTextView/master/CYRTextView.png</iconUrl>
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<description>
13+
Xamarin.iOS Binding for CYRTextView
14+
</description>
15+
<releaseNotes>Release: 9621ffb</releaseNotes>
16+
<copyright>Copyright © Vinicius Jarina 2019</copyright>
17+
<tags>CYRTextView</tags>
18+
</metadata>
19+
<files>
20+
<file src="lib\Release\CYRTextView.dll" target="lib\xamarinios" />
21+
<file src="LICENSE" target="LICENSE" />
22+
</files>
23+
</package>

CYRTextView.png

13.2 KB
Loading

CYRTextView.sln

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CYRTextView", "build\XamariniOS\CYRTextView.csproj", "{BC890E8A-DAE1-4480-8845-A8C446E8A448}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CYRTextViewExample", "CYRTextViewExample\CYRTextViewExample.csproj", "{CCD532C0-24B1-4433-917F-366EC5E7C95F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
Debug|iPhoneSimulator = Debug|iPhoneSimulator
13+
Release|iPhone = Release|iPhone
14+
Release|iPhoneSimulator = Release|iPhoneSimulator
15+
Debug|iPhone = Debug|iPhone
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
23+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
24+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Release|iPhone.ActiveCfg = Release|Any CPU
25+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Release|iPhone.Build.0 = Release|Any CPU
26+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
27+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
28+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Debug|iPhone.ActiveCfg = Debug|Any CPU
29+
{BC890E8A-DAE1-4480-8845-A8C446E8A448}.Debug|iPhone.Build.0 = Debug|Any CPU
30+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
31+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
32+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
33+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
34+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
35+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
36+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Release|iPhone.ActiveCfg = Release|iPhone
37+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Release|iPhone.Build.0 = Release|iPhone
38+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
39+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
40+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Debug|iPhone.ActiveCfg = Debug|iPhone
41+
{CCD532C0-24B1-4433-917F-366EC5E7C95F}.Debug|iPhone.Build.0 = Debug|iPhone
42+
EndGlobalSection
43+
EndGlobal

0 commit comments

Comments
 (0)