2

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

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

我注意到大多数 GitHub 发布资产都可以通过https://github.com/owner/repo/archive/file.tar.gz. 由于我只想维护一个随每次提交而构建的副本,因此使用 GitHub 版本将是矫枉过正。我可以以某种方式从最新版本中“转储”PDFhttps://github.com/me/resume/archive/resume.pdf吗?如果没有,还有其他方法吗?

4

2 回答 2

1

您最好的选择是拥有一个版本并一次又一次地更新该文件。

GitHub Actions 也有工件,但它们只能由登录用户下载。

于 2021-02-26T21:30:14.070 回答
1

跟进@riQQ 的回答,我能够使用 GitHub Actions 自动执行此操作。这是一个示例工作流 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。

于 2021-02-26T21:33:18.363 回答