This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Release and pre-release pipelines with publish script (#224)
Pipelines for release and pre-release on merges to master and dev respectively. Dev branch will release a beta to NPM and Master will release a patch to NPM Resolves [AB#588]
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
trigger: | ||
branches: | ||
include: | ||
- dev | ||
pr: none | ||
|
||
variables: | ||
- group: npm-release-credentials | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
steps: | ||
- task: NodeTool@0 | ||
displayName: 'Use Node 10.x' | ||
inputs: | ||
versionSpec: 10.x | ||
|
||
- checkout: self | ||
clean: true | ||
persistCredentials: true | ||
fetchDepth: 1 | ||
|
||
- task: Bash@3 | ||
name: BumpNpmVersion | ||
displayName: Bump NPM Prerelease Version | ||
inputs: | ||
targetType: filePath | ||
filePath: ./scripts/version.sh | ||
arguments: 'serverless/serverless-azure-functions' | ||
env: | ||
NPM_TOKEN: $(NPM_TOKEN) | ||
GITHUB_ACCESS_TOKEN: $(GITHUB_ACCESS_TOKEN) | ||
SOURCE_BRANCH: $(Build.SourceBranch) | ||
|
||
- task: Bash@3 | ||
displayName: 'Publish serverless-azure-functions to NPM' | ||
inputs: | ||
targetType: filePath | ||
filePath: ./scripts/publish.sh | ||
arguments: 'prerelease' | ||
env: | ||
NPM_TOKEN: $(NPM_TOKEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
trigger: none | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
variables: | ||
- group: npm-release-credentials | ||
|
||
steps: | ||
- task: NodeTool@0 | ||
displayName: 'Use Node 10.x' | ||
inputs: | ||
versionSpec: 10.x | ||
|
||
- checkout: self | ||
clean: true | ||
persistCredentials: true | ||
fetchDepth: 1 | ||
|
||
- task: Bash@3 | ||
displayName: 'Publish serverless-azure-functions to NPM' | ||
inputs: | ||
targetType: filePath | ||
filePath: ./scripts/publish.sh | ||
env: | ||
NPM_TOKEN: $(NPM_TOKEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
$(pwd)/scripts/build.sh | ||
|
||
# NOTE: auth is taken care of via NPM_TOKEN env variable | ||
if [ -z "$1" ]; then | ||
echo "Publishing 'latest' to NPM..."; | ||
npm publish | ||
else | ||
echo "Publishing 'prerelease' to NPM..."; | ||
npm publish --tag=beta | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Environment Variables Needed: | ||
# SOURCE_BRANCH | ||
# GITHUB_ACCESS_TOKEN | ||
|
||
PACKAGE_NAME=$1 | ||
NPM_RELEASE_TYPE=${2-"prerelease"} | ||
|
||
# Get full branch name excluding refs/head from the env var SOURCE_BRANCH | ||
SOURCE_BRANCH_NAME=${SOURCE_BRANCH/refs\/heads\/} | ||
|
||
# Configure git to commit as SLS Azure Functions Service Account | ||
echo "Configuring git to use service account..." | ||
git config --local user.email "Serverless Azure Functions" | ||
git config --local user.name "sls-az@microsoft.com" | ||
|
||
git pull origin ${SOURCE_BRANCH_NAME} | ||
git checkout ${SOURCE_BRANCH_NAME} | ||
echo "Checked out branch: ${SOURCE_BRANCH_NAME}" | ||
|
||
NPM_VERSION=`npm version ${NPM_RELEASE_TYPE} -m "release: Update ${NPM_RELEASE_TYPE} version to %s ***NO_CI***"` | ||
echo "Set NPM version to: ${NPM_VERSION}" | ||
|
||
SHA=`git rev-parse HEAD` | ||
|
||
git remote add authOrigin https://${GITHUB_ACCESS_TOKEN}@github.com/serverless/serverless-azure-functions.git | ||
git push authOrigin ${SOURCE_BRANCH_NAME} --tags | ||
|
||
echo "Pushed new tag: ${PACKAGE_NAME}-${NPM_VERSION} @ SHA: ${SHA:0:8}" |