【发布时间】:2022-08-06 12:24:51
【问题描述】:
我有一个在发布事件上发布 nuget 包的工作流,但我无法从标记名中删除 \'v\' 字符。我所有的标签名称都是 v${version} 所以我需要去掉那个 \'v\' 并只获取版本。
我有这个工作流程:
name: Nuget package publish
on:
release:
types: [published]
jobs:
nuget:
name: Nuget - Publish package
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Verify commit exists in origin/master
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep origin/master
- name: Set VERSION variable from tag
run: |
echo \"VERSION=${{ github.event.release.tag_name }}\" >> $GITHUB_ENV
echo \"VERSION=${VERSION:1}\" >> $GITHUB_ENV
- name: Build
run: dotnet build --configuration Release
- name: Pack
run: dotnet pack UVtools.Core --configuration Release --no-build --output .
- name: Push nuget.org
run: dotnet nuget push UVtools.Core.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_TOKEN}
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
问题在:
运行 echo \"VERSION=v3.2.0\" >> $GITHUB_ENV
回声 \"VERSION=v3.2.0\" >> $GITHUB_ENV
回声 \"VERSION=${VERSION:1}\" >> $GITHUB_ENV
外壳:/usr/bin/bash -e {0}在我尝试剥离 \'v\' VERSION 设置为空
错误:文件不存在(UVtools.Core..nupkg)。
我怎么能从变量中去除\'v\'?
PS:在我机器上的一个 bash 脚本下,我测试了:
VERSION=v1.5.0 echo $VERSION echo \"${VERSION:1}\"产生:
v1.5.0
1.5.0
标签: github-actions