gpt4 book ai didi

github - 如何在Github Action中使用Github发行版本号

转载 作者:行者123 更新时间:2023-12-03 13:44:30 28 4
gpt4 key购买 nike

我创建了一个Github存储库,该存储库已采取行动来构建npm软件包并将其发布到npmjs.com。我行动的触发因素是在Github中创建了一个新版本。创建新版本时,Github要求我提供版本号。我很乐意在Action中使用此版本号,并将其提供给yarn publish命令。

我的ci文件如下所示(我剥离了一些不重要的部分):

name: Deploy npm package

on:
release:
types: [created]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: yarn install
- run: yarn build
- run: yarn publish --new-version ${...}
env:a
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

是否有环境变量包含发行版中的版本号?

最佳答案

应该是${{ github.event.release.tag_name }}。发行版的结构可以在这里找到:https://developer.github.com/v3/repos/releases/#get-a-single-release

我也建议使用

on:
release:
types: [published]

而不是为了避免在草稿发布时将内容添加到npm而创建。
另请: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#release-event-release

提示:

要调试事件,您可以使用:
jobs:
debug:
name: Debug
runs-on: ubuntu-latest
steps:
- name: Dump env
run: env | sort
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

关于github - 如何在Github Action中使用Github发行版本号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59518658/

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