-
Notifications
You must be signed in to change notification settings - Fork 24
177 lines (152 loc) · 6.75 KB
/
build.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Build Project
on:
pull_request:
push:
branches:
- "**" # trigger the workflow on any branch push event
paths:
- "**" # trigger the workflow on any file change
workflow_dispatch:
jobs:
build:
concurrency:
group: ${{ github.ref }}
strategy:
matrix:
java: ["17","21"]
maven: ["3.9.2"]
node: ["16.20.2"]
node_vmware_samples: ["14.17.1"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout vmware/build-tools-for-vmware-aria repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Setup Maven Action
uses: s4u/[email protected]
with:
java-version: ${{ matrix.java }}
java-distribution: "temurin"
maven-version: ${{ matrix.maven }}
- name: Install xmllint
run: sudo apt-get install libxml2-utils
- name: Install [email protected]
run: npm install -g [email protected]
- name: Print versions
run: |
echo "-------------------------------------------"
echo "-----------< TOOLS AND VERSIONS >----------"
git --version
java -version 2>&1
mvn --version
echo "node version: $(node --version)"
echo "npm version: $(npm --version)"
pip3 --version
python --version
pwsh --version
gpg --version | head -n 1
openssl version
xmllint --version 2>&1 | head -n 1
echo "Installed global npm packages:"
npm list -g --depth=0
echo "-------------------------------------------"
echo "-------------------------------------------"
- name: Get IAC version
run: echo "IAC_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)" >> $GITHUB_ENV
- name: Replace variables in settings.xml
run: |
sed -i "s/{{ IAC_VERSION }}/${{ env.IAC_VERSION }}/g" .m2/settings.xml
sed -i "s/{{ OSSRH_USERNAME }}/${{ secrets.OSSRH_USERNAME }}/g" .m2/settings.xml
sed -i "s/{{ OSSRH_PASSWORD }}/${{ secrets.OSSRH_PASSWORD }}/g" .m2/settings.xml
- name: Import GPG Key
if: ${{ github.ref == 'refs/heads/main' }}
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set default env GPG_PASSPHRASE
run: echo "GPG_PASSPHRASE=''" >> $GITHUB_ENV
- name: Set env GPG_PASSPHRASE if main
if: ${{ github.ref == 'refs/heads/main' }}
run: echo "GPG_PASSPHRASE=${{ secrets.GPG_PASSPHRASE }}" >> $GITHUB_ENV
- name: Set MVN_BUILD_COMMAND
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
MVN_BUILD_COMMAND="install deploy"
else
MVN_BUILD_COMMAND="install"
fi
echo "MVN_BUILD_COMMAND is $MVN_BUILD_COMMAND"
echo "MVN_BUILD_COMMAND=$MVN_BUILD_COMMAND" >> $GITHUB_ENV
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build 'iac' - parent IAC project ONLY
run: mvn clean ${{ env.MVN_BUILD_COMMAND }} -f pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml -pl .
- name: Build 'keystore-example'
run: mvn clean ${{ env.MVN_BUILD_COMMAND }} -f common/keystore-example/pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build 'npmlib'
run: mvn clean ${{ env.MVN_BUILD_COMMAND }} -f maven/npmlib/pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build 'iac'
run: mvn clean ${{ env.MVN_BUILD_COMMAND }} -f pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build 'base-package'
run: mvn clean ${{ env.MVN_BUILD_COMMAND }} -f maven/base-package/pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build 'packages'
run: mvn clean ${{ env.MVN_BUILD_COMMAND }} -f packages/pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build 'typescript-project-all'
run: mvn clean ${{ env.MVN_BUILD_COMMAND }} -f maven/typescript-project-all/pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build 'repository'
run: mvn clean package -f maven/repository/pom.xml --batch-mode -Dgpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Checkout vmware-samples/build-tools-for-vmware-aria-samples repository
uses: actions/checkout@v3
with:
repository: vmware-samples/build-tools-for-vmware-aria-samples
ref: main
path: build-tools-for-vmware-aria-samples
- name: Use Node.js ${{ matrix.node_vmware_samples }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_vmware_samples }}
- name: Build vmware-samples/build-tools-for-vmware-aria-samples project repository
run: |
pushd build-tools-for-vmware-aria-samples/
./switch_parent_version.sh ${{ env.IAC_VERSION }}
mvn clean package install -Pbundle-with-installer --batch-mode -s ../.m2/settings.xml
popd
rm -rf build-tools-for-vmware-aria-samples/
- name: Set artifact file name
if: ${{ !contains(env.IAC_VERSION, '-SNAPSHOT') }}
run: echo "ARTIFACT_FILE_NAME=build-tools-for-vmware-aria-${{ env.IAC_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- name: Package all artifacts
if: ${{ !contains(env.IAC_VERSION, '-SNAPSHOT') }}
run: |
cp maven/repository/target/iac-maven-repository.zip .
tar -zcvf "${{ env.ARTIFACT_FILE_NAME }}.zip" iac-maven-repository.zip docs/ "LICENSE.txt"
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ !contains(env.IAC_VERSION, '-SNAPSHOT') }}
with:
name: ${{ env.ARTIFACT_FILE_NAME }}
path: ${{ env.ARTIFACT_FILE_NAME }}.zip
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Build Results
needs: [build]
steps:
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}