gpt4 book ai didi

github - 使用 GitHub Actions 创建标签而不是发布

转载 作者:行者123 更新时间:2023-12-03 15:09:20 25 4
gpt4 key购买 nike

目前在我的 GitHub 存储库中,我有以下每天发布夜间快照的工作流程,并使用当前日期作为发布名称和标签名称:

name: Nightly Snapshot

on:
schedule:
- cron: "59 23 * * *"

jobs:
build:
name: Release
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Checkout branch "master"
uses: actions/checkout@v2
with:
ref: 'master'
- name: Release snapshot
id: release-snapshot
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.date.outputs.date }}
release_name: ${{ steps.date.outputs.date }}
draft: false
prerelease: false

GitHub 将所有以这种方式创建的快照标记为最新版本。但是,我想避免这种情况,并实现类似于 what Swift's snapshots are like 的东西。 :快照只是标签;尽管它们出现在发行版中,但它们的处理方式不同。

我应该如何修改我的工作流程文件来实现这一点?谢谢!

最佳答案

另一种选择是使用 GitHub Script .这将创建一个名为 tagname 的轻量级标签。 :

      - name: Create tag
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/tagname",
sha: context.sha
})

关于github - 使用 GitHub Actions 创建标签而不是发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60963759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com