Skip to content

Commit a3181a2

Browse files
feat: add packageNames output (#33)
Add packageNames as a json formatted array consisting of the package names generated from this action. Intended for use cases such as enabling process rollbacks. Sanitize provided version for "v" prefix.
1 parent e48ffd2 commit a3181a2

3 files changed

Lines changed: 60 additions & 12 deletions

File tree

.github/workflows/uipath-ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
projectVersion: '1.0.0'
4545
releaseNotes: 'Initial release'
4646

47+
- run: echo "Generated packages ${{ steps.pack.outputs.packageNames }}"
48+
4749
# Upload packages as build artifacts to be handled by deploy job
4850
- uses: actions/upload-artifact@v6
4951
with:
@@ -54,6 +56,8 @@ jobs:
5456

5557
pack-with-multi-file-input:
5658
runs-on: windows-latest
59+
outputs:
60+
packageNames: ${{ steps.pack.outputs.packageNames }}
5761
steps:
5862
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
5963
- uses: actions/checkout@v6
@@ -78,6 +82,8 @@ jobs:
7882
projectVersion: '1.0.0'
7983
releaseNotes: 'Initial release with file input'
8084

85+
- run: echo "Generated packages ${{ steps.pack.outputs.packageNames }}"
86+
8187
# Upload packages as build artifacts to be handled by deploy job
8288
- uses: actions/upload-artifact@v6
8389
with:
@@ -86,6 +92,16 @@ jobs:
8692
if-no-files-found: error
8793
retention-days: 90
8894

95+
matrix-example-job:
96+
needs: pack-with-multi-file-input
97+
runs-on: ubuntu-latest
98+
strategy:
99+
matrix:
100+
tenant: [ TEST, PROD ]
101+
packageName: ${{ fromJson(needs.pack-with-multi-file-input.outputs.packageNames) }}
102+
steps:
103+
- run: echo "This job can now use the package name ${{ matrix.packageName }} to perform further steps, such as deployment or testing."
104+
89105
pack-with-ubuntu:
90106
runs-on: ubuntu-latest
91107
steps:
@@ -113,9 +129,11 @@ jobs:
113129
orchestratorApplicationSecret: ${{ secrets.UIPATH_APP_SECRET }}
114130
orchestratorApplicationScope: ${{ secrets.UIPATH_APP_SCOPE }}
115131
orchestratorLogicalName: ${{ secrets.UIPATH_ORGANIZATION_ID }}
116-
projectVersion: '1.0.0'
132+
projectVersion: 'v1.0.0'
117133
releaseNotes: 'Initial release with file input'
118134

135+
- run: echo "Generated packages ${{ steps.pack.outputs.packageNames }}"
136+
119137
# Upload packages as build artifacts to be handled by deploy job
120138
- uses: actions/upload-artifact@v4
121139
with:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ The scenario illustrated below shows how one can work with providing specific pr
7575
|Name|Description|
7676
|:--|:--|
7777
|**packagesPath**|Path to the folder containing the .nupkg packages generated by this action|
78+
|**packageNames**|Comma-separated list of generated package file names|

action.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,24 @@ outputs:
4848
packagesPath:
4949
description: 'Folder containing the generated packages'
5050
value: ${{ steps.pack.outputs.packagesPath }}
51+
packageNames:
52+
description: 'JSON array of generated package names, for use with fromJson() in subsequent matrix jobs'
53+
value: ${{ steps.step-summary.outputs.packageNames }}
5154

5255
runs:
5356
using: "composite"
5457
steps:
58+
- id: sanitize-version
59+
name: Sanitize version
60+
shell: bash
61+
run: |
62+
# Remove leading 'v' if present in version (e.g., v1.0.0 -> 1.0.0)
63+
sanitizedVersion="${{ inputs.projectVersion }}"
64+
if [[ "$sanitizedVersion" == v* ]]; then
65+
sanitizedVersion="${sanitizedVersion:1}"
66+
fi
67+
echo "projectVersion=$sanitizedVersion" >> $GITHUB_OUTPUT
68+
5569
- id: set-urls
5670
name: Set URLs
5771
shell: bash
@@ -83,7 +97,7 @@ runs:
8397
8498
while IFS= read -r p; do
8599
echo "::group::uipcli output for packing project: $p"
86-
uipcli package pack "$p" \
100+
if ! packResult=$(uipcli package pack "$p" \
87101
--output "$packages" \
88102
--libraryOrchestratorUrl "${{ inputs.orchestratorUrl }}" \
89103
--libraryOrchestratorTenant "${{ inputs.orchestratorTenant }}" \
@@ -93,22 +107,22 @@ runs:
93107
--libraryOrchestratorApplicationScope "${{ inputs.orchestratorApplicationScope }}" \
94108
--libraryOrchestratorFolder "${{ inputs.orchestratorFolder }}" \
95109
--releaseNotes "${{ inputs.releaseNotes }}" \
96-
--version "${{ inputs.projectVersion }}" \
110+
--version "${{ steps.sanitize-version.outputs.projectVersion }}" \
97111
-l en-US \
98112
--repositoryUrl "${{ steps.set-urls.outputs.repoUrl }}" \
99113
--repositoryCommit "${{ github.sha }}" \
100114
--repositoryBranch "${{ github.head_ref || github.ref_name }}" \
101115
--repositoryType git \
102116
--projectUrl "${{ steps.set-urls.outputs.projectUrl }}" \
103117
--traceLevel "${{ inputs.traceLevel }}" \
104-
--author "${{ inputs.author }}"
105-
106-
echo "::endgroup::"
107-
108-
if [ $? -ne 0 ]; then
118+
--author "${{ inputs.author }}" 2>&1); then
109119
echo "Pack Failed"
120+
echo "uipcli output: $packResult"
121+
echo "::endgroup::"
110122
exit 1
111123
fi
124+
echo "Pack Succeeded: $packResult"
125+
echo "::endgroup::"
112126
done <<< "$projectJsonFiles"
113127
114128
- id: step-summary
@@ -118,10 +132,25 @@ runs:
118132
run: |
119133
echo "### Generated packages: " >> $GITHUB_STEP_SUMMARY
120134
121-
packages=$(find "${{ steps.pack.outputs.packagesPath }}" -type f -name "*.nupkg")
122-
for package in $packages; do
123-
echo ":package: $(basename "$package")" >> $GITHUB_STEP_SUMMARY
124-
done
135+
packageNames=()
136+
while IFS= read -r -d '' package; do
137+
packageFileName=$(basename "$package")
138+
packageName="${packageFileName%.nupkg}"
139+
versionSuffix=".${{ steps.sanitize-version.outputs.projectVersion }}"
140+
if [[ "$packageName" == *"$versionSuffix" ]]; then
141+
packageName="${packageName%$versionSuffix}"
142+
fi
143+
packageNames+=("$packageName")
144+
echo "📦 $packageFileName" >> $GITHUB_STEP_SUMMARY
145+
done < <(find "${{ steps.pack.outputs.packagesPath }}" -type f -name "*.nupkg" -print0)
146+
147+
if [ ${#packageNames[@]} -gt 0 ]; then
148+
packageNamesJson=$(printf '%s\n' "${packageNames[@]}" | jq -R . | jq -s -c .)
149+
else
150+
packageNamesJson="[]"
151+
fi
152+
153+
echo "packageNames=$packageNamesJson" >> $GITHUB_OUTPUT
125154
126155
127156

0 commit comments

Comments
 (0)