如何在Github Action中使用Github发行版本号 [英] How to use Github Release Version Number in Github Action

查看:533
本文介绍了如何在Github Action中使用Github发行版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have created a Github repo that has got an action to build the npm package and publish it to npmjs.com. The trigger for my action is the creation of a new release in Github. When creating the new release, Github is asking me for a version number. I would love to use this version number in the Action and provide it to the yarn publish command.

我的ci文件看起来像这样(我剥去了一些不重要的部分):

My ci-file looks like this (i stripped some parts that are not important here):

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}}

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

Is there an environmental variable that contains the version number from the release?

推荐答案

您可以使用${{ github.event.release.tag_name }}获取标签版本.

You can get tag version using ${{ github.event.release.tag_name }}.

这篇关于如何在Github Action中使用Github发行版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆