Skip to content

Commit

Permalink
Renamed deploy.yml to build.yml, added the amazing pwsh function @jam…
Browse files Browse the repository at this point in the history
…essimone created for apex-rollup to auto-promote any prod package versions that are listed in README files
  • Loading branch information
jongpie committed Jan 14, 2022
1 parent f9c1a7c commit f8c393a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/deploy.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pipeline for Nebula Logger
name: Deployment
name: Build

on:
push:
Expand Down Expand Up @@ -114,7 +114,6 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
flags: LWC

# TODO find a way to consolidate duplicated LOC for scratch org steps
base-scratch-org-tests:
name: 'Run Base Scratch Org Tests'
needs: [code-quality-tests]
Expand Down Expand Up @@ -213,7 +212,6 @@ jobs:
- name: 'Run Apex Tests'
run: npm run test:apex

# TODO revisit this part - for now, CodeCov.io upload will only run in the Experience Cloud org
- name: 'Delete unsupported code coverage files'
run: rm ./test-coverage/apex/test-result-707*-codecoverage.json

Expand Down Expand Up @@ -317,3 +315,29 @@ jobs:

- name: 'Create Beta Managed Package Version'
run: npm run package:version:create:managed

promote-package-versions:
name: 'Promote Package Versions'
needs: [lwc-tests, base-scratch-org-tests, experience-cloud-scratch-org-tests]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2

- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install npm dependencies'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci

- name: 'Promote package versions'
run: npx pwsh ./config/scripts/build/promote-readme-packages.ps1
24 changes: 24 additions & 0 deletions config/scripts/build/promote-readme-packages.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This script finds any production install links for packages within README files & automatically promotes them

$DebugPreference = 'Continue'
$ErrorActionPreference = 'Stop'

function Start-Package-Promotion {
Write-Debug "Beginning promote script"

$allReadmes = Get-ChildItem -Exclude node_modules, .sfdx, tests | Get-ChildItem -Filter README.md -Recurse
foreach ($readme in $allReadmes) {
$readmePackageIdResults = (Select-String -Path $readme 'https:\/\/login.salesforce.com\/packaging\/installPackage.apexp\?p0=.{0,18}')
if ($readmePackageIdResults.Matches.Length -gt 0) {
$packageIdSplit = $readmePackageIdResults.Matches[0].Value.Split("=")
if ($packageIdSplit.Length -eq 2) {
$packageId = $packageIdSplit[1]
Write-Debug "Promoting $packageId from $readme"
npx sfdx force:package:version:promote --package $packageId --noprompt
}
}
}
Write-Debug "Finished package promotion!"
}

Start-Package-Promotion

0 comments on commit f8c393a

Please sign in to comment.