2222
2323jobs :
2424 create-package-version :
25- name :
25+ name : Create Package Version
2626 runs-on : ubuntu-latest
2727 steps :
2828 - name : Checkout
@@ -31,10 +31,10 @@ jobs:
3131 - name : Switch Package Context
3232 shell : bash
3333 run : |
34- # TODO: Swap the sfdx-project.json file for the one listed in the package directory:
35- # - 1. Create a tmp/ directory
36- # - 2. Move the existing sfdx-project.json file into the tmp/ directory
37- # - 3. Move the specified ${{ inputs.package }} directory's sfdx-project.json file into the project root
34+ # Swap the sfdx-project.json file for the one listed in the package directory
35+ mkdir -p tmp
36+ mv sfdx-project.json tmp/
37+ cp " ${{ inputs.package }}/ sfdx-project.json" .
3838
3939 - name : Get Version Number
4040 id : get-version
@@ -57,10 +57,16 @@ jobs:
5757 env :
5858 VERSION_NUMBER : ${{ steps.get-version.outputs.version-number }}
5959 run : |
60- # TODO: Update the version number/name on both tmp/sfdx- project.json and sfdx-project.json :
60+ # Update the version number/name in both project files :
6161 VERSION_NAME="v$VERSION_NUMBER"
62- # - 1. Update the version number/name on sfdx-project.json
63- # - 2. Update the version number/name on tmp/sfdx-project.json
62+ # Update the package file
63+ jq --arg vn "$VERSION_NUMBER" --arg vnm "$VERSION_NAME" \
64+ '.packageDirectories[0].versionNumber = $vn | .packageDirectories[0].versionName = $vnm' \
65+ sfdx-project.json > sfdx-project.json.tmp && mv sfdx-project.json.tmp sfdx-project.json
66+ # Update version in the original root file
67+ jq --arg vn "$VERSION_NUMBER" --arg vnm "$VERSION_NAME" \
68+ '.packageDirectories[0].versionNumber = $vn | .packageDirectories[0].versionName = $vnm' \
69+ tmp/sfdx-project.json > tmp/sfdx-project.json.tmp && mv tmp/sfdx-project.json.tmp tmp/sfdx-project.json
6470
6571 - name : Setup SF CLI
6672 uses : ./.github/actions/setup-sf-cli
8692 VERSION_NUMBER : ${{ steps.get-version.outputs.version-number }}
8793 shell : bash
8894 run : |
95+ # Get package alias from sfdx-project.json
96+ PACKAGE_ALIAS=$(jq -r '.packageDirectories[] | select(.default == true) | .package' sfdx-project.json)
97+ echo "Creating package version for: $PACKAGE_ALIAS"
8998 sf package version create \
9099 --code-coverage \
91100 --installation-key-bypass \
@@ -96,10 +105,10 @@ jobs:
96105 - name : Cleanup
97106 shell : bash
98107 run : |
99- # TODO: Relocate root & package's project files back to their original location
100- # - 1. Move the root's sfdx-project.json back to the directory specified in ${{ inputs.package }}
101- # - 2. Move tmp/sfdx-project.json back to the root
102- # - 3. Delete the tmp/ directory, and any other temporary files created by this process
108+ # Relocate root & package's project files back to their original location
109+ cp sfdx-project.json " ${{ inputs.package }}/"
110+ mv tmp/sfdx-project.json .
111+ rm -rf tmp/
103112
104113 - name : Tag & Commit Changes
105114 uses : " stefanzweifel/git-auto-commit-action@v6"
0 commit comments