我可以在 GitHub 上维护 git 跟踪之外的单个二进制文件吗?

Can I maintain a single binary on GitHub outside git's tracking?

我有一个 GitHub 存储库,其中包含用于我的简历的 LaTeX 代码。目前,我将生成的 PDF 文件作为文件包含在 git 中,即它在版本控制中进行了跟踪。包含 PDF 的唯一目的是为我可以发送给人们的最新简历 PDF 添加一个 link。因此,我根本不需要在版本控制中跟踪二进制文件。

有没有办法避免通过 git 跟踪这个二进制文件?我正在考虑使用 GitHub 操作生成 PDF,然后将其上传到某个地方。这样我就不必在 git 中包含 PDF,同时我可以共享 link 到最新版本(离开 master 分支)。 GitHub 有可以保存此 PDF 的地方吗?

我注意到大多数 GitHub 发布资产都可以通过 link 获得,例如 https://github.com/owner/repo/archive/file.tar.gz。由于我只想维护一个随每次提交而构建的副本,因此使用 GitHub 版本就太过分了。我能以某种方式从 https://github.com/me/resume/archive/resume.pdf 的最新版本中“转储”PDF 吗?如果不行,还有其他办法吗?

最好的办法是发布一个版本并一次又一次地更新该文件。

GitHub 操作也有工件,但只能由登录用户下载。

根据@riQQ 的回答,我能够使用 GitHub 操作自动执行此操作。这是一个示例工作流 YAML 文件:

name: Update binary
on:
  push:
    branches:
      - master

jobs:
  build:
    name: Update binary
    runs-on: ubuntu-latest
    steps:
      # Checkout the repo at the commit which triggered this job
      - name: Set up git repo
        uses: actions/checkout@v2
        with:
          fetch-depth: 0  # used to get the tag of the latest release

      # TODO: Action for compiling and generating the binary
      - name: Compile code

      # Removes the latest release, so that we can create a new one in its place
      - name: Delete latest release
        uses: ame-yu/action-delete-latest-release@v2
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # (optional) Removes the tag associated with the latest release
      - name: Delete release tag
        run: |
          git tag -d release
          git push origin :release
        continue-on-error: true # in case there's no existing release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # Creates the new release with the binary as a release asset.
      # If the previous Action was skipped, then this keeps the same tag as the
      # previous release.
      - name: Create new release
        uses: softprops/action-gh-release@v1
        with:
          body: "Release notes"
          name: Latest
          tag_name: release
          files: /path/to/binary
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

注意:此方法仅适用于仅出于将二进制文件维护为发布资产的目的而维护单个版本的情况。

二进制文件现在将在发布页面中可见,并且可以获取其 URL。