当前在我的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的功能:快照只是标签;尽管它们出现在发行版中,但它们的处理方式有所不同。
我应该如何修改我的工作流程文件以实现此目的?谢谢!
答案 0 :(得分:3)
我发现this GitHub action可以按需标记。使用它,我的工作流程可以这样修改:
name: Nightly Snapshot
on:
schedule:
- cron: "59 23 * * *"
jobs:
tag:
name: Tag
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: Tag snapshot
uses: tvdias/github-tagger@v0.0.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.date.outputs.date }}
答案 1 :(得分:1)
另一种选择是使用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
})