-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (93 loc) · 4.02 KB
/
build.yaml
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
name: Build
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- '**'
tags:
- 'v*'
pull_request:
branches:
- main
env:
PACKAGE_NAME: hello
CONAN_REPO: my-conan-repo
CONAN_REPO_URL: https://wangyoucao577.jfrog.io/artifactory/api/conan/test-conan-local
CONAN_CHANNEL_FOR_RELEASE: stable
CONAN_CHANNEL_BY_DEFAULT: ci
jobs:
calc-version:
runs-on: ubuntu-latest
outputs:
packageSemVer: ${{ env.PACKAGE_SEMVER }}
conanUserChannel: ${{ env.CONAN_PACKAGE_USER_CHANNEL }}
conanReference: ${{ env.CONAN_PACKAGE_REFERENCE }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
# use gitversion to determine next version
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.9
with:
versionSpec: 'x.x.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.9
with:
useConfigFile: true
- name: Display SemVer
run: |
echo "SemVer: $GITVERSION_SEMVER"
- name: Set envs for branchs/pr
if: ${{ ( github.event_name == 'push' && !contains(github.ref, 'tags')) || github.event_name == 'pull_request' }}
run: |
echo PACKAGE_SEMVER=${{ steps.gitversion.outputs.semVer }}+${{ steps.gitversion.outputs.shortSha }} >> ${GITHUB_ENV}
echo CONAN_PACKAGE_USER_CHANNEL=${{ github.actor }}/${{ env.CONAN_CHANNEL_BY_DEFAULT }} >> ${GITHUB_ENV}
- name: Set envs for tags
if: ${{ github.event_name == 'push' && contains(github.ref, 'tags') }}
run: |
echo PACKAGE_SEMVER=${{ steps.gitversion.outputs.semVer }} >> ${GITHUB_ENV}
echo CONAN_PACKAGE_USER_CHANNEL=${{ github.actor }}/${{ env.CONAN_CHANNEL_FOR_RELEASE }} >> ${GITHUB_ENV}
- name: Set CONAN_PACKAGE_REFERENCE if user_channel available
if: ${{ env.CONAN_PACKAGE_USER_CHANNEL }}
run: echo CONAN_PACKAGE_REFERENCE=${{ env.PACKAGE_NAME }}/${{ env.PACKAGE_SEMVER }}@${{ env.CONAN_PACKAGE_USER_CHANNEL }} >> ${GITHUB_ENV}
- name: Set CONAN_PACKAGE_REFERENCE if user_channel NOT available
if: ${{ !env.CONAN_PACKAGE_USER_CHANNEL }}
run: echo CONAN_PACKAGE_REFERENCE=${{ env.PACKAGE_NAME }}/${{ env.PACKAGE_SEMVER }} >> ${GITHUB_ENV}
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
needs: calc-version
env:
PACKAGE_SEMVER: ${{ needs.calc-version.outputs.packageSemVer }}
CONAN_PACKAGE_USER_CHANNEL: ${{ needs.calc-version.outputs.conanUserChannel }}
CONAN_PACKAGE_REFERENCE: ${{ needs.calc-version.outputs.conanReference }}
steps:
- name: Checkout
uses: actions/checkout@v2
# use conan to build and store
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
- name: Conan version
run: echo "${{ steps.conan.outputs.version }}"
- name: Build Static
run: |
conan create . ${{ env.CONAN_PACKAGE_USER_CHANNEL }}
conan create . ${{ env.CONAN_PACKAGE_USER_CHANNEL }} -s build_type=Debug
- name: Build Shared
if: ${{ !contains(matrix.os, 'macos') && !contains(matrix.os, 'windows') }} # disable shared on macos/windows at the moment due to poco doesn't have pre-built shared libraries.
run: |
conan create . ${{ env.CONAN_PACKAGE_USER_CHANNEL }} -o hello:shared=True
conan create . ${{ env.CONAN_PACKAGE_USER_CHANNEL }} -s build_type=Debug -o hello:shared=True
- name: Upload # ignore on pull_request
if: ${{ github.event_name != 'pull_request' }}
run: |
conan remote add ${{ env.CONAN_REPO }} ${{ env.CONAN_REPO_URL }}
conan user -p ${{ secrets.MY_JFROG_IO_ACCESS_TOKEN }} -r ${{ env.CONAN_REPO }} ${{ secrets.MY_JFROG_IO_USERNAME }}
conan upload ${{ env.CONAN_PACKAGE_REFERENCE }} -r ${{ env.CONAN_REPO }} --all