This repository was archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
feat: Release and pre-release pipelines with publish script #224
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c06853b
feat: Release and pre-release pipelines with publish script
tbarlow12 b56cf53
feat: Add version script and trigger on commits to dev or master
tbarlow12 da75799
feat: Update version script to work with GitHub
adf67f6
fix: Respond to PR feedback
tbarlow12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
This file contains hidden or 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 hidden or 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 hidden or 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"} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 Groupsin AzDO and referencing them here, so that you don't have to add the variables after pipeline creation