-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (107 loc) · 4.21 KB
/
packaging.yml
File metadata and controls
117 lines (107 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Packaging
on:
workflow_call:
inputs:
package:
description: Package Directory
required: true
type: string
version:
description: Version Number (#.#.#)
required: false
type: string
workflow_dispatch:
inputs:
package:
description: Package Directory
required: true
version:
description: Version Number (#.#.#)
required: false
jobs:
create-package-version:
name: Create Package Version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Switch Package Context
shell: bash
run: |
# Swap the sfdx-project.json file for the one listed in the package directory
mkdir -p tmp
mv sfdx-project.json tmp/
cp "${{ inputs.package }}/sfdx-project.json" .
- name: Get Version Number
id: get-version
env:
INPUT_VERSION: ${{ inputs.version }}
shell: bash
run: |
# If an input version number isn't set, use the current version defined in sfdx-project.json:
if [[ -z "$INPUT_VERSION" ]]; then
VERSION_NUMBER=$(jq -r '.packageDirectories[] | select(.default == true) | .versionNumber' sfdx-project.json)
echo "Using the version number defined in sfdx-project.json: $VERSION_NUMBER"
else
VERSION_NUMBER="${INPUT_VERSION}.NEXT"
echo "Using specified version number: $VERSION_NUMBER"
fi
echo "version-number=$VERSION_NUMBER" >> "$GITHUB_OUTPUT"
- name: Increment Version Number
shell: bash
env:
VERSION_NUMBER: ${{ steps.get-version.outputs.version-number }}
run: |
# Update the version number/name in both project files:
VERSION_NAME="v$VERSION_NUMBER"
# Update the package file
jq --arg vn "$VERSION_NUMBER" --arg vnm "$VERSION_NAME" \
'.packageDirectories[0].versionNumber = $vn | .packageDirectories[0].versionName = $vnm' \
sfdx-project.json > sfdx-project.json.tmp && mv sfdx-project.json.tmp sfdx-project.json
# Update version in the original root file
jq --arg vn "$VERSION_NUMBER" --arg vnm "$VERSION_NAME" \
'.packageDirectories[0].versionNumber = $vn | .packageDirectories[0].versionName = $vnm' \
tmp/sfdx-project.json > tmp/sfdx-project.json.tmp && mv tmp/sfdx-project.json.tmp tmp/sfdx-project.json
- name: Setup SF CLI
uses: ./.github/actions/setup-sf-cli
- name: Authenticate Devhub
env:
CLIENT_ID: ${{ secrets.SALESFORCE_CONSUMER_KEY }}
JWT_KEY: ${{ secrets.SALESFORCE_JWT_KEY }}
USERNAME: ${{ secrets.SALESFORCE_DEVHUB_USERNAME }}
shell: bash
run: |
set -euo pipefail
echo "${JWT_KEY}" > server.key
sf org login jwt \
--client-id "$CLIENT_ID" \
--jwt-key-file server.key \
--set-default-dev-hub \
--username "$USERNAME"
trap 'rm -f server.key' EXIT
- name: Create New Package Version
env:
VERSION_NUMBER: ${{ steps.get-version.outputs.version-number }}
shell: bash
run: |
# Get package alias from sfdx-project.json
PACKAGE_ALIAS=$(jq -r '.packageDirectories[] | select(.default == true) | .package' sfdx-project.json)
echo "Creating package version for: $PACKAGE_ALIAS"
sf package version create \
--code-coverage \
--installation-key-bypass \
--package "$PACKAGE_ALIAS" \
--version-number "$VERSION_NUMBER" \
--wait 29
- name: Cleanup
shell: bash
run: |
# Relocate root & package's project files back to their original location
cp sfdx-project.json "${{ inputs.package }}/"
mv tmp/sfdx-project.json .
rm -rf tmp/
- name: Tag & Commit Changes
uses: "stefanzweifel/git-auto-commit-action@v6"
with:
commit_message: "Requested new package version v${{ steps.get-version.outputs.version-number }}"
tagging_message: "v${{ steps.get-version.outputs.version-number }}"