-
Notifications
You must be signed in to change notification settings - Fork 47
147 lines (146 loc) · 5.77 KB
/
build_libs.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
name: build libraries
on:
push:
branches:
- develop
pull_request:
branches:
- develop
workflow_dispatch: {}
jobs:
changes:
runs-on: ubuntu-22.04
outputs:
tklog: ${{ steps.filter.outputs.tklog }}
tkassert: ${{ steps.filter.outputs.tkassert }}
tkrng: ${{ steps.filter.outputs.tkrng }}
tktokenswap: ${{ steps.filter.outputs.tktokenswap }}
tkwsm: ${{ steps.filter.outputs.tkwsm }}
libs: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v3
- uses: dorny/[email protected]
id: filter
with:
base: ${{ github.ref }}
filters: |
tklog:
- 'libs/tklog/conanfile.py'
tkassert:
- 'libs/tkassert/conanfile.py'
tkrng:
- 'libs/tkrng/conanfile.py'
tktokenswap:
- 'libs/tktokenswap/conanfile.py'
tkwsm:
- 'libs/tkwsm/conanfile.py'
build_libraries:
name: build library
needs: changes
if: ${{ needs.changes.outputs.libs != '[]' && needs.changes.outputs.libs != '' }}
strategy:
matrix:
os: ['ubuntu-22.04', 'macos-12', 'windows-2022']
lib: ${{ fromJson(needs.changes.outputs.libs) }}
build_type: ['Release', 'Debug']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: normalize line endings in conanfile and src directory
if: matrix.os == 'windows-2022'
# This is necessary to ensure consistent revisions across platforms.
# Conan's revision hash is composed of hashes all the exported files, so
# we must normalize the line endings in these.
run: |
$lib_files = Get-ChildItem "libs/${{ matrix.lib }}" -File -Recurse
foreach ($f in $lib_files) {
$normalized_file = [IO.File]::ReadAllText($f) -replace "`r`n", "`n"
[IO.File]::WriteAllText($f, $normalized_file)
}
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
run: conan create -s build_type=${{ matrix.build_type }} -o boost/*:header_only=True libs/${{ matrix.lib }} --build=missing --user=tket --channel=stable --format json > ${{ matrix.lib }}.json
- name: build shared ${{ matrix.lib }}
if: matrix.lib == 'tklog'
run: conan create -s build_type=${{ matrix.build_type }} -o boost/*:header_only=True -o ${{ matrix.lib }}/*:shared=True libs/${{ matrix.lib }} --build=missing --user=tket --channel=stable
- name: authenticate to repository
run: conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }}
- name: get version
shell: bash
run: |
lib_label=`./libver ${{ matrix.lib }}.json ${{ matrix.lib }}`
echo "LIB_LABEL=${lib_label}" >> $GITHUB_ENV
- name: upload package
if: github.event_name == 'push'
run: conan upload ${{ env.LIB_LABEL }} -r=tket-libs
macos-m1:
name: build library (macos-m1)
needs: changes
if: ${{ needs.changes.outputs.libs != '[]' && needs.changes.outputs.libs != '' }}
runs-on: ['self-hosted', 'macOS', 'ARM64']
strategy:
matrix:
lib: ${{ fromJson(needs.changes.outputs.libs) }}
build_type: ['Release', 'Debug']
steps:
- uses: actions/checkout@v3
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect --force
- name: set remotes
run: conan remote add --force tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
run: conan create -s build_type=${{ matrix.build_type }} -o boost/*:header_only=True libs/${{ matrix.lib }} --build=missing --user=tket --channel=stable --format json > ${{ matrix.lib }}.json
- name: authenticate to repository
run: conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }}
- name: get version
run: |
lib_label=`./libver ${{ matrix.lib }}.json ${{ matrix.lib }}`
echo "LIB_LABEL=${lib_label}" >> $GITHUB_ENV
- name: upload package
if: github.event_name == 'push'
run: conan upload ${{ env.LIB_LABEL }} -r=tket-libs
- name: unauthenticate
if: always()
run: conan remote logout tket-libs
manylinux:
name: build library (manylinux)
needs: changes
if: ${{ needs.changes.outputs.libs != '[]' && needs.changes.outputs.libs != '' }}
runs-on: ubuntu-22.04
strategy:
matrix:
lib: ${{ fromJson(needs.changes.outputs.libs) }}
env:
UPLOAD_PACKAGE: "NO"
steps:
- uses: actions/checkout@v3
- name: set up container
run: |
docker create --name linux_build -i -v /:/host quay.io/pypa/manylinux2014_x86_64:latest /bin/bash
docker cp ./libs/${{ matrix.lib }} linux_build:/
docker cp ./libver linux_build:/
docker cp ./.github/workflows/linuxbuildlib linux_build:/
- name: determine whether to upload package
if: github.event_name == 'push'
run: echo "UPLOAD_PACKAGE=YES" >> ${GITHUB_ENV}
- name: build ${{ matrix.lib }}
run: |
docker start linux_build
cat <<EOF > env-vars
TKLIB=${{ matrix.lib }}
UPLOAD_PACKAGE=${UPLOAD_PACKAGE}
JFROG_ARTIFACTORY_TOKEN_3=${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }}
JFROG_ARTIFACTORY_USER_3=${{ secrets.JFROG_ARTIFACTORY_USER_3 }}
EOF
docker exec --env-file env-vars linux_build /bin/bash -c "/linuxbuildlib"