Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit a4f9f65

Browse files
authored
chore: pipeline for preview release (queue manually) (#879)
1 parent 15881b7 commit a4f9f65

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#job-templates-with-parameters
2+
jobs:
3+
- job: ${{ parameters.name }}
4+
pool: ${{ parameters.pool }}
5+
timeoutInMinutes: 15 # how long to run the job before automatically cancelling
6+
steps:
7+
- task: NodeTool@0
8+
displayName: 'Use Node 10.x'
9+
inputs:
10+
versionSpec: 10.x
11+
12+
- bash: |
13+
set -ex
14+
15+
# clean install
16+
npm ci
17+
npm run release-ci
18+
19+
OS=${{ parameters.os }}
20+
ARTIFACT_NAME=${{ parameters.artifact }}
21+
22+
mkdir -p ${OS}
23+
cp releases/${ARTIFACT_NAME} ${OS}/
24+
25+
displayName: Build
26+
27+
- publish: $(System.DefaultWorkingDirectory)/${{ parameters.os }}
28+
artifact: ${{ parameters.os }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
parameters:
2+
GitHubConnection: '' # defaults for any parameters that aren't specified
3+
repositoryName: ''
4+
releaseNotesSource: input
5+
addChangeLog: false
6+
isPreRelease: true
7+
isDraft: true
8+
9+
jobs:
10+
- job: Create_Github_Release
11+
timeoutInMinutes: 30 # timeout on job if deploy is not completed in 30 minutes
12+
pool:
13+
vmImage: ubuntu-16.04
14+
steps:
15+
- checkout: none # we already have the artifacts built, don't need the code
16+
17+
- download: current
18+
19+
- task: GitHubRelease@0
20+
displayName: 'GitHub release (create)'
21+
inputs:
22+
gitHubConnection: ${{ parameters.GitHubConnection }}
23+
repositoryName: ${{ parameters.repositoryName }}
24+
releaseNotesSource: ${{ parameters.releaseNotesSource }}
25+
target: $(Build.SourceBranch)
26+
assets: |
27+
../linux/*
28+
../windows/*
29+
../mac/*
30+
addChangeLog: ${{ parameters.addChangeLog }}
31+
isDraft: true # for testing, change to true when ready to merge
32+
isPreRelease: ${{ parameters.isPrelease }}

preview-release-pipeline.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
trigger: none # manual queue only when we're ready to release
2+
pr: none # disable CI build for PR
3+
4+
stages:
5+
- stage: version_bump_commit
6+
jobs:
7+
- job: "version_bump"
8+
9+
variables:
10+
- group: GitHub-Deploy-Creds
11+
12+
timeoutInMinutes: 30 # timeout on job if deploy is not completed in 30 minutes
13+
cancelTimeoutInMinutes: 1 # time limit to wait for job to cancel
14+
15+
pool:
16+
vmImage: macOS-10.13 # ssh key was generated on a Mac so using the same type of OS here
17+
18+
steps:
19+
- task: NodeTool@0
20+
inputs:
21+
versionSpec: 10.x
22+
displayName: 'Install Node.js'
23+
24+
# Download secure file
25+
# Download a secure file to the agent machine
26+
- task: DownloadSecureFile@1
27+
# name: sshKey # The name with which to reference the secure file's path on the agent, like $(mySecureFile.secureFilePath)
28+
inputs:
29+
secureFile: vott_id_rsa
30+
31+
# Install an SSH key prior to a build or deployment
32+
- task: InstallSSHKey@0 # https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/install-ssh-key?view=azure-devops
33+
inputs:
34+
knownHostsEntry: $(KNOWN_HOSTS_ENTRY)
35+
sshPublicKey: $(SSH_PUBLIC_KEY)
36+
#sshPassphrase: # Optional
37+
sshKeySecureFile: vott_id_rsa
38+
env:
39+
KNOWN_HOSTS_ENTRY: $(KNOWN_HOSTS_ENTRY)
40+
SSH_PUBLIC_KEY: $(SSH_PUBLIC_KEY) # map to the right format (camelCase) that Azure credentials understand
41+
42+
- task: Bash@3
43+
name: BumpNpmVersion
44+
displayName: Bump NPM Prerelease Version
45+
inputs:
46+
targetType: filePath
47+
filePath: ./scripts/version-bump-commit.sh
48+
env:
49+
SOURCE_BRANCH: $(Build.SourceBranch)
50+
51+
- stage: package_build
52+
dependsOn: version_bump_commit
53+
jobs:
54+
- template: azure-pipelines/templates/build-artifact.yml
55+
parameters:
56+
name: Linux
57+
pool:
58+
vmImage: ubuntu-16.04
59+
os: linux
60+
artifact: vott*.snap
61+
62+
- template: azure-pipelines/templates/build-artifact.yml
63+
parameters:
64+
name: Windows
65+
pool:
66+
vmImage: vs2017-win2016
67+
os: windows
68+
artifact: vott*.exe
69+
70+
- template: azure-pipelines/templates/build-artifact.yml
71+
parameters:
72+
name: MacOS
73+
pool:
74+
vmImage: macOS-10.13
75+
os: mac
76+
artifact: vott*.dmg
77+
78+
- stage: github_release
79+
dependsOn: package_build
80+
jobs:
81+
- template: azure-pipelines/templates/create-github-release.yml
82+
parameters:
83+
GitHubConnection: 'GitHub connection' # defaults for any parameters that aren't specified
84+
repositoryName: 'Microsoft/VoTT'
85+
releaseNotesSource: input
86+
addChangeLog: false
87+
isPreRelease: true
88+
isDraft: false

scripts/version-bump-commit.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
NPM_RELEASE_TYPE=${1-"prepatch --preid=preview"}
5+
6+
# Get full branch name excluding refs/head from the env var SOURCE_BRANCH
7+
SOURCE_BRANCH_NAME=${SOURCE_BRANCH/refs\/heads\/}
8+
9+
# Configure git to commit as SLS Azure Functions Service Account
10+
echo "Configuring git to use deploy key..."
11+
git config --local user.email "[email protected]"
12+
git config --local user.name "Vott"
13+
14+
echo "SOURCE_BRANCH: ${SOURCE_BRANCH_NAME}"
15+
git pull origin ${SOURCE_BRANCH_NAME}
16+
git checkout ${SOURCE_BRANCH_NAME}
17+
echo "Checked out branch: ${SOURCE_BRANCH_NAME}"
18+
19+
NPM_VERSION=`npm version ${NPM_RELEASE_TYPE} -m "release: Update ${NPM_RELEASE_TYPE} version to %s ***NO_CI***"`
20+
echo "Set NPM version to: ${NPM_VERSION}"
21+
22+
SHA=`git rev-parse HEAD`
23+
24+
export GIT_SSH_COMMAND="ssh -vvv -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
25+
git remote add authOrigin [email protected]:microsoft/VoTT.git
26+
git push authOrigin ${SOURCE_BRANCH_NAME} --tags
27+
28+
echo "Pushed new tag: ${NPM_VERSION} @ SHA: ${SHA:0:8}"

0 commit comments

Comments
 (0)