【发布时间】:2021-09-18 19:52:24
【问题描述】:
我对 github 操作很陌生。我已经设法使用 CMAKE 为 ubuntu-latest 和 windows-latest 构建了我的 C++ 程序,现在我在将其上传到版本时遇到了问题。 我使用的是策略矩阵,因此不同的操作系统作业并行运行。
我的目标是将构建文件上传到单个发布标签,其中每个文件都有一个基于操作系统平台的自定义名称。
例如:
Release Tag: V0.2.0
Files: main_0.2.0_windows.exe
main_0.2.0_ubuntu
...
main_0.2.0_other-OS.ext
有人可以帮我这样做吗?以下是我当前的工作流程 yml。
** 我已经设法将单个文件上传到 ubuntu-latest 的单个发布标签。对于 windows-latest,我收到一条错误消息,提示找不到要上传的文件 :( .
name: CMake
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
trigger:
required: false
default: 'workflow_dispatcher'
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
VERSION: 0.2.0
jobs:
build:
strategy:
matrix:
platform: [ ubuntu-latest, windows-latest ]
python-version: ['2.7', '3.6']
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip & setuptools
run: python -m pip install --upgrade pip setuptools
- name: Install matplotlib & numpy
run: python -m pip install matplotlib numpy
- name: Copy numpy core to include folder
run: python ${{github.workspace}}/cp-numpy-core.py
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target main
- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
- name: Rename Ubuntu Files
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: mv ${{github.workspace}}/build/main ${{github.workspace}}/build/main_${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.python-version }}
- name: Rename Windows Files
if: ${{ matrix.platform == 'windows-latest' }}
run: Ren "${{github.workspace}}\build\${{ env.BUILD_TYPE }}\main.exe" "${{github.workspace}}\build\${{ env.BUILD_TYPE }}\main_${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.python-version }}.exe"
- name: Upload Artifacts
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.BUILD_TYPE }}${{ env.VERSION }}/${{ matrix.platform }}/Python${{ matrix.python-version }}"
prerelease: true
title: "${{ env.BUILD_TYPE }} V${{ env.VERSION }} - OS: ${{ matrix.platform }} - Python: ${{ matrix.python-version }}"
files: |
${{github.workspace}}/build/main_${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.python-version }}
${{github.workspace}}\build\${{ env.BUILD_TYPE }}\main_${{ env.VERSION }}_${{ matrix.platform }}_${{ matrix.python-version }}.exe
最好的问候并继续编码!
【问题讨论】:
标签: github cmake github-actions