Skip to content

Commit 3511f81

Browse files
authored
fix: Specify default value for PACKAGES_NAME (#4)
1 parent 709e44e commit 3511f81

File tree

2 files changed

+53
-34
lines changed

2 files changed

+53
-34
lines changed

.github/workflows/commit-to-git.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
type: string
1717
required: false
1818
PACKAGE_NAMES:
19-
#description: 'Comma-separated list of package names to update'
19+
#description: 'Comma-separated list of package names to update. _Default value_: repository name.'
2020
type: string
2121
required: false
2222

@@ -37,7 +37,7 @@ jobs:
3737
VERSION: ${{ inputs.VERSION }}
3838
COMMITTER: ${{ inputs.COMMITTER || github.actor }}
3939
COMMIT_MESSAGE: ${{ inputs.COMMIT_MESSAGE }}
40-
PACKAGE_NAMES: ${{ inputs.PACKAGE_NAMES }}
40+
PACKAGE_NAMES: ${{ inputs.PACKAGE_NAMES || github.repository }}
4141

4242
steps:
4343
- name: Create GitHub App Token

templates/call-commit-to-git.yml

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,59 @@
1414
# -----------------
1515
name: Call Commit to Git Workflow
1616

17-
jobs:
17+
jobs:
1818

19-
# Your workflow must include a job that generates a new version of the componente (aka 'buildJob')
20-
# As an integration sample, the following 'buildJob' is provided.
21-
buildJob:
22-
name: Build & Publish
23-
# To ensure proper handling of values by the callable workflow, you need to define output variables.
24-
# In this sample, the values are saved as part of the step 'getBuildInfo'.
25-
# Please refer to the workflow itself for more information about the required and optional arguments.
26-
outputs:
27-
PACKAGE_VERSION: ${{ steps.getBuildInfo.outputs.PACKAGE_VERSION }} # Required
28-
PACKAGES_NAME: ${{ steps.getBuildInfo.outputs.PACKAGES_NAME }} # Optional
29-
GIT_COMMIT_MSG: ${{ steps.getBuildInfo.outputs.COMMIT_MSG }} # Optional
19+
# Your workflow must include a job that generates a new version of the componente (aka 'buildJob')
20+
# As an integration sample, the following 'buildJob' is provided.
21+
buildJob:
22+
name: Build & Publish
23+
# To ensure proper handling of values by the callable workflow, you need to define output variables.
24+
# In this sample, the values are saved as part of the step 'getDepsInfo'.
25+
# Please refer to the workflow itself for more information about the required and optional arguments.
26+
outputs:
27+
PACKAGE_VERSION: ${{ steps.getDepsInfo.outputs.PACKAGE_VERSION }}
28+
PACKAGES_NAME: ${{ steps.getDepsInfo.outputs.PACKAGES_NAME }}
3029

31-
steps:
32-
# As part of your workflow steps, it is necessary to include a process that generates a new package
33-
# with a new version and publishes it to a well-known feed. During this process, it is important
34-
# to preserve certain values that will be used for integration purposes.
35-
- name: Get Build Information
36-
id: getBuildInfo
37-
run: |
38-
# Process to get a new package version that is stored in the variable $newPackageVersion
39-
echo "PACKAGE_VERSION=$newPackageVersion" >> $GITHUB_OUTPUT
40-
echo "PACKAGES_NAME=package1,package2" >> $GITHUB_OUTPUT
41-
echo "COMMIT_MSG=Update to version $newPackageVersion" >> $GITHUB_OUTPUT
30+
steps:
31+
# As part of your workflow steps, it is necessary to include a process that generates a new package
32+
# with a new version and publishes it to a well-known feed. During this process, it is important
33+
# to preserve certain values that will be used for integration purposes.
34+
- name: Get Packages Information
35+
id: getDepsInfo
36+
run: |
37+
# Following sample reads the packages Id and Ver from the
38+
# nupkg in a given directory
39+
$nupkgDir = "Packages\Release"
40+
$pattern = '^(.*?)\.(\d+\.\d+(\.\d+)?([+-].*)?)\.nupkg$'
41+
$packageIds= @()
42+
$packageVer=""
43+
Get-ChildItem "$env:nupkgDir\*.nupkg" -Recurse | ForEach-Object {
44+
if ($_.Name -match $pattern) {
45+
$packageId = $matches[1]
46+
if ($packageId-notin $packageIds) {
47+
$packageIds += $packageId
48+
}
49+
# In this sample, all packages are expected to share the same package version
50+
$packageVer = $matches[2]
51+
}
52+
else {
53+
Write-Error "Unexpected name. File name does not matches NuGet pattern for packageId and packgeVersion: $_.Name"
54+
}
55+
}
56+
$packageNames = $packageIds -join ","
57+
58+
# Look out! GITHUB_OUTPUT is an environment variable. In Powershell, its name is $env:GITHUB_OUTPUT, but for other
59+
# languages it is referred to as $GITHUB_OUTPUT.
60+
echo "PACKAGE_VERSION=$packageVer" >> $env:GITHUB_OUTPUT
61+
echo "PACKAGES_NAME=$packageNames" >> $env:GITHUB_OUTPUT
4262
4363
# -- Copy & Paste the following job ---
44-
update-genexus-dependency:
45-
# Replace the 'buildJob' name in the following lines for the name of the job in your workflow that publish the packages(s)
46-
uses: genexuslabs/build-genexus-reusable-workflow/.github/workflows/commit-to-git.yml@main
47-
needs: buildJob
48-
with:
49-
VERSION: ${{ needs.buildJob.outputs.PACKAGE_VERSION }}
50-
PACKAGE_NAMES: ${{ needs.buildJob.outputs.PACKAGES_NAME }} # Optional
51-
COMMIT_MESSAGE: ${{ needs.buildJob.outputs.GIT_COMMIT_MSG }} # Optional
52-
secrets: inherit
64+
update-genexus-dependency:
65+
# Replace the 'buildJob' name in the following lines for the name of the job in your workflow that publish the packages(s)
66+
uses: genexuslabs/build-genexus-reusable-workflow/.github/workflows/commit-to-git.yml@main
67+
needs: buildJob
68+
with:
69+
VERSION: ${{ needs.buildJob.outputs.PACKAGE_VERSION }}
70+
PACKAGE_NAMES: ${{ needs.buildJob.outputs.PACKAGES_NAME }} # Optional
71+
secrets: inherit
5372
# -------------------------------------

0 commit comments

Comments
 (0)