forked from johnwason/vcpkg-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
230 lines (209 loc) · 9.59 KB
/
action.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: vcpkg-action
description: Simple action to run vcpkg and cache results
inputs:
pkgs:
description: "List of packages to build, separated by spaces. Cannot be used with manifest-dir"
required: false
triplet:
description: "vcpkg triplet to use"
required: true
extra-args:
description: "Extra vcpkg install command line args (optional)"
required: false
default: ''
cache-key:
description: "Additional cache key component (optional)"
required: false
disable-cache:
description: "Disable cache (useful for release builds)"
required: false
default: 'false'
revision:
description: "vcpkg revision to checkout."
required: false
default: ''
token:
description: "GitHub token to authenticate API requests. Recommended to use github.token "
required: false
default: ''
manifest-dir:
description: Directory containing vcpkg.json manifest file. Cannot be used with pkgs.
required: false
default: ''
github-binarycache:
description: "Use vcpkg built-in GitHub binary caching. If not specified, will use the dry-run based file cache."
required: false
default: ''
fetch-depth:
description: "Fetch depth for vcpkg checkout"
required: false
default: "1"
vcpkg-subdir:
description: "The subdirectory into which to install VCPKG"
required: false
default: "vcpkg"
outputs:
vcpkg-cmake-config:
description: Configure options for cmake to use vcpkg
value: ${{ steps.vcpkg-cmake-config.outputs.vcpkg-cmake-config }}
vcpkg-cache-hash:
description: Hash of the vcpkg cache key
value: ${{ steps.vcpkg-cmake-config.outputs.vcpkg-cache-hash }}
runs:
using: "composite"
steps:
- name: Get latest Github release
uses: cardinalby/git-get-release-action@v1
id: get-latest-vcpkg-release
env:
GITHUB_TOKEN: ${{ inputs.token }}
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
with:
latest: true
repo: microsoft/vcpkg
prerelease: false
draft: false
- name: Determine checkout tag
shell: bash
id: determine-checkout-revision
run: |
if [[ "${{ inputs.revision }}" != "" ]]; then
echo "vcpkg-revision=${{ inputs.revision }}" >> $GITHUB_OUTPUT
else
echo "vcpkg-revision=${{ steps.get-latest-vcpkg-release.outputs.tag_name }}" >> $GITHUB_OUTPUT
fi
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: checkout-vcpkg
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/${{ inputs.vcpkg-subdir }}
repository: microsoft/vcpkg
ref: '${{ steps.determine-checkout-revision.outputs.vcpkg-revision }}'
fetch-depth: ${{ inputs.fetch-depth }}
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: bootstrap-vcpkg-win
if: runner.os == 'Windows'
working-directory: ${{ github.workspace }}\${{ inputs.vcpkg-subdir }}
run: bootstrap-vcpkg.bat
shell: cmd
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: bootstrap-vcpkg-unix
if: runner.os != 'Windows'
working-directory: ${{ github.workspace }}/${{ inputs.vcpkg-subdir }}
run: ./bootstrap-vcpkg.sh
shell: bash
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: set-binarycache-variable
if: inputs.github-binarycache != 'true' && inputs.github-binarycache != true
shell: bash
run: |
echo VCPKG_DEFAULT_BINARY_CACHE='${{ github.workspace }}/vcpkg_cache' >> $GITHUB_ENV
mkdir -p '${{ github.workspace }}/vcpkg_cache'
#
# DRY RUNs : Use Dry run output as key for cache hit or miss later
#
- name: vcpkg-dry-run-win
if: runner.os == 'Windows' && inputs.manifest-dir == '' && inputs.github-binarycache != 'true' && inputs.github-binarycache != true
working-directory: ${{ github.workspace }}\${{ inputs.vcpkg-subdir }}
shell: powershell
run: >
& "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg.exe" install --dry-run --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} ${{ inputs.pkgs }}
| Tee-Object -FilePath vcpkg_dry_run.txt
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: vcpkg-dry-run-unix
if: runner.os != 'Windows' && inputs.manifest-dir == '' && inputs.github-binarycache != 'true' && inputs.github-binarycache != true
working-directory: ${{ github.workspace }}/${{ inputs.vcpkg-subdir }}
shell: bash
run: >
"${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg" install --dry-run --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} ${{ inputs.pkgs }}
| tee vcpkg_dry_run.txt
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: vcpkg-dry-run-win-manifest
if: runner.os == 'Windows' && inputs.manifest-dir != '' && inputs.github-binarycache != 'true' && inputs.github-binarycache != true
working-directory: ${{ github.workspace }}\${{ inputs.vcpkg-subdir }}
shell: powershell
run: >
& "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg.exe" install --dry-run --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }}
--x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}\${{ inputs.vcpkg-subdir }}\installed
| Tee-Object -FilePath vcpkg_dry_run.txt
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: vcpkg-dry-run-unix-manifest
if: runner.os != 'Windows' && inputs.manifest-dir != '' && inputs.github-binarycache != 'true' && inputs.github-binarycache != true
working-directory: ${{ github.workspace }}/${{ inputs.vcpkg-subdir }}
shell: bash
run: |
"${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg" install --dry-run --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} \
--x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/installed | tee vcpkg_dry_run.txt
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
##########################
# CACHE
#
- name: cache-vcpkg-archives
if: ${{ inputs.disable_cache != 'true' }} && inputs.github-binarycache != 'true' && inputs.github-binarycache != true
id: cache-vcpkg-archives
uses: pat-s/always-upload-cache@v3
with:
path: ${{ github.workspace }}/vcpkg_cache
key: ${{ runner.os }}-${{ inputs.triplet }}-vcpkg-${{ hashFiles('${{ inputs.vcpkg-subdir }}/vcpkg_dry_run.txt') }}-${{ inputs.cache-key }}
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: Export GitHub Actions cache environment variables
if: (inputs.disable_cache != 'true' && inputs.disable_cache != true) && (inputs.github-binarycache == 'true' || inputs.github-binarycache == true)
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
core.exportVariable('VCPKG_BINARY_SOURCES', "clear;x-gha,readwrite");
##########################
# Build / vcpkg install
#
- name: build-vcpkg-win-nomanifest
if: runner.os == 'Windows' && inputs.manifest-dir == ''
shell: cmd
working-directory: ${{ github.workspace }}\${{ inputs.vcpkg-subdir }}
run: |
"${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg.exe" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} ${{ inputs.pkgs }}
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: build-vcpkg-unix-no-manifest
if: runner.os != 'Windows' && inputs.manifest-dir == ''
shell: bash
working-directory: ${{ github.workspace }}/${{ inputs.vcpkg-subdir }}
run: |
"${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} ${{ inputs.pkgs }}
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: build-vcpkg-win
if: runner.os == 'Windows' && inputs.manifest-dir != ''
shell: cmd
working-directory: ${{ github.workspace }}\${{ inputs.vcpkg-subdir }}
run: >
"${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg.exe" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }}
--x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/installed
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: build-vcpkg-unix
if: runner.os != 'Windows' && inputs.manifest-dir != ''
shell: bash
working-directory: ${{ github.workspace }}/${{ inputs.vcpkg-subdir }}
run: >
( "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/vcpkg" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }}
--x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/installed )
|| ( (echo '*********>>>>>DUMPING FILE>>>>>') && ( cat ./installed/vcpkg/issue_body.md ) && (echo '<<<<<*********') && ( false ))
env:
VCPKG_ROOT: "${{ github.workspace }}/${{ inputs.vcpkg-subdir }}"
- name: vcpkg cmake configure
shell: bash
id: vcpkg-cmake-config
run: |
echo "vcpkg-cmake-config=-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ inputs.vcpkg-subdir }}/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ inputs.triplet }}" >> $GITHUB_OUTPUT
echo "vcpkg-cache-hash=${{ hashFiles('${{ inputs.vcpkg-subdir }}/vcpkg_dry_run.txt') }}-${{ inputs.cache-key }}" >> $GITHUB_OUTPUT