-
Notifications
You must be signed in to change notification settings - Fork 0
/
call-update-genexus-dep-version.yml
77 lines (71 loc) · 3.79 KB
/
call-update-genexus-dep-version.yml
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
# -----------------
# Template that can be used by repositories on github.com/genexuslabs organization
# -----------------
# Requirements:
# * Your repository must have a workflow defined that publishes a new version of
# component package(s) to a well-known feed on the organization (aka "build.yml").
# -----------------
# Instructions:
# 1. Edit the build.yml workflow file in your repository.
# 2. Copy the job "update-genexus-dependency" and add it to the workflow.
# 3. Configure your build job to generate package information (name and version).
# 4. Configure update-genexus-dependency job to execute after your build job and
# retrieve the package name and version information.
# 5. Ask your organization Owner to let your repo use the following secrets:
# - GENEXUS_SUITE_LINK_APP_PRIVATE_KEY
# -----------------
name: Call "Update GeneXus Dependency Version" Workflow
jobs:
# Your workflow must include a job that generates a new version of the componente (aka 'buildJob')
# As an integration sample, the following 'buildJob' is provided.
buildJob:
name: Build & Publish
# To ensure proper handling of values by the callable workflow, you need to define output variables.
# In this sample, the values are saved as part of the step 'getDepsInfo'.
# Please refer to the workflow itself for more information about the required and optional arguments.
outputs:
PACKAGE_VERSION: ${{ steps.getDepsInfo.outputs.PACKAGE_VERSION }}
PACKAGES_NAME: ${{ steps.getDepsInfo.outputs.PACKAGES_NAME }}
steps:
# As part of your workflow steps, it is necessary to include a process that generates a new package
# with a new version and publishes it to a well-known feed. During this process, it is important
# to preserve certain values that will be used for integration purposes.
- name: Get Packages Information
id: getDepsInfo
run: |
# Following sample reads the packages Id and Ver from the
# nupkg in a given directory
$nupkgDir = "Packages\Release"
$pattern = '^(.*?)\.(\d+\.\d+(\.\d+)?([+-].*)?)\.nupkg$'
$packageIds= @()
$packageVer=""
Get-ChildItem "$env:nupkgDir\*.nupkg" -Recurse | ForEach-Object {
if ($_.Name -match $pattern) {
$packageId = $matches[1]
if ($packageId-notin $packageIds) {
$packageIds += $packageId
}
# In this sample, all packages are expected to share the same package version
$packageVer = $matches[2]
}
else {
Write-Error "Unexpected name. File name does not matches NuGet pattern for packageId and packgeVersion: $_.Name"
}
}
$packageNames = $packageIds -join ","
# Look out! GITHUB_OUTPUT is an environment variable. In Powershell, its name is $env:GITHUB_OUTPUT, but for other
# languages it is referred to as $GITHUB_OUTPUT.
echo "PACKAGE_VERSION=$packageVer" >> $env:GITHUB_OUTPUT
echo "PACKAGES_NAME=$packageNames" >> $env:GITHUB_OUTPUT
# -- Copy & Paste the following job ---
update-genexus-dependency:
# Replace the 'buildJob' name in the following lines for the name of the job in your workflow that publish the packages(s)
uses: genexuslabs/build-genexus-reusable-workflow/.github/workflows/update-genexus-dep-version.yml@main
needs: buildJob
with:
VERSION: ${{ needs.buildJob.outputs.PACKAGE_VERSION }}
PACKAGE_NAMES: ${{ needs.buildJob.outputs.PACKAGES_NAME }} # Optional (1)
secrets: inherit
# -------------------------------------
# (1) PACKAGES_NAME is optional when your have only one dependency to update and its name
# is the same than the repo; otherwise, define this value.