首页 > 解决方案 > 如何从 github 操作下载构建文件?

问题描述

我想知道如何从 Github Actions 下载构建文件。所以主要问题是,我是 Windows 用户,我想为 mac 用户构建我的应用程序。但是没有简单的方法,所以我使用 Github Actions 为 mac 用户构建应用程序。它运行成功,但我如何下载构建文件。 链接到 Github 存储库

标签: github-actions

解决方案


构建后,您应该首先使用actions/upload-release-assetGitHub Action 上传刚刚构建的发布资产。

您在Yevhenii Babichenko的“使用 GitHub Actions 的自动化多平台发布”中有一个完整的示例

# ...
  release_assets:
    name: Release assets
    needs: create_release # we need to know the upload URL
    runs-on: ${{ matrix.config.os }} # we run many different builds
    strategy:
      # just an example matrix
      matrix:
        config:
          - os: ubuntu-latest
          - os: macos-latest
          - os: windows-latest
    steps:
      # checkout of cource
      - name: Checkout code
        uses: actions/checkout@v1
      # ... whatever build and packaging steps you need here
      # and finally do an upload!
      - name: Upload release assets
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create_release.outputs.upload_url }}
          # This is how it will be named on the release page. Put hatever name
          # you like, remember that they need to be different for each platform.
          # You can choose any build matrix parameters. For Rust I use the
          # target triple.
          asset_name: program-name-${{ matrix.config.os }}
          # The path to the file you want to upload.
          asset_path: ./path/to/your/file
          # probably you will need to change it, but most likely you are
          # uploading a binary file
          asset_content_type: application/octet-stream

只有当这些资产上传到 GitHub 后,您才可以考虑下载它们


推荐阅读