Fix release-related issue

This commit is contained in:
Pig Fang 2019-07-05 18:04:30 +08:00
parent 53069d53e3
commit b28c8a8bf1
5 changed files with 53 additions and 47 deletions

View File

@ -5,78 +5,84 @@ pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
variables: variables:
RELEASE_TAG: $(Build.SourceBranchName) RELEASE_TAG: '4.3.1'
steps: steps:
- script: | - script: |
sudo update-alternatives --set php /usr/bin/php7.3 (git log -1 --pretty="%s" | grep -P 'Bump version to \d+\.\d+\.\d+') > /dev/null 2>&1
php -version if [ $? -eq 0 ]
then
sudo update-alternatives --set php /usr/bin/php7.3
php -version
fi
displayName: 'Use PHP version 7.3' displayName: 'Use PHP version 7.3'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- script: | - script: |
composer install --no-interaction --prefer-dist --no-dev (git log -1 --pretty="%s" | grep -P 'Bump version to \d+\.\d+\.\d+') > /dev/null 2>&1
rm -rf vendor/bin if [ $? -eq 0 ]
then
composer install --no-interaction --prefer-dist --no-dev
rm -rf vendor/bin
fi
displayName: 'composer install' displayName: 'composer install'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- task: NodeTool@0 - task: NodeTool@0
inputs: inputs:
versionSpec: '10.x' versionSpec: '10.x'
displayName: 'Install Node.js' displayName: 'Install Node.js'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- script: | - script: |
yarn (git log -1 --pretty="%s" | grep -P 'Bump version to \d+\.\d+\.\d+') > /dev/null 2>&1
yarn build if [ $? -eq 0 ]
then
yarn
yarn build
fi
displayName: 'Build front end' displayName: 'Build front end'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- script: | - script: |
zip -9 -r blessing-skin-server-$RELEASE_TAG.zip \ (git log -1 --pretty="%s" | grep -P 'Bump version to \d+\.\d+\.\d+') > /dev/null 2>&1
app \ if [ $? -eq 0 ]
bootstrap \ then
config \ composer install --no-interaction --prefer-dist --no-dev
database \ rm -rf vendor/bin
plugins \ fi
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
cd ..
displayName: 'Archive files' displayName: 'Archive files'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- script: | - script: |
cd dist (git log -1 --pretty="%s" | grep -P 'Bump version to \d+\.\d+\.\d+') > /dev/null 2>&1
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 if [ $? -eq 0 ]
git init then
git add . zip -9 -r blessing-skin-server-$RELEASE_TAG.zip \
git commit -m "Publish" app \
git remote add origin https://blessing-skin:$AZURE_TOKEN@dev.azure.com/blessing-skin/Blessing%20Skin%20Server/_git/Blessing%20Skin%20Server bootstrap \
git push -f origin master config \
cd .. 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
cd ..
fi
displayName: 'Create update source info' displayName: 'Create update source info'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- script: | - script: |
(cat resources/misc/changelogs/zh_CN/$RELEASE_TAG.md && echo "\n---\n" && cat resources/misc/changelogs/en/$RELEASE_TAG.md) > changelog.md (cat resources/misc/changelogs/zh_CN/$RELEASE_TAG.md && echo "\n---\n" && cat resources/misc/changelogs/en/$RELEASE_TAG.md) > changelog.md
displayName: 'Generate changelog' displayName: 'Generate changelog'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- task: GitHubRelease@0 - task: GitHubRelease@0
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
displayName: 'Create GitHub Release' displayName: 'Create GitHub Release'
inputs: inputs:
gitHubConnection: g-plane gitHubConnection: g-plane
@ -86,5 +92,5 @@ steps:
tagSource: 'auto' tagSource: 'auto'
releaseNotesSource: 'file' releaseNotesSource: 'file'
releaseNotesFile: 'changelog.md' releaseNotesFile: 'changelog.md'
assets: 'dist/blessing-skin-server-$(Build.SourceBranchName).zip' assets: 'dist/blessing-skin-server-$(RELEASE_TAG).zip'
addChangeLog: false addChangeLog: false

View File

@ -20,7 +20,7 @@ function git(args: readonly string[]) {
} }
(async () => { (async () => {
const files = ['./config/app.php', './package.json'] const files = ['./config/app.php', './package.json', './azure-pipelines.yml']
await Promise.all(files.map(saveVersion)) await Promise.all(files.map(saveVersion))
await git(['add'].concat(files)) await git(['add'].concat(files))
await git(['commit', '-m', `Bump version to ${next}`]) await git(['commit', '-m', `Bump version to ${next}`])