|
14 | 14 | # -----------------
|
15 | 15 | name: Call Commit to Git Workflow
|
16 | 16 |
|
17 |
| - jobs: |
| 17 | + jobs: |
18 | 18 |
|
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 }} |
30 | 29 |
|
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 |
42 | 62 |
|
43 | 63 | # -- 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 |
53 | 72 | # -------------------------------------
|
0 commit comments