Skip to content

Update README.md 關於小奇點/忠誠點數 #49

Update README.md 關於小奇點/忠誠點數

Update README.md 關於小奇點/忠誠點數 #49

Workflow file for this run

name: 自動打包並上傳
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 克隆仓库
uses: actions/checkout@v2
- name: 安裝 Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: 安裝必要的 npm 資產
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm install
- name: 壓縮兩個資料夾
run: |
mkdir output
zip -r output/TNTCoinImprove.mcaddon [BP]iiTNTC [RP]iiTNTC
zip -r output/TNTCoinImproveBP.mcpack [BP]iiTNTC
zip -r output/TNTCoinImproveRP.mcpack [RP]iiTNTC
- name: 檢查並創建 RELEASE_LOG.md 文件
run: |
if [ ! -f RELEASE_LOG.md ]; then
echo "## 新Release Log" > RELEASE_LOG.md
fi
- name: 生成 Release 日誌
id: log
run: |
# 獲取最近的提交訊息
RECENT_COMMITS=$(git log -5 --pretty=format:"%h - %s")
# 更新 RELEASE_LOG.md 文件
echo "$RECENT_COMMITS" >> RELEASE_LOG.md
# 打印提交訊息到終端
echo "Recent commits: $RECENT_COMMITS"
- name: 檢查並更新 release 草稿或創建新草稿
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/${{ github.repository }}/releases | jq -r '.[] | select(.draft == true) | .id')
if [ -n "$RELEASE_ID" ]; then
echo "Updating draft release with ID: $RELEASE_ID"
UPDATE_RESPONSE=$(curl -s -X PATCH \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg body "$(cat RELEASE_LOG.md)" '{"body": $body}')" \
https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID)
echo "Update Response: $UPDATE_RESPONSE"
else
echo "No draft release found. Creating a new draft release."
NEW_RELEASE=$(curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg tag_name "v1.0.0" --arg name "v1.0.0" --arg body "$(cat RELEASE_LOG.md)" '{"tag_name": $tag_name, "name": $name, "body": $body, "draft": true}')" \
https://api.github.com/repos/${{ github.repository }}/releases)
NEW_RELEASE_ID=$(echo "$NEW_RELEASE" | jq -r '.id')
echo "Created new draft release with ID: $NEW_RELEASE_ID"
echo "release_id=$NEW_RELEASE_ID" >> $GITHUB_ENV
fi
- name: 上傳文件到 release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/${{ github.repository }}/releases | jq -r '.[] | select(.draft == true) | .id')
echo "Uploading files to release ID: $RELEASE_ID"
for file in output/*; do
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/zip" \
--data-binary @"$file" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$(basename $file)"
done