Update prompthelper.js #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release PromptHelper | |
on: | |
push: | |
branches: | |
- main # 或你希望触发此工作流的分支 | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: 设置 Node.js 环境 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: 安装yml处理插件 | |
run: npm install js-yaml | |
- name: 生成新的 prompthelper.js | |
run: node scripts/generate-prompthelper.js | |
- name: 基于时间戳推送新的tag | |
run: | | |
TIMESTAMP=`date +%Y%m%d%H%M%S` | |
echo "NEW_TAG_NAME=v$TIMESTAMP" >> $GITHUB_ENV | |
# 使用sed命令更新prompthelper.js中的版本信息 | |
TAG_NAME="1.0.$TIMESTAMP" | |
sed -i "s/@version [0-9.]*/@version $TAG_NAME/" prompthelper.js | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git tag $NEW_TAG_NAME $(git rev-parse HEAD) | |
git push origin $NEW_TAG_NAME | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: 发布 | |
id: create_release | |
run: | | |
RESPONSE=$(curl \ | |
-X POST \ | |
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/releases \ | |
-d '{"tag_name":"${{ env.NEW_TAG_NAME }}", "name":"Release ${{ env.NEW_TAG_NAME }}", "body":"Release description here", "draft":false, "prerelease":false}') | |
UPLOAD_URL=$(echo $RESPONSE | jq -r .upload_url | sed 's/{?name,label}//') | |
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV | |
- name: 上传文件 | |
run: | | |
curl \ | |
-X POST \ | |
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ | |
-H "Content-Type: application/javascript" \ | |
--data-binary @"./prompthelper.js" \ | |
"${{ env.UPLOAD_URL }}?name=prompthelper.js&label=Prompthelper" |