Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions pipelines/publish-prerelease.yml
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend creating Variable Groups in AzDO and referencing them here, so that you don't have to add the variables after pipeline creation

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

26 changes: 26 additions & 0 deletions pipelines/publish-release.yml
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)
13 changes: 13 additions & 0 deletions scripts/publish.sh
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
31 changes: 31 additions & 0 deletions scripts/version.sh
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"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we will just have prerelease release types?


# 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}"