Use Azure Pipelines

This commit is contained in:
Pig Fang 2019-08-01 11:44:59 +08:00
parent 744964424e
commit 07d08c7ad8
4 changed files with 51 additions and 61 deletions

View File

@ -1,26 +0,0 @@
language: php
php: 7.3
install: true
script: true
before_deploy:
- nvm install 10
- node -v
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.15.2
- export PATH="$HOME/.yarn/bin:$PATH"
- RELEASE_TAG=$TRAVIS_TAG ./scripts/release.sh
deploy:
provider: releases
api_key: $GITHUB_TOKEN
file: blessing-skin-server-$TRAVIS_TAG.zip
name: $TRAVIS_TAG
skip_cleanup: true
on:
tags: true
after_deploy:
- curl -s -o github-release.tar.bz2 -L https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2
- tar -xf github-release.tar.bz2
- ./bin/linux/amd64/github-release -v edit -u bs-community -r blessing-skin-server -t $TRAVIS_TAG -d "$(cat resources/misc/changelogs/en/$TRAVIS_TAG.md && echo -e '\n---\n' && cat resources/misc/changelogs/zh_CN/$TRAVIS_TAG.md)"

12
azure-pipelines.yml Normal file
View File

@ -0,0 +1,12 @@
trigger:
- master
- dev
pr: none
pool:
vmImage: 'ubuntu-latest'
steps:
- pwsh: ./scripts/release.ps1
displayName: 'Release'

39
scripts/release.ps1 Normal file
View File

@ -0,0 +1,39 @@
$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_2.json' | ConvertFrom-Json
$last = $manifest.latest
$current = (Get-Content package.json | ConvertFrom-Json).version
if ($last -eq $current) {
exit
}
Install-Module PSGitHub -Force
# Install dependencies
composer install --no-dev
Remove-Item vendor/bin -Recurse -Force
yarn
yarn build
$zip = "blessing-skin-server-$current.zip"
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
New-Item dist -ItemType Directory
Set-Location dist
Copy-Item -Path "../$zip" -Destination $zip
$manifest.latest = $current
$manifest.url = $manifest.url.Replace($last, $current)
ConvertTo-Json $manifest | Out-File -FilePath update_2.json
$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
$githubToken = $env:GITHUB_TOKEN | ConvertTo-SecureString -AsPlainText -Force
$enChangelog = Get-Content "../resources/misc/changelogs/en/$current.md"
$changelog = "`n---`n" + $enChangelog
New-GitHubRelease -Token $githubToken -Owner 'bs-community' -Repository 'blessing-skin-server' -TagName $current -ReleaseNote $changelog

View File

@ -1,35 +0,0 @@
#!/bin/bash
set -e
composer install --no-dev
rm -rf vendor/bin
yarn
yarn build
zip -9 -r blessing-skin-server-$RELEASE_TAG.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
mkdir dist
cd dist
cp ../blessing-skin-server-$RELEASE_TAG.zip blessing-skin-server-$RELEASE_TAG.zip
echo "{\"spec\":2,\"php\":\"7.1.8\",\"latest\":\"$RELEASE_TAG\",\"url\":\"https://dev.azure.com/blessing-skin/51010f6d-9f99-40f1-a262-0a67f788df32/_apis/git/repositories/a9ff8df7-6dc3-4ff8-bb22-4871d3a43936/Items?path=%2Fblessing-skin-server-$RELEASE_TAG.zip\"}" > update_2.json
git init
git add .
git commit -m "Publish"
git remote add origin https://blessing-skin:$AZURE_TOKEN@dev.azure.com/blessing-skin/Blessing%20Skin%20Server/_git/Blessing%20Skin%20Server
git push -f origin master
cd ..