Skip to content

Commit

Permalink
chore(build): semantic-release now used for deployments
Browse files Browse the repository at this point in the history
Using semantic-release for deployments based on conventional commits and Chocolatey deployments & GitHub Releases release notes
  • Loading branch information
activescott committed Oct 11, 2020
1 parent ec654ef commit affc1c7
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 24 deletions.
41 changes: 17 additions & 24 deletions appveyor.yml
@@ -1,6 +1,14 @@
# see http://www.appveyor.com/docs/appveyor-yml
# environment info: https://www.appveyor.com/docs/windows-images-software/#visual-studio-2015
image: Visual Studio 2015

environment:
# from https://github.com/settings/tokens encrypted at https://ci.appveyor.com/tools/encrypt
GH_TOKEN:
secure: K10jiRl71WzhwEL/OJsAFS+ooQB0dAVBe0NXwnuV3h6mDvZlIM6GFt2WgcnLU8kT
CHOCO_KEY:
secure: /Ie5xuB5GTDwElbSN0V+mCyYtYNhfQJRjdoWFUsNsVJW9bq32LNzSlI1cn4OUxIu

#---------------------------------#
# build configuration #
#---------------------------------#
Expand All @@ -10,7 +18,6 @@ build_script:
#---------------------------------#
# tests configuration #
#---------------------------------#

test:
assemblies:
- .\src\.deploy\LessMsi.Tests.dll
Expand All @@ -19,27 +26,13 @@ artifacts:
- path: 'src\.deploy\chocolateypackage\*.nupkg'
- path: 'src\.deploy\*.zip'

deploy:
- provider: GitHub # See https://www.appveyor.com/docs/deployment/github/
release: v$(APPVEYOR_BUILD_VERSION)
description: 'Appveyor deployed v$(APPVEYOR_BUILD_VERSION)'
auth_token:
secure: oWfqfhnk8xvX/xrkBmz3jue7DCFM9VzP9MHzvX7T3qBzEIrAuDaue6bKTsVekpNs # encrypted token from https://github.com/settings/tokens
artifact: /(.*\.nupkg)|(.*\.zip)/ # upload NuGet & zip files to release assets
draft: false
prerelease: false
on:
branch: master # only deploy on master
appveyor_repo_tag: true # only deploy when there is a tag pushed
appveyor_repo_tag_name: publish # only deploy when tag == "publish"
# NOTE: Deployments, before_deploy and after_deploy scripts are disabled by default on Pull Requests.
# https://www.appveyor.com/docs/deployment/#pull-requests
deploy_script:
# install (select) node 10 per semantic-release requirements: https://www.appveyor.com/docs/lang/nodejs-iojs/#selecting-nodejs-or-iojs-version
- ps: Install-Product node 10
# install semantic-release and reequirement plugins:
- cmd: npm i semantic-release@17 @semantic-release/exec@5
# run semantic-release with config:
- cmd: node_modules\.bin\semantic-release

- provider: NuGet # See https://www.appveyor.com/docs/deployment/nuget/
# For Chocolatey setup for NuGet see https://blog.gripdev.xyz/2015/04/08/appveyor-github-and-chocolatey-automatically-build-your-project-and-publish-updates-it-to-chocolatey/
server: https://push.chocolatey.org/
api_key:
secure: /Ie5xuB5GTDwElbSN0V+mCyYtYNhfQJRjdoWFUsNsVJW9bq32LNzSlI1cn4OUxIu
artifact: /.*\.nupkg/
on:
branch: master # only deploy on master
appveyor_repo_tag: true # only deploy when there is a tag pushed
appveyor_repo_tag_name: publish # only deploy when tag == "publish"
21 changes: 21 additions & 0 deletions release.config.js
@@ -0,0 +1,21 @@
module.exports = {
branches: [
"master"
],
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/exec", {
"verifyConditionsCmd": "src\\.build\\semantic-release-verify.cmd",
"prepareCmd": "src\\.build\\semantic-release-prepare.cmd ${nextRelease.version}",
"publishCmd": "src\\.build\\semantic-release-publish.cmd ${nextRelease.version}",
}],
// github config docs: https://github.com/semantic-release/github
["@semantic-release/github", {
"assets": [
{"path": "src\\.deploy\\chocolateypackage\\*.nupkg", "label": "NuGet distribution"},
{"path": "src\\.deploy\\*.zip", "label": "ZIP distribution"}
]
}],
]
};
19 changes: 19 additions & 0 deletions src/.build/semantic-release-prepare.cmd
@@ -0,0 +1,19 @@
@echo off

REM This script called by semantic-release to "prepare" the build.
REM Since semantic-release determines the version number based on commits, we rebuild it with the new version number:

IF [%1]==[] (
ECHO ERROR: Must supply build version as first parameter to this bat file! 1>&2
EXIT 1
)
set _BUILD_VERSION=%1

ECHO Running msbuild...

msbuild .\src\.build\lessmsi.msbuild /p:TheVersion=%_BUILD_VERSION% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"

REM NOTE: ECHO does not clear/set errorlevel https://ss64.com/nt/errorlevel.htmls
ECHO Running msbuild complete.

EXIT %ERRORLEVEL%
21 changes: 21 additions & 0 deletions src/.build/semantic-release-publish.cmd
@@ -0,0 +1,21 @@
@echo off

REM note: Nodejs configured and semantic-release insalled in appveyor.yml
REM This script is called /by/ semantic-release to publish to chocolatey

set THIS_DIR=%~dp0

IF [%1]==[] (
ECHO ERROR: Must supply build version as first parameter to this bat file! 1>&2
EXIT 1
)
set _BUILD_VERSION=%1

ECHO Running choco push...

choco push "%THIS_DIR%..\.deploy\chocolateypackage\lessmsi.%_BUILD_VERSION%.nupkg" --api-key=%CHOCO_KEY%

REM NOTE: ECHO does not clear/set errorlevel https://ss64.com/nt/errorlevel.htmls
ECHO Running choco push complete. Errorlevel was %ERRORLEVEL%

EXIT %ERRORLEVEL%
9 changes: 9 additions & 0 deletions src/.build/semantic-release-verify.cmd
@@ -0,0 +1,9 @@
@echo off

IF DEFINED CHOCO_KEY (
echo "CHOCO_KEY is defined"
EXIT 0
) ELSE (
echo "CHOCO_KEY is NOT defined" 1>&2
EXIT 1
)

0 comments on commit affc1c7

Please sign in to comment.