added configure conan (#20) #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
workflow_call: | |
inputs: | |
public_artifactory: | |
type: boolean | |
default: false | |
os: | |
required: true | |
type: string | |
default: ubuntu-22.04 | |
compiler: | |
type: string | |
default: clang-17 | |
cmake-version: | |
type: string | |
default: 3.24.0 | |
conan-version: | |
type: string | |
default: 2.3.0 | |
conan-options: | |
type: string | |
use-tag: # if true an existing tag/release is update; otherwise the job fails. If true the job will also fail if the tag doesn't match the version reported via conan. | |
type: boolean | |
default: false | |
secrets: | |
CONAN_USER: | |
required: true | |
CONAN_PW: | |
required: true | |
jobs: | |
publish-release: | |
name: Creates a release for the current version defined in CMake and uploads a Conan package to conan.dice-research.org. Fails if release for the version exists already. | |
defaults: | |
run: | |
shell: bash | |
runs-on: ${{ inputs.os }} | |
steps: | |
- name: Fail fast if use-tag is used without a tag | |
if: ${{ inputs.use-tag && github.ref_type != 'tag' }} | |
run: exit 1 | |
# setup env | |
- name: Install tools and requirements | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq python3 python3-pip | |
- name: Add repos for for gcc-13 and clang-16,17 | |
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt | |
- name: Ensure stdlib version | |
run: | | |
sudo apt-get install -y libstdc++-13-dev | |
- name: Get minimum cmake version | |
uses: lukka/get-cmake@latest | |
with: | |
cmakeVersion: ${{ inputs.cmake-version }} | |
- name: Install compiler | |
id: install_cc | |
uses: rlalik/[email protected] | |
with: | |
compiler: ${{ inputs.compiler }} | |
- name: Install mold | |
uses: rui314/setup-mold@v1 | |
- name: Install conan | |
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan | |
with: | |
conan-version: ${{ inputs.conan-version }} | |
- name: add conan user | |
run: | | |
conan remote add dice-group https://conan.dice-research.org/artifactory/api/conan/tentris | |
conan remote login -p "${{ secrets.CONAN_PW }}" dice-group "${{ secrets.CONAN_USER }}" | |
conan remote add tentris-private https://conan.dice-research.org/artifactory/api/conan/tentris-private | |
conan remote login -p "${{ secrets.CONAN_PW }}" tentris-private "${{ secrets.CONAN_USER }}" | |
- name: Cache conan data | |
id: cache-conan | |
uses: actions/cache@v3 | |
with: | |
path: ~/.conan2/p | |
key: ${{ inputs.os }}-${{ inputs.compiler }}-conan-reusable-workflow-release | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Collect package information | |
shell: bash | |
run: | | |
pkg_name=$(conan inspect --format json . | jq -r '.name') | |
pkg_ver=$(conan inspect --format json . | jq -r '.version') | |
echo "conan_package_version=${pkg_ver}" >> $GITHUB_ENV | |
echo "conan_package_identifier=${pkg_name}/${pkg_ver}" >> $GITHUB_ENV | |
- name: Fail if use-tag and tag is not equal to package version from conan inspect | |
if: ${{ inputs.use-tag && github.ref_name != format('v{0}', env.conan_package_version) }} | |
run: exit 1 | |
- name: Create github release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: v${{ env.conan_package_version }} | |
allowUpdates: ${{ inputs.use-tag }} | |
- name: Create Package | |
env: | |
CC: ${{ steps.install_cc.outputs.cc }} | |
CXX: ${{ steps.install_cc.outputs.cxx }} | |
run: | | |
(conan remove -f "${{ env.conan_package_identifier }}:*" || true) | |
conan create --build missing ${{ inputs.conan-options }} . | |
- name: Select public artifactory for upload | |
if: ${{ fromJSON(inputs.public_artifactory) }} | |
run: | | |
echo "remote_artifactory_name=dice-group" >> $GITHUB_ENV | |
- name: Select private artifactory for upload | |
if: ${{ !fromJSON(inputs.public_artifactory) }} | |
run: | | |
echo "remote_artifactory_name=tentris-private" >> $GITHUB_ENV | |
- name: Upload to artifactory | |
run: | | |
conan upload "${{ env.conan_package_identifier }}" -r ${{ env.remote_artifactory_name }} --only-recipe |