11name : Azure IPAM Build
22
3- run-name : Azure IPAM Production Build & Release
3+ run-name : Azure IPAM Container Build
44
55on :
6- push :
7- branches :
8- - main
6+ release :
7+ types : [ published ]
98
109permissions :
1110 id-token : write
12- contents : write
13- pull-requests : read
1411
1512env :
1613 ACR_NAME : ${{ vars.IPAM_PROD_ACR }}
1714
1815jobs :
19- version :
20- name : Update Azure IPAM Version
16+ init :
17+ name : Initialize Azure IPAM Build
2118 runs-on : ubuntu-latest
2219 outputs :
23- ipamVersion : ${{ steps.updateVersion.outputs.ipamVersion }}
24- prNumber : ${{ fromJson(steps.getPullRequestData.outputs.result).number }}
25- commitHash : ${{ steps.commitCode.outputs.commitHash }}
20+ ipamVersion : ${{ steps.extractVersion.outputs.ipamVersion }}
2621 steps :
27- - run : echo "Job triggered by a ${{ github.event_name }} event to main."
28-
29- - name : " Setup NodeJS v18"
30- id : setupNode
31- uses : actions/setup-node@v4
32- with :
33- node-version : 18
34-
35- - name : " Setup Python v3.9"
36- id : setupPython
37- uses : actions/setup-python@v5
38- with :
39- python-version : ' 3.9'
40-
41- - name : " Extract Pull Request Details"
42- id : getPullRequestData
43- uses : actions/github-script@v7
44- with :
45- script : |
46- return (
47- await github.rest.repos.listPullRequestsAssociatedWithCommit({
48- commit_sha: context.sha,
49- owner: context.repo.owner,
50- repo: context.repo.repo,
51- })
52- ).data[0];
53-
54- - name : Checkout Azure IPAM Code
55- uses : actions/checkout@v4
56- with :
57- token : ${{ secrets.PAT_TOKEN }}
22+ - run : echo "Job triggered by a ${{ github.event_name }} event."
23+ - run : echo "Release Tag - ${{ github.event.release.tag_name }}."
5824
59- - name : Configure Git
60- id : configureGit
61- run : |
62- git config --global user.name "IPAM GitHub Actions"
63- git config --global user.email "[email protected] " 64-
65- - name : " Increment Azure IPAM Version"
66- id : updateVersion
67- working-directory : tools
25+ - name : Extract IPAM Version
26+ id : extractVersion
6827 env :
69- prBody : ${{ fromJson(steps.getPullRequestData.outputs.result).body }}
70- shell : pwsh
71- run : |
72- $version = [regex]::matches($env:prBody, '(?<=\[version:).*(?=])').value
73- $major = $env:prBody -match '(?<=\[)major(?=])'
74- $minor = $env:prBody -match '(?<=\[)minor(?=])'
75- $build = $env:prBody -match '(?<=\[)build(?=])'
76-
77- try {
78- $version = [System.Version]$version
79- $newVersion = "{0}.{1}.{2}" -f $version.Major, $version.Minor, $version.Build
80- } catch {
81- $version = $null
82- }
83-
84- if ($version) {
85- ./version.ps1 -Version $newVersion
86- } elseif ($major) {
87- ./version.ps1 -BumpMajor
88- } elseif ($minor) {
89- ./version.ps1 -BumpMinor
90- } else {
91- ./version.ps1 -BumpBuild
92- }
93-
94- - name : Install NPM Packages
95- id : installNpmPackages
96- working-directory : ui
97- run : |
98- npm install
99-
100- - name : Install PIP Packages
101- id : installPipPackages
102- working-directory : engine
103- run : |
104- pip install -r requirements.txt
105-
106- - name : Freeze PIP Packages
107- id : freezePipPackages
108- working-directory : engine
109- run : |
110- echo "# Dependencies for Azure IPAM v${{ steps.updateVersion.outputs.ipamVersion }}" > requirements.lock.txt
111- pip freeze >> requirements.lock.txt
112-
113- - name : " Create Azure IPAM ZIP Asset"
114- id : buildZipAsset
115- working-directory : tools
28+ releaseTag : ${{ github.event.release.tag_name }}
11629 shell : pwsh
11730 run : |
118- ./build.ps1 -Path ../assets/
119-
120- - name : Commit Updated Azure IPAM Code
121- id : commitCode
122- env :
123- prNumber : ${{ fromJson(steps.getPullRequestData.outputs.result).number }}
124- run : |
125- git commit -a -m "Updated Azure IPAM Version to v${{ steps.updateVersion.outputs.ipamVersion }} [skip ci]"
126- git push
127- echo "commitHash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
128-
129- release :
130- name : Create Azure IPAM Release
131- runs-on : ubuntu-latest
132- needs : [ version ]
133- steps :
134- - name : Checkout Azure IPAM Code
135- uses : actions/checkout@v4
136- with :
137- ref : ${{ needs.version.outputs.commitHash }}
138- sparse-checkout : |
139- assets
140-
141- - name : Publish Azure IPAM Release
142- id : publishRelease
143- env :
144- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
145- tagName : v${{ needs.version.outputs.ipamVersion }}
146- run : |
147- gh release create "$tagName" \
148- --repo="$GITHUB_REPOSITORY" \
149- --title="$tagName" \
150- --notes "Azure IPAM Release"
151-
152- - name : Upload Azure IPAM Release Asset
153- id : uploadReleaseAsset
154- env :
155- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
156- tagName : v${{ needs.version.outputs.ipamVersion }}
157- assetPath : ./assets/ipam.zip
158- run : |
159- gh release upload "$tagName" "$assetPath"
31+ $version = $env:releaseTag -replace "v", ""
32+ Write-Output "ipamVersion=$version" >> $Env:GITHUB_OUTPUT
16033
16134 build :
16235 name : Build Azure IPAM Containers
16336 runs-on : ubuntu-latest
164- needs : [ version, release ]
37+ needs : [ init ]
16538 steps :
16639 - name : Azure Login
16740 uses : azure/login@v2
@@ -174,23 +47,21 @@ jobs:
17447 - name : Checkout Azure IPAM Code
17548 uses : actions/checkout@v4
17649 with :
177- ref : ${{ needs.version.outputs.commitHash }}
17850 sparse-checkout : |
17951 engine
18052 ui
181- lb
18253
18354 - name : Build Azure IPAM Containers
18455 env :
185- IPAM_VERSION : ${{ needs.version .outputs.ipamVersion }}
56+ IPAM_VERSION : ${{ needs.init .outputs.ipamVersion }}
18657 run : |
18758 az acr build -r $ACR_NAME -t ipam:$IPAM_VERSION -t ipam:latest -f ./Dockerfile.deb .
18859 az acr build -r $ACR_NAME -t ipamfunc:$IPAM_VERSION -t ipamfunc:latest -f ./Dockerfile.func .
18960
19061 build-legacy :
19162 name : Build Legacy Azure IPAM Containers
19263 runs-on : ubuntu-latest
193- needs : [ version, release ]
64+ needs : [ init ]
19465 steps :
19566 - name : Azure Login
19667 uses : azure/login@v2
@@ -203,15 +74,14 @@ jobs:
20374 - name : Checkout Azure IPAM Code
20475 uses : actions/checkout@v4
20576 with :
206- ref : ${{ needs.version.outputs.commitHash }}
20777 sparse-checkout : |
20878 engine
20979 ui
21080 lb
21181
21282 - name : Build Legacy Azure IPAM Containers
21383 env :
214- IPAM_VERSION : ${{ needs.version .outputs.ipamVersion }}
84+ IPAM_VERSION : ${{ needs.init .outputs.ipamVersion }}
21585 run : |
21686 az acr build -r $ACR_NAME -t ipam-engine:$IPAM_VERSION -t ipam-engine:latest -f ./engine/Dockerfile.deb ./engine
21787 az acr build -r $ACR_NAME -t ipam-func:$IPAM_VERSION -t ipam-func:latest -f ./engine/Dockerfile.func ./engine
0 commit comments