-
Notifications
You must be signed in to change notification settings - Fork 9
151 lines (135 loc) · 5.21 KB
/
pull-request-ui.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Pull Request UI Build
on:
workflow_dispatch:
pull_request:
branches: [main]
env:
TARGET: Release
jobs:
get_version_code:
name: Get Version Code
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_version_code.outputs.version }}
build_number: ${{ steps.get_version_code.outputs.build_number }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Get Version Code
id: get_version_code
run: |
git fetch --depth=100 origin +refs/tags/*:refs/tags/*
TAG_NAME=$(git describe --tags `git rev-list --tags --max-count=1`) # v1.0.0
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
BUILD_NUMBER=$(echo $TAG_NAME | grep -oP '\d+$')
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT
VERSION="${TAG_NAME/v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
github: ${{ steps.filter.outputs.github }}
bindings: ${{ steps.filter.outputs.bindings }}
root: ${{ steps.filter.outputs.root }}
scripts: ${{ steps.filter.outputs.scripts }}
source: ${{ steps.filter.outputs.source }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
github:
- '.github/workflows/pull-request-ui.yml'
bindings:
- 'bindings/netstandard/**'
root:
- 'Dockerfile'
- 'Makefile'
scripts:
- 'scripts/**'
source:
- 'src/electionguard-ui/**'
build_and_test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
needs: [get_version_code, changes]
strategy:
fail-fast: false
matrix:
name: ["macOS", "windows-os"]
include:
- name: macOS
os: macOS-13
version: "14.2"
osFolder: "maccatalyst"
- name: windows-os
os: windows-2022
version: "latest"
osFolder: "windows"
steps:
- name: Configure Change Filter
id: filter
shell: bash
run: |
FILTER_ANY_CHANGE="false"
if [[ "${{ needs.changes.outputs.github }}" == "true" || "${{ needs.changes.outputs.bindings }}" == "true" || "${{ needs.changes.outputs.root }}" == "true" || "${{ needs.changes.outputs.scripts }}" == "true" || "${{ needs.changes.outputs.source }}" == "true" ]]; then
FILTER_ANY_CHANGE="true"
fi
echo "any=$FILTER_ANY_CHANGE" >> $GITHUB_OUTPUT
echo "github=${{ needs.changes.outputs.github }}" >> $GITHUB_OUTPUT
echo "bindings=${{ needs.changes.outputs.bindings }}" >> $GITHUB_OUTPUT
echo "root=${{ needs.changes.outputs.root }}" >> $GITHUB_OUTPUT
echo "scripts=${{ needs.changes.outputs.scripts }}" >> $GITHUB_OUTPUT
echo "source=${{ needs.changes.outputs.source }}" >> $GITHUB_OUTPUT
# Checkout
- name: Checkout Code
if: (steps.filter.outputs.any == 'true')
uses: actions/checkout@v4
- name: Change Directory
if: (steps.filter.outputs.any == 'true')
run: cd ${{ github.workspace }}
- name: Install .NET
if: (steps.filter.outputs.any == 'true')
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Update Mac Environment
if: (runner.os == 'macOS' && steps.filter.outputs.any == 'true')
run: |
ls -ls /Applications/
ls -ls $ANDROID_SDK_ROOT/ndk
sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app
- name: Configure Environment
if: (steps.filter.outputs.any == 'true')
run: make environment-ui
- name: Test UI
if: (steps.filter.outputs.bindings == 'true' || steps.filter.outputs.source == 'true')
env:
BUILD_NUMBER: ${{ needs.get_version_code.outputs.build_number }}
BUILD_VERSION: "${{needs.get_version_code.outputs.version}}"
APPCENTER_SECRET_MACOS: ${{ secrets.APPCENTER_SECRET_MACOS }}
APPCENTER_SECRET_UWP: ${{ secrets.APPCENTER_SECRET_UWP }}
run: make test-ui
- name: Clean UI
if: (steps.filter.outputs.bindings == 'true' || steps.filter.outputs.source == 'true')
run: make clean-ui
- name: Publish UI
if: (steps.filter.outputs.bindings == 'true' || steps.filter.outputs.source == 'true')
env:
BUILD_NUMBER: ${{ needs.get_version_code.outputs.build_number }}
BUILD_VERSION: "${{needs.get_version_code.outputs.version}}"
APPCENTER_SECRET_MACOS: ${{ secrets.APPCENTER_SECRET_MACOS }}
APPCENTER_SECRET_UWP: ${{ secrets.APPCENTER_SECRET_UWP }}
run: make publish-ui
- name: save build artifacts
if: (steps.filter.outputs.bindings == 'true' || steps.filter.outputs.source == 'true')
uses: actions/upload-artifact@v4
with:
name: electionguard-admin
retention-days: 7
path: ./publish/*