Skip to content

Commit fecf150

Browse files
authored
Add: [setup-vcpkg] action to setup vcpkg (#108)
1 parent 02a7b70 commit fecf150

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This repository contains several GitHub Actions and Workflows that help with the
66

77
- [annotation-check](annotation-check/): Check if any previous job in a workflow has any annotation.
88
- [checkout-pull-request](checkout-pull-request/): Checkout all commits of a Pull Request.
9+
- [setup_vcpkg](setup-vcpkg/): Install vcpkg and configure its cache.
910

1011
## Reusing Workflows
1112

setup-vcpkg/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# OpenTTD - Setup vcpkg
2+
3+
Install `vcpkg` and set it up to use NuGet for binary caching.
4+
Will install `mono` if the runner OS requires it, or if an install command is provided.
5+
6+
## Usage
7+
8+
```yaml
9+
- name: Setup vcpkg
10+
id: vcpkg
11+
uses: openttd/actions/setup-vcpkg@v6
12+
```

setup-vcpkg/action.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: 'Setup vcpkg'
2+
description: 'Installs vcpkg and initialises binary caching via NuGet'
3+
inputs:
4+
vcpkg-location:
5+
description: 'Where to install vcpkg'
6+
required: true
7+
default: '${{ runner.temp }}/vcpkg'
8+
mono-install-command:
9+
description: 'Command to run to install mono'
10+
required: false
11+
default: ${{ runner.os == 'macOS' && 'brew install mono' || runner.os == 'Linux' && 'sudo apt-get install -y --no-install-recommends mono-complete' || '' }}
12+
outputs:
13+
vcpkg-location:
14+
description: 'Where vcpkg is installed'
15+
value: ${{ inputs.vcpkg-location }}
16+
vcpkg:
17+
description: 'The vcpkg executable'
18+
value: '${{ inputs.vcpkg-location }}/vcpkg'
19+
vcpkg-cmake:
20+
description: 'The vcpkg cmake toolchain'
21+
value: '${{ inputs.vcpkg-location }}/scripts/buildsystems/vcpkg.cmake'
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
- name: Install vcpkg
27+
shell: bash
28+
run: |
29+
git clone https://github.com/microsoft/vcpkg "${{ inputs.vcpkg-location }}"
30+
cd "${{ inputs.vcpkg-location }}"
31+
./bootstrap-vcpkg.$(if [ "${{ runner.os }}" = "Windows" ]; then echo "bat"; else echo "sh"; fi) -disableMetrics
32+
33+
- name: Install mono
34+
if: inputs.mono-install-command
35+
shell: bash
36+
run: |
37+
${{ inputs.mono-install-command }}
38+
39+
- name: Setup NuGet Credentials
40+
shell: bash
41+
env:
42+
FEED_URL: 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json'
43+
run: |
44+
cd "${{ inputs.vcpkg-location }}"
45+
${{ inputs.mono-install-command && 'mono' }} $(./vcpkg fetch nuget | tail -n 1) \
46+
sources add \
47+
-source "${{ env.FEED_URL }}" \
48+
-storepasswordincleartext \
49+
-name "GitHub" \
50+
-username "${{ github.repository_owner }}" \
51+
-password "${{ github.token }}"
52+
${{ inputs.mono-install-command && 'mono' }} $(./vcpkg fetch nuget | tail -n 1) \
53+
setapikey "${{ github.token }}" \
54+
-source "${{ env.FEED_URL }}"
55+
56+
- name: Setup vcpkg caching
57+
uses: actions/github-script@v8
58+
with:
59+
script: |
60+
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;nuget,GitHub,readwrite')
61+

0 commit comments

Comments
 (0)