blessing-skin-server/scripts/release.ps1

60 lines
2.5 KiB
PowerShell
Raw Normal View History

2019-09-13 09:52:34 +08:00
$manifest = Invoke-WebRequest 'https://dev.azure.com/blessing-skin/51010f6d-9f99-40f1-a262-0a67f788df32/_apis/git/repositories/a9ff8df7-6dc3-4ff8-bb22-4871d3a43936/Items?path=%2Fupdate_preview.json' | ConvertFrom-Json
2019-08-01 11:44:59 +08:00
$last = $manifest.latest
$current = (Get-Content package.json | ConvertFrom-Json).version
2019-08-01 14:47:48 +08:00
Write-Host "Latest version: $last. Current: $current" -ForegroundColor Blue
2019-08-01 11:44:59 +08:00
if ($last -eq $current) {
2019-08-01 14:47:48 +08:00
Write-Host "Latest version is $last. No need to publish." -ForegroundColor Green -BackgroundColor DarkMagenta
2019-08-01 11:44:59 +08:00
exit
}
Install-Module PSGitHub -Force
2019-08-01 14:47:48 +08:00
Write-Host "'PSGitHub' has been installed." -ForegroundColor Green
2019-08-01 11:44:59 +08:00
# Install dependencies
2019-09-13 09:36:11 +08:00
composer install --no-dev --prefer-dist --no-suggest --no-progress
2019-08-01 11:44:59 +08:00
Remove-Item vendor/bin -Recurse -Force
yarn
2019-08-01 14:47:48 +08:00
Write-Host "Dependencies have been installed." -ForegroundColor Green
2019-11-27 15:24:36 +08:00
./scripts/build.ps1
2019-08-01 11:44:59 +08:00
$zip = "blessing-skin-server-$current.zip"
2019-12-07 00:02:09 +08:00
zip -9 -r $zip app bootstrap config database plugins public resources/lang resources/views resources/misc routes storage vendor .env.example artisan LICENSE README.md README_EN.md index.html
2019-08-01 14:47:48 +08:00
Write-Host "Zip archive is created." -ForegroundColor Green
2019-08-01 11:44:59 +08:00
New-Item dist -ItemType Directory
Set-Location dist
Copy-Item -Path "../$zip" -Destination $zip
$manifest.latest = $current
$manifest.url = $manifest.url.Replace($last, $current)
2019-09-12 22:54:51 +08:00
$manifest.php = '7.2.0'
ConvertTo-Json $manifest | Out-File -FilePath update_preview.json
2019-08-01 14:47:48 +08:00
Write-Host "Update source is prepared." -ForegroundColor Green
2019-08-01 11:44:59 +08:00
$azureToken = $env:AZURE_TOKEN
git config --global user.email 'g-plane@hotmail.com'
git config --global user.name 'Pig Fang'
git init
git add .
git commit -m "Publish"
git push -f "https://anything:$azureToken@dev.azure.com/blessing-skin/Blessing%20Skin%20Server/_git/Blessing%20Skin%20Server" master
2019-08-01 14:47:48 +08:00
Write-Host "Update source is pushed to Azure Repos." -ForegroundColor Green
2019-08-01 11:44:59 +08:00
$githubToken = $env:GITHUB_TOKEN | ConvertTo-SecureString -AsPlainText -Force
2019-09-13 09:36:11 +08:00
$changelogPath = "../resources/misc/changelogs/en/$current.md"
if (Test-Path $changelogPath) {
$enChangelog = Get-Content $changelogPath
$changelog = "`n---`n" + $enChangelog
} else {
$changelog = ''
}
2019-09-12 22:54:51 +08:00
$release = New-GitHubRelease -Token $githubToken -Owner 'bs-community' -Repository 'blessing-skin-server' -TagName $current -ReleaseNote $changelog -PreRelease
2019-08-01 14:38:26 +08:00
try {
New-GitHubReleaseAsset -Token $githubToken -Owner 'bs-community' -Repository 'blessing-skin-server' -ReleaseId $release.Id -Path $zip
} catch {
# Do nothing.
}
2019-08-01 14:47:48 +08:00
Write-Host "New version $current is published!" -ForegroundColor Green -BackgroundColor DarkMagenta