|
| 1 | +name: Update Version |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [update-version] |
| 6 | + workflow_dispatch: |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + actions: read |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + update-version: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v5 |
| 18 | + with: |
| 19 | + fetch-depth: 1 |
| 20 | + |
| 21 | + - name: Fetch version |
| 22 | + id: fetch_versions |
| 23 | + env: |
| 24 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + REPO: "Class-Widgets/Class-Widgets" |
| 26 | + run: | |
| 27 | + VERSION_RELEASE=$(gh release list --repo "${{ env.REPO }}" --json tagName,isPrerelease --jq '[.[] | select(.isPrerelease == false)][0].tagName // empty') |
| 28 | + if [ -z "$VERSION_RELEASE" ] || [ "$VERSION_RELEASE" = "null" ]; then |
| 29 | + echo "[DEBUG] 未找到正式版本" |
| 30 | + VERSION_RELEASE=$(gh release list --repo "${{ env.REPO }}" --json tagName --jq '.[0].tagName // empty') |
| 31 | + if [ -z "$VERSION_RELEASE" ] || [ "$VERSION_RELEASE" = "null" ]; then |
| 32 | + echo "[ERROR] 无法获取任何版本信息" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | + fi |
| 36 | + VERSION_BETA=$(gh release list --repo "${{ env.REPO }}" --json tagName,isPrerelease --jq '[.[] | select(.isPrerelease == true)][0].tagName // empty') |
| 37 | + if [ -z "$VERSION_BETA" ]; then |
| 38 | + VERSION_BETA="$VERSION_RELEASE" |
| 39 | + fi |
| 40 | + echo "[INFO] 最新 release 版本: $VERSION_RELEASE" |
| 41 | + echo "[INFO] 最新 beta / Nightly 版本: $VERSION_BETA" |
| 42 | +
|
| 43 | + jq -n \ |
| 44 | + --arg release "$VERSION_RELEASE" \ |
| 45 | + --arg beta "$VERSION_BETA" \ |
| 46 | + '{"version_release": $release, "version_beta": $beta}' > public/version.json |
| 47 | + echo "VERSION_RELEASE=$VERSION_RELEASE" >> $GITHUB_OUTPUT |
| 48 | + echo "VERSION_BETA=$VERSION_BETA" >> $GITHUB_OUTPUT |
| 49 | +
|
| 50 | + - name: Import GPG key |
| 51 | + id: import-gpg |
| 52 | + uses: crazy-max/ghaction-import-gpg@v6 |
| 53 | + continue-on-error: true |
| 54 | + with: |
| 55 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 56 | + passphrase: ${{ secrets.GPG_PASSPHRASE }} |
| 57 | + git_user_signingkey: true |
| 58 | + git_commit_gpgsign: true |
| 59 | + |
| 60 | + - name: Create Pull Request |
| 61 | + uses: peter-evans/create-pull-request@v7 |
| 62 | + with: |
| 63 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + commit-message: | |
| 65 | + chore(version): 更新版本号 |
| 66 | +
|
| 67 | + * 正式版: ${{ steps.fetch_versions.outputs.VERSION_RELEASE }} |
| 68 | + * Beta / Nightly 版: ${{ steps.fetch_versions.outputs.VERSION_BETA }} |
| 69 | + title: 'chore(version): 更新版本号' |
| 70 | + body: | |
| 71 | + ## 版本更新 |
| 72 | + - **正式版**: ${{ steps.fetch_versions.outputs.VERSION_RELEASE }} |
| 73 | + - **Beta / Nightly 版**: ${{ steps.fetch_versions.outputs.VERSION_BETA }} |
| 74 | +
|
| 75 | + branch: update/version-${{ github.run_id }} |
| 76 | + delete-branch: true |
| 77 | + committer: ChimeYao-bot <ChimeYao@outlook.jp> |
| 78 | + author: ChimeYao-bot <ChimeYao@outlook.jp> |
0 commit comments