-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
187 lines (187 loc) · 8.24 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
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 command line args (optional)"
required: false
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"
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 }}/vcpkg"
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 }}/vcpkg"
- name: checkout-vcpkg
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/vcpkg
repository: microsoft/vcpkg
ref: '${{ steps.determine-checkout-revision.outputs.vcpkg-revision }}'
fetch-depth: ${{ inputs.fetch-depth }}
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- name: bootstrap-vcpkg-win
if: runner.os == 'Windows'
working-directory: ${{ github.workspace }}\vcpkg
run: bootstrap-vcpkg.bat
shell: cmd
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- name: bootstrap-vcpkg-unix
if: runner.os != 'Windows'
working-directory: ${{ github.workspace }}/vcpkg
run: ./bootstrap-vcpkg.sh
shell: bash
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- 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'
- name: vcpkg-dry-run-win
if: runner.os == 'Windows' && inputs.manifest-dir == '' && inputs.github-binarycache != 'true' && inputs.github-binarycache != true
working-directory: ${{ github.workspace }}\vcpkg
shell: powershell
run: |
& "${{ github.workspace }}/vcpkg/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 }}/vcpkg"
- name: vcpkg-dry-run-unix
if: runner.os != 'Windows' && inputs.manifest-dir == '' && inputs.github-binarycache != 'true' && inputs.github-binarycache != true
working-directory: ${{ github.workspace }}/vcpkg
shell: bash
run: |
"${{ github.workspace }}/vcpkg/vcpkg" install --dry-run --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} ${{ inputs.pkgs }} | tee vcpkg_dry_run.txt
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- 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 }}\vcpkg
shell: powershell
run: |
& "${{ github.workspace }}/vcpkg/vcpkg.exe" install --dry-run --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} --x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}\vcpkg\installed | Tee-Object -FilePath vcpkg_dry_run.txt
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- 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 }}/vcpkg
shell: bash
run: |
"${{ github.workspace }}/vcpkg/vcpkg" install --dry-run --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} --x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}/vcpkg/installed | tee vcpkg_dry_run.txt
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- 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('vcpkg/vcpkg_dry_run.txt') }}-${{ inputs.cache-key }}
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- 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");
- name: build-vcpkg-win
if: runner.os == 'Windows' && inputs.manifest-dir == ''
shell: cmd
working-directory: ${{ github.workspace }}\vcpkg
run: |
"${{ github.workspace }}/vcpkg/vcpkg.exe" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} ${{ inputs.pkgs }}
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- name: build-vcpkg-unix
if: runner.os != 'Windows' && inputs.manifest-dir == ''
shell: bash
working-directory: ${{ github.workspace }}/vcpkg
run: |
"${{ github.workspace }}/vcpkg/vcpkg" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} ${{ inputs.pkgs }}
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- name: build-vcpkg-win
if: runner.os == 'Windows' && inputs.manifest-dir != ''
shell: cmd
working-directory: ${{ github.workspace }}\vcpkg
run: |
"${{ github.workspace }}/vcpkg/vcpkg.exe" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} --x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}/vcpkg/installed
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- name: build-vcpkg-unix
if: runner.os != 'Windows' && inputs.manifest-dir != ''
shell: bash
working-directory: ${{ github.workspace }}/vcpkg
run: |
"${{ github.workspace }}/vcpkg/vcpkg" install --triplet ${{ inputs.triplet }} ${{ inputs.extra-args }} --x-manifest-root=${{ inputs.manifest-dir }} --x-install-root=${{ github.workspace }}/vcpkg/installed
env:
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
- name: vcpkg cmake configure
shell: bash
id: vcpkg-cmake-config
run: |
echo "vcpkg-cmake-config=-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ inputs.triplet }} -DVCPKG_MANIFEST_MODE=OFF" >> $GITHUB_OUTPUT
echo "vcpkg-cache-hash=${{ hashFiles('vcpkg/vcpkg_dry_run.txt') }}-${{ inputs.cache-key }}" >> $GITHUB_OUTPUT