Update master.yml #8
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: Create Release on Push | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
create-release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
steps: | |
# 检出仓库代码 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# 获取正确的版本号 commit 信息 | |
- name: Get commit info | |
id: commit_info | |
run: | | |
COMMIT_MSG=$(git log --pretty=format:"%s" | grep -E "^[0-9]+\.[0-9]+v[0-9]+$" | head -n 1) | |
if [ -z "$COMMIT_MSG" ]; then | |
echo "No valid tag found. Exiting workflow." | |
exit 1 | |
fi | |
echo "::set-output name=message::${COMMIT_MSG}" | |
# 安装 zip 工具 | |
- name: Install zip | |
run: sudo apt-get install -y zip | |
# 创建 ElysianRealm-Data 压缩包 | |
- name: Create ElysianRealm-Data.zip | |
run: | | |
mkdir ElysianRealm-Data | |
find . -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.gif' \) -exec cp {} ElysianRealm-Data/ \; | |
cp LICENSE ElysianRealm-Data/ | |
cp README.md ElysianRealm-Data/ | |
zip -r ElysianRealm-Data.zip ElysianRealm-Data | |
# 根据标签生成 Release 内容 | |
- name: Generate release content | |
id: generate_content | |
run: | | |
if [[ "${{ steps.commit_info.outputs.message }}" == *v1 ]]; then | |
RELEASE_BODY="### 使用 \`/更新乐土攻略\` 后可直接复制下面命令添加 \`XX乐土\` 唤醒词\n\n" | |
RELEASE_BODY+=" - XX\n" | |
RELEASE_BODY+="\`/RealmCommand add ImageName XX乐土\`\n" | |
RELEASE_BODY+="\`/RealmCommand add ImageName_AstralRing XX乐土2,XX星环流\`\n\n" | |
RELEASE_BODY+="> 指令内容[请]阅读[README.md](https://github.com/MskTim/Bh3-ElysianRealm-Strategy/blob/master/README.md)" | |
else | |
RELEASE_BODY="> 推荐使用 \`/更新乐土攻略\` 指令获取攻略" | |
fi | |
echo "::set-output name=release_body::${RELEASE_BODY}" | |
# 创建 Release 草稿 | |
- name: Create release draft | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.commit_info.outputs.message }} | |
release_name: ${{ steps.commit_info.outputs.message }}整合包 | |
draft: true | |
body: ${{ steps.generate_content.outputs.release_body }} | |
# 上传压缩包至 Release | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./ElysianRealm-Data.zip | |
asset_name: ElysianRealm-Data.zip | |
asset_content_type: application/zip |