Skip to content

Commit e72c741

Browse files
author
fadhly.permata
committed
Update project metadata and add build automation script
- Updates package metadata including name, version, and description to better reflect project purpose - Adds README and LICENSE files to the package distribution - Includes a new PowerShell script for automated building, versioning, and publishing to NuGet - Modifies .gitignore to better handle build artifacts and solution files
1 parent 72b5097 commit e72c741

File tree

3 files changed

+110
-11
lines changed

3 files changed

+110
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
JQL.Net.sln
12
bin
23
bin/*
34
obj
45
obj/*
5-
JQL.Net.sln
6+
nupkg/*

JQL.Net.csproj

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<TargetFramework>net8.0</TargetFramework>
5-
<PackageId>NamaLibrary</PackageId>
6-
<Version>1.0.0</Version>
7-
<Authors>Fadhly</Authors>
8-
<Company>NamaPerusahaan</Company>
9-
<Description>Library untuk ...</Description>
4+
<PackageId>JQL.Net</PackageId>
5+
<Version>1.0.3</Version>
6+
<Authors>Fadhly Permata</Authors>
7+
<Company>Fadhly Permata</Company>
8+
<Description>JQL.Net: A lightweight SQL-inspired engine to query, join, and aggregate JSON in .NET. No database? No problem!</Description>
9+
<PackageReadmeFile>README.md</PackageReadmeFile>
10+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1011
<ImplicitUsings>enable</ImplicitUsings>
1112
<Nullable>enable</Nullable>
13+
<NoWarn>$(NoWarn);S1192</NoWarn>
1214
</PropertyGroup>
13-
1415
<ItemGroup>
1516
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
1617
</ItemGroup>
17-
18-
<NoWarn>$(NoWarn);S1192</NoWarn>
19-
</Project>
18+
<ItemGroup>
19+
<None Include="README.md" Pack="true" PackagePath="\" />
20+
<None Include="LICENSE" Pack="true" PackagePath="\" />
21+
</ItemGroup>
22+
</Project>

build-and-push.ps1

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# --- Magic Start ---
2+
Clear-Host
3+
Write-Host "--- Menyiapkan peluncuran project C# kamu ke awan! ---`n" -ForegroundColor Cyan -BackgroundColor DarkBlue
4+
5+
# 1. Cari file .csproj di folder saat ini
6+
$projectFiles = Get-ChildItem -Filter *.csproj
7+
8+
if ($projectFiles.Count -eq 0) {
9+
Write-Host "!!! Aduh! Gak ketemu file .csproj di sini. Coba cek lagi ya! !!!" -ForegroundColor Red
10+
exit 1
11+
}
12+
13+
# Jika ada lebih dari satu project, minta user pilih
14+
if ($projectFiles.Count -gt 1) {
15+
Write-Host "Wah, banyak project keren di sini! Pilih yang mana nih?:" -ForegroundColor Yellow
16+
for ($i = 0; $i -lt $projectFiles.Count; $i++) {
17+
Write-Host " [$i] : $($projectFiles[$i].Name)" -ForegroundColor Gray
18+
}
19+
$choice = Read-Host "Ketik nomor pilihannya (default 0)"
20+
if ([string]::IsNullOrWhiteSpace($choice)) { $choice = 0 }
21+
$selectedProject = $projectFiles[$choice].FullName
22+
} else {
23+
$selectedProject = $projectFiles[0].FullName
24+
}
25+
26+
$projectName = [System.IO.Path]::GetFileName($selectedProject)
27+
Write-Host "`nProject Terpilih: " -NoNewline; Write-Host "$projectName" -ForegroundColor Green -BackgroundColor Black
28+
29+
# 2. Minta input versi dari user
30+
Write-Host "`nVersi berapa yang mau kita rilis hari ini?" -ForegroundColor Yellow
31+
$newVersion = Read-Host "Masukkan versi (misal: 1.0.0)"
32+
if ([string]::IsNullOrWhiteSpace($newVersion)) {
33+
Write-Host "Versi gak boleh kosong ya!" -ForegroundColor Red
34+
exit 1
35+
}
36+
37+
# 3. Update Versi di file XML .csproj 🛠️
38+
Write-Host "Sedang mengukir versi $newVersion ke dalam $projectName..." -ForegroundColor DarkGray
39+
[xml]$xml = Get-Content $selectedProject
40+
$propertyGroup = $xml.Project.PropertyGroup | Select-Object -First 1
41+
42+
if ($null -eq $propertyGroup.Version) {
43+
$versionNode = $xml.CreateElement("Version")
44+
$versionNode.InnerText = [string]$newVersion
45+
$propertyGroup.AppendChild($versionNode)
46+
} else {
47+
# Perbaikan di sini: Tambahkan .#text atau .InnerText
48+
$propertyGroup.Version = [string]$newVersion
49+
}
50+
$xml.Save($selectedProject)
51+
Write-Host "Sip! Versi berhasil diupdate." -ForegroundColor Green
52+
53+
# 4. Proses Build & Pack
54+
Write-Host "`nSedang membangun (Build) project... Tunggu bentar ya!" -ForegroundColor Cyan
55+
dotnet build $selectedProject --configuration Release /nologo
56+
if ($LASTEXITCODE -ne 0) {
57+
Write-Host "Build-nya error! Cek kodenya lagi ya." -ForegroundColor Red
58+
exit 1
59+
}
60+
61+
Write-Host "Membungkus paket NuGet (Pack)..." -ForegroundColor Magenta
62+
$outputDir = "./nupkg"
63+
if (!(Test-Path $outputDir)) { New-Item -ItemType Directory -Path $outputDir | Out-Null }
64+
65+
dotnet pack $selectedProject --configuration Release --output $outputDir --no-build /p:PackageVersion=$newVersion /nologo
66+
67+
# 5. Konfirmasi Push ke NuGet
68+
Write-Host "`nSiap untuk terbang ke NuGet?" -ForegroundColor Yellow
69+
$confirmation = Read-Host "Kirim sekarang? (y/n)"
70+
if ($confirmation -eq 'y') {
71+
if ($null -eq $env:NUGET_API_KEY) {
72+
Write-Host "Variabel `$env:NUGET_API_KEY` belum ada di sistem kamu." -ForegroundColor Red
73+
exit 1
74+
}
75+
76+
$nupkgFile = Get-ChildItem "$outputDir/*$newVersion.nupkg" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
77+
78+
if ($null -eq $nupkgFile) {
79+
Write-Host "File paketnya nggak ketemu!" -ForegroundColor Red
80+
exit 1
81+
}
82+
83+
Write-Host "Mengirim paket ke NuGet..." -ForegroundColor DarkCyan
84+
dotnet nuget push $nupkgFile.FullName --api-key $env:NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" --skip-duplicate
85+
86+
if ($LASTEXITCODE -eq 0) {
87+
Write-Host "`nHOREEE! Paket kamu sudah mendarat di NuGet!" -ForegroundColor Green -BackgroundColor Black
88+
} else {
89+
Write-Host "`nProses pengiriman gagal." -ForegroundColor Red
90+
}
91+
} else {
92+
Write-Host "Paket disimpan di folder ./nupkg." -ForegroundColor Yellow
93+
}
94+
95+
Write-Host "`nHappy Coding and Have a Great Day!`n" -ForegroundColor White -BackgroundColor DarkMagenta

0 commit comments

Comments
 (0)