generated from ni/github-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
81 lines (66 loc) · 2.65 KB
/
unit-test-and-build-vi-package.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
78
79
80
81
name: Build the icon editor
on:
pull_request:
branches:
- 'feature/*'
- 'develop'
types: [opened, synchronize, reopened]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-and-test:
name: Build the icon editor
runs-on: [self-hosted, iconeditor]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get Build Revision
id: get_revision
shell: pwsh
run: |
# Path to store the build revision counter
$COUNTER_FILE = "$env:GITHUB_WORKSPACE/.github/buildCounter.txt"
Write-Host "Counter file path: $COUNTER_FILE"
# Initialize the counter file if it doesn't exist
if (-Not (Test-Path $COUNTER_FILE)) {
Write-Host "Counter file not found. Initializing to 1."
"1" | Out-File $COUNTER_FILE
}
# Read the current value
$build_revision = Get-Content $COUNTER_FILE
Write-Host "Current build_revision: $build_revision"
# Increment the counter
$new_build_revision = [int]$build_revision + 1
Write-Host "New build_revision: $new_build_revision"
# Save the new value to the file
$new_build_revision | Out-File $COUNTER_FILE
# Set the output variable for GitHub Actions
echo "build_revision=$new_build_revision" >> $env:GITHUB_OUTPUT
- name: Set agent into development mode
shell: pwsh
run: |
.\pipeline\scripts\Set_Development_Mode.ps1
- name: Test and Build the Icon Editor
shell: pwsh
# Put the dynamic variables at the step level, after "get_revision" is available
env:
build_id: ${{ github.run_number }}
build_revision: ${{ steps.get_revision.outputs.build_revision }}
build_version: 1.0.${{ github.run_number }}.${{ steps.get_revision.outputs.build_revision }}
run: |
.\pipeline\scripts\Build.ps1 -build_version $env:build_version
- name: Restore agent from development mode
shell: pwsh
run: |
.\pipeline\scripts\RevertDevelopmentMode.ps1
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: vi-package
path: 'builds/VI Package'
- name: Commit and Push Build Counter
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Increment build revision to ${{ steps.get_revision.outputs.build_revision }}'
file_pattern: '.github/buildCounter.txt'