github aciotn的简单使用

前言

遇到没有文档的项目时,CI文件可以帮助我们,了解项目该如何编译。本文仅尝试使用GitHub Actions文档 - GitHub 文档,作为C++项目的CI。有 gitlib-ci的简单使用的体验之后,github的action比较容易上手。

除了官方文档外,这里给出另外的参考链接:


github action的简单使用

本节仓库:GitHub - da1234cao/github-action-demo: github action demo

目标:一个简单的C++项目。项目需要在windows和linux上编译。项目依赖qt和boost。

编写CI脚本,照葫芦画瓢即可。没有看到很好的葫芦,这个可以参考:Qt使用github-Actions自动化编译 - 知乎

这里不进行详细介绍,阅读完上面的链接,自可明白。在Github Actions workflows中安装qt和boost: Install Qt · Actions · GitHub Marketplace · GitHubDownload and install Boost · Actions · GitHub Marketplace · GitHub

name: GitHub Actions Demo
run-name: ${
    
    {
    
     github.actor }} is testing out GitHub Actions
on: [push]
jobs:
  build-on-window-22:
    runs-on: windows-2022
    steps:
      - name: Check out repository code
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      - name: install boost
        id: install-boost
        uses: MarkusJx/install-[email protected]
        with:
          boost_version: '1.80.0'
          platform_version: 2022
          toolset: 'msvc'
      - name: install qt
        uses: jurplel/install-qt-action@v3
        with:
          version: '5.15.2'
          host: 'windows'
          target: 'desktop'
          arch: 'win64_msvc2019_64'
      - name: build demo
        run: |
          mkdir build
          cd build
          cmake ..
          cmake --build . --config Release
        env:
          BOOST_ROOT: ${
    
    {
    
     steps.install-boost.outputs.BOOST_ROOT }}

  build-on-ubuntu-22:
    runs-on: ubuntu-22.04
    steps:
      - name: Check out repository code
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      - name: install boost
        id: install-boost
        uses: MarkusJx/install-[email protected]
        with:
          boost_version: '1.80.0'
          platform_version: 22.04
          toolset: 'gcc'

      - name: install qt
        uses: jurplel/install-qt-action@v3
        with:
          version: '5.15.2'
          target: 'desktop'
      - name: build demo
        run: |
          mkdir build
          cd build
          cmake ..
          make
        env:
          BOOST_ROOT: ${
    
    {
    
     steps.install-boost.outputs.BOOST_ROOT }}

猜你喜欢

转载自blog.csdn.net/sinat_38816924/article/details/131277467
今日推荐