Skip to content

Commit

Permalink
chore: cut release (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeul authored Oct 31, 2023
2 parents e75aeea + c503af2 commit 7c0cd20
Show file tree
Hide file tree
Showing 331 changed files with 449 additions and 5,929 deletions.
94 changes: 60 additions & 34 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ pipeline {
}

tools {
nodejs 'Node14'
nodejs 'Node18'
}

// STAGE_TAG will be {branch_name}_{timestamp}
environment {
BRANCH_NAME = sh(returnStdout: true, script: 'echo $GIT_BRANCH | sed "s#origin/##g"').trim()
GIT_COMMIT_MESSAGE = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
// sed commands in order:
// remove origin/ from the branch name
// replace any hyphens (-) with underscores (_)
// shorten to 18 characters to allow space for the timestamp at the end
STAGE_TAG = sh(returnStdout: true, script: 'echo $(echo $GIT_BRANCH | sed "s#origin/##g" | sed "s/-/_/g" | sed -e "s/(.{18}).*/$1/g")_$(date +%s)').trim()
GIT_COMMIT_HASH = GIT_COMMIT.take(7)

// Assumes commit messages follow this format: chore(release): 1.49.1 [skip ci]
VERSION = sh(returnStdout: true, script: "echo $GIT_COMMIT_MESSAGE | cut -d ':' -f2 | cut -d '[' -f1").trim()
}

stages {
Expand All @@ -26,39 +24,65 @@ pipeline {
echo $GIT_COMMIT_MESSAGE
node -v
npm -v
npm i --reg https://npm.paypal.com -g @paypalcorp/web
npm i --reg $REGISTRY -g @paypalcorp/web
'''
}
}

// For non-release, auto-generate a stage build
stage('Stage Tag') {
when {
not {
branch 'release'
// For release, deploy existing build assets
stage('Bundle Stage') {
steps {
script {
if (GIT_COMMIT_MESSAGE.contains('chore(release)')) {
// Stage tags can only contain alphnumeric characters and underscores
VERSION=VERSION.replace('.', '_')
env.stageBundleId='up_stage_v' + VERSION + '_' + GIT_COMMIT_HASH
withCredentials([usernamePassword(credentialsId: 'web-cli-creds', passwordVariable: 'SVC_ACC_PASSWORD', usernameVariable: 'SVC_ACC_USERNAME')]) {
sh '''
rm -rf ./dist/bizcomponents/sandbox
rm -rf ./dist/bizcomponents/js
output=$(web stage --tag $stageBundleId)
web notify "$stageBundleId"
git checkout -- dist
'''
}
}
}
}
}
stage('Bundle Sandbox') {
steps {
withCredentials([usernamePassword(credentialsId: 'web-cli-creds', passwordVariable: 'SVC_ACC_PASSWORD', usernameVariable: 'SVC_ACC_USERNAME')]) {
sh '''
npm i --reg https://npm.paypal.com
npm run build -- -t $STAGE_TAG -s $TEST_ENV
'''
script {
if (GIT_COMMIT_MESSAGE.contains('chore(release)')) {
env.sandboxBundleId='up_sb_v' + VERSION + '_' + GIT_COMMIT_HASH
withCredentials([usernamePassword(credentialsId: 'web-cli-creds', passwordVariable: 'SVC_ACC_PASSWORD', usernameVariable: 'SVC_ACC_USERNAME')]) {
sh '''
rm -rf ./dist/bizcomponents/stage
rm -rf ./dist/bizcomponents/js
output=$(web stage --tag $sandboxBundleId)
web notify "$sandboxBundleId"
git checkout -- dist
'''
}
}
}
}
}

// For release, stage existing build assets and send notification
stage('Deploy') {
when {
branch 'release'
}
stage('Build Production') {
steps {
withCredentials([usernamePassword(credentialsId: 'web-cli-creds', passwordVariable: 'SVC_ACC_PASSWORD', usernameVariable: 'SVC_ACC_USERNAME')]) {
sh '''
OUTPUT=$(web stage --json --tag $STAGE_TAG)
web notify $STAGE_TAG
'''
script {
if (GIT_COMMIT_MESSAGE.contains('chore(release)')) {
env.productionBundleId='up_prod_v' + VERSION + '_' + GIT_COMMIT_HASH
withCredentials([usernamePassword(credentialsId: 'web-cli-creds', passwordVariable: 'SVC_ACC_PASSWORD', usernameVariable: 'SVC_ACC_USERNAME')]) {
sh '''
rm -rf ./dist/bizcomponents/stage
rm -rf ./dist/bizcomponents/sandbox
output=$(web stage --tag $productionBundleId)
web notify "$productionBundleId"
git checkout -- dist
'''
}
}
}
}
}
Expand All @@ -72,15 +96,17 @@ pipeline {
// Single quotes on this so the variable makes it to the email plugin instead of Jenkins trying to replace
to: '$DEFAULT_RECIPIENTS',
subject: "paypal-messaging-components - ${BRANCH_NAME} - Build #${env.BUILD_NUMBER} - SUCCESS!",
// The ${FILE} similarly needs to be sent to the plugin to be replaced, so the $ is escaped
body: """
Build Succeeded!<br />
<br />
${GIT_COMMIT_MESSAGE}<br />
Build URL: ${env.BUILD_URL}<br />
Stage Tag: ${STAGE_TAG}<br />
CDN Bundle: https://UIDeploy--StaticContent--${STAGE_TAG}--ghe.preview.dev.paypalinc.com/upstream/bizcomponents/stage?cdn:list<br />
Test Page: ${TEST_URL}${STAGE_TAG}<br />
Build URL: ${BUILD_URL}<br />
<br />
Version ${env.VERSION} assets have been bundled and are ready for review.<br />
Please approve and deploy: <br />
1. Stage: ${BUNDLE_URL}${stageBundleId} <br />
2. Sandbox: ${BUNDLE_URL}${sandboxBundleId} <br />
3. Production: ${BUNDLE_URL}${productionBundleId} <br />
<br />
Regards,<br />
Your friendly neighborhood digital butler
Expand Down
45 changes: 0 additions & 45 deletions content/modals/AU/gpl.json

This file was deleted.

54 changes: 0 additions & 54 deletions content/modals/DE/gpl.json

This file was deleted.

46 changes: 0 additions & 46 deletions content/modals/DE/pi30.json

This file was deleted.

2 changes: 1 addition & 1 deletion content/modals/ES/short_term_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
]
},
"instructions": [
"Choose PayPal at checkout to pay later with <strong>Pay in 3</strong>. ",
"Choose PayPal at checkout to pay later with <strong>Pay in 3 installments</strong>. ",
"Complete your purchase with your first payment today. ",
"Any remaining payments are made automatically. It's easy!"
],
Expand Down
48 changes: 0 additions & 48 deletions content/modals/FR/gpl.json

This file was deleted.

Loading

0 comments on commit 7c0cd20

Please sign in to comment.