Skip to content

update-version

update-version #28

name: Update Version(cw1)
on:
repository_dispatch:
types: [update-version]
workflow_dispatch:
permissions:
contents: write
actions: read
pull-requests: write
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Fetch version
id: fetch_versions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: "Class-Widgets/Class-Widgets"
run: |
VERSION_RELEASE=$(gh release list --repo "${{ env.REPO }}" --json tagName,isPrerelease --jq '[.[] | select(.isPrerelease == false)][0].tagName // empty')
if [ -z "$VERSION_RELEASE" ] || [ "$VERSION_RELEASE" = "null" ]; then
echo "[DEBUG] 未找到正式版本"
VERSION_RELEASE=$(gh release list --repo "${{ env.REPO }}" --json tagName --jq '.[0].tagName // empty')
if [ -z "$VERSION_RELEASE" ] || [ "$VERSION_RELEASE" = "null" ]; then
echo "[ERROR] 无法获取任何版本信息"
exit 1
fi
fi
VERSION_BETA=$(gh release list --repo "${{ env.REPO }}" --json tagName,isPrerelease --jq '[.[] | select(.isPrerelease == true)][0].tagName // empty')
if [ -z "$VERSION_BETA" ]; then
VERSION_BETA="$VERSION_RELEASE"
fi
echo "[INFO] 最新 release 版本: $VERSION_RELEASE"
echo "[INFO] 最新 beta / Nightly 版本: $VERSION_BETA"
jq -n \
--arg release "$VERSION_RELEASE" \
--arg beta "$VERSION_BETA" \
'{"version_release": $release, "version_beta": $beta}' > public/version.json
echo "VERSION_RELEASE=$VERSION_RELEASE" >> $GITHUB_OUTPUT
echo "VERSION_BETA=$VERSION_BETA" >> $GITHUB_OUTPUT
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v6
continue-on-error: true
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: |
chore(version-cw1): 更新版本号
* 正式版: ${{ steps.fetch_versions.outputs.VERSION_RELEASE }}
* Beta / Nightly 版: ${{ steps.fetch_versions.outputs.VERSION_BETA }}
file_pattern: "public/version.json"
commit_user_name: "ChimeYao-bot"
commit_user_email: "ChimeYao@outlook.jp"
commit_author: "ChimeYao-bot <ChimeYao@outlook.jp>"