|
| 1 | +# Copyright 2024 - 2025 Khalil Estell and the libhal contributors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: 📦 Conan Package & Upload |
| 16 | + |
| 17 | +on: |
| 18 | + workflow_call: |
| 19 | + inputs: |
| 20 | + library: |
| 21 | + type: string |
| 22 | + default: ${{ github.event.repository.name }} |
| 23 | + repo: |
| 24 | + type: string |
| 25 | + default: ${{ github.repository }} |
| 26 | + conan_version: |
| 27 | + type: string |
| 28 | + default: 2.18.0 |
| 29 | + config2_version: |
| 30 | + type: string |
| 31 | + default: main |
| 32 | + version: |
| 33 | + type: string |
| 34 | + default: latest # "latest" means (do not upload) |
| 35 | + runner_os: |
| 36 | + type: string |
| 37 | + required: true |
| 38 | + arch: |
| 39 | + type: string |
| 40 | + required: true |
| 41 | + os: |
| 42 | + type: string |
| 43 | + required: true |
| 44 | + compiler_profile: |
| 45 | + type: string |
| 46 | + required: true |
| 47 | + dir: # Directory where the conan package exists |
| 48 | + type: string |
| 49 | + default: . |
| 50 | + remote_url: # Path to conan package repo |
| 51 | + type: string |
| 52 | + default: "" |
| 53 | + |
| 54 | + secrets: |
| 55 | + conan_remote_user: |
| 56 | + required: false |
| 57 | + conan_remote_password: |
| 58 | + required: false |
| 59 | +jobs: |
| 60 | + package_and_upload: |
| 61 | + runs-on: ${{ inputs.runner_os }} |
| 62 | + env: |
| 63 | + VERBOSE: 1 |
| 64 | + CONAN_REMOTE_USER: ${{ secrets.conan_remote_user }} |
| 65 | + CONAN_REMOTE_PASSWORD: ${{ secrets.conan_remote_password }} |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4.1.1 |
| 68 | + if: ${{ inputs.version != 'latest' }} |
| 69 | + with: |
| 70 | + submodules: true |
| 71 | + repository: ${{ inputs.repo }} |
| 72 | + ref: ${{ inputs.version }} |
| 73 | + |
| 74 | + - uses: actions/checkout@v4.1.1 |
| 75 | + if: ${{ inputs.version == 'latest' }} |
| 76 | + with: |
| 77 | + submodules: true |
| 78 | + repository: ${{ inputs.repo }} |
| 79 | + |
| 80 | + - name: 📥 Install Conan ${{ inputs.conan_version }} |
| 81 | + run: pipx install conan==${{ inputs.conan_version }} |
| 82 | + |
| 83 | + - name: 🔍 conan version |
| 84 | + run: conan --version |
| 85 | + |
| 86 | + - name: 📡 Create and setup default profile |
| 87 | + run: conan profile detect --force |
| 88 | + |
| 89 | + - name: 📡 Add conan libhal remote |
| 90 | + run: conan remote add libhal https://libhal.jfrog.io/artifactory/api/conan/trunk-conan |
| 91 | + |
| 92 | + - name: 📡 Add conan user remote-package-repo |
| 93 | + if: ${{ inputs.remote_url != '' }} |
| 94 | + run: conan remote add --force remote-package-repo ${{ inputs.remote_url }} |
| 95 | + # We use --force to allow the remote-package-repo to also be the libhal |
| 96 | + # repo. |
| 97 | + |
| 98 | + - name: 📡 Install libhal settings_user.yml |
| 99 | + run: conan config install https://github.com/libhal/conan-config2.git --args="-b ${{ inputs.config2_version }}" |
| 100 | + |
| 101 | + - name: 📦 Create `Debug` package for ${{ inputs.profile }} |
| 102 | + run: conan create ${{ inputs.dir }} -s:h build_type=Debug -s:h os=${{ inputs.os }} -s:h arch=${{ inputs.arch }} --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing |
| 103 | + |
| 104 | + - name: 📦 Create `MinSizeRel` package for ${{ inputs.profile }} |
| 105 | + run: conan create ${{ inputs.dir }} -s:h build_type=MinSizeRel -s:h os=${{ inputs.os }} -s:h arch=${{ inputs.arch }} --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing |
| 106 | + |
| 107 | + - name: 📦 Create `Release` package for ${{ inputs.profile }} |
| 108 | + run: conan create ${{ inputs.dir }} -s:h build_type=Release -s:h os=${{ inputs.os }} -s:h arch=${{ inputs.arch }} --version=${{ inputs.version }} -pr:h ${{ inputs.compiler_profile }} --build=missing |
| 109 | + |
| 110 | + - name: 📡 Sign into Conan Package Repository |
| 111 | + if: ${{ inputs.version != 'latest' && inputs.remote_url != '' && env.CONAN_REMOTE_USER != '' && env.CONAN_REMOTE_PASSWORD != '' }} |
| 112 | + run: conan remote login -p ${{ secrets.conan_remote_password }} remote-package-repo ${{ secrets.conan_remote_user }} |
| 113 | + |
| 114 | + - name: 🆙 Upload package version ${{ inputs.version }} to conan repo |
| 115 | + if: ${{ inputs.version != 'latest' && inputs.remote_url != '' }} |
| 116 | + run: conan upload "${{ inputs.library }}/${{ inputs.version }}" --confirm -r=remote-package-repo |
0 commit comments