Skip to content

Commit f0a16b0

Browse files
authored
使用矩阵简化更新工作流 (#4725)
1 parent 783cadc commit f0a16b0

1 file changed

Lines changed: 17 additions & 57 deletions

File tree

.github/workflows/check-update.yml

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
dev-check-update:
12+
check-update:
1313
if: ${{ github.repository_owner == 'HMCL-dev' }}
14+
strategy:
15+
fail-fast: false
16+
max-parallel: 1
17+
matrix:
18+
include:
19+
- channel: dev
20+
task: checkUpdateDev
21+
- channel: stable
22+
task: checkUpdateStable
1423
runs-on: ubuntu-latest
24+
name: check-update-${{ matrix.channel }}
1525
steps:
1626
- uses: actions/checkout@v5
1727
- name: Set up JDK
@@ -22,7 +32,7 @@ jobs:
2232
- name: Fetch tags
2333
run: git fetch --all --tags
2434
- name: Fetch last version
25-
run: ./gradlew checkUpdateDev --no-daemon --info --stacktrace
35+
run: ./gradlew ${{ matrix.task }} --no-daemon --info --stacktrace
2636
- name: Check for existing tags
2737
run: if [ -z "$(git tag -l "$HMCL_TAG_NAME")" ]; then echo "continue=true" >> $GITHUB_ENV; fi
2838
- name: Download artifacts
@@ -34,66 +44,16 @@ jobs:
3444
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.jar.sha256"
3545
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.sh"
3646
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.sh.sha256"
37-
- name: Generate release note
38-
if: ${{ env.continue == 'true' }}
39-
run: |
40-
echo "The full changelogs can be found on the website: https://docs.hmcl.net/changelog/dev.html" >> RELEASE_NOTE
41-
echo "" >> RELEASE_NOTE
42-
echo "*Notice: changelogs are written in Chinese.*" >> RELEASE_NOTE
43-
echo "" >> RELEASE_NOTE
44-
echo "| File Name | SHA-256 Checksum |" >> RELEASE_NOTE
45-
echo "| --- | --- |" >> RELEASE_NOTE
46-
echo "| [HMCL-$HMCL_VERSION.exe]($GH_DOWNLOAD_BASE_URL/v$HMCL_VERSION/HMCL-$HMCL_VERSION.exe) | \`$(cat HMCL-$HMCL_VERSION.exe.sha256)\` |" >> RELEASE_NOTE
47-
echo "| [HMCL-$HMCL_VERSION.jar]($GH_DOWNLOAD_BASE_URL/v$HMCL_VERSION/HMCL-$HMCL_VERSION.jar) | \`$(cat HMCL-$HMCL_VERSION.jar.sha256)\` |" >> RELEASE_NOTE
48-
echo "| [HMCL-$HMCL_VERSION.sh]($GH_DOWNLOAD_BASE_URL/v$HMCL_VERSION/HMCL-$HMCL_VERSION.sh) | \`$(cat HMCL-$HMCL_VERSION.sh.sha256)\` |" >> RELEASE_NOTE
4947
env:
5048
GH_DOWNLOAD_BASE_URL: https://github.com/HMCL-dev/HMCL/releases/download
51-
- name: Create release
52-
if: ${{ env.continue == 'true' }}
53-
uses: softprops/action-gh-release@v2
54-
with:
55-
body_path: RELEASE_NOTE
56-
files: |
57-
HMCL-${{ env.HMCL_VERSION }}.exe
58-
HMCL-${{ env.HMCL_VERSION }}.jar
59-
HMCL-${{ env.HMCL_VERSION }}.sh
60-
target_commitish: ${{ env.HMCL_COMMIT_SHA }}
61-
name: ${{ env.HMCL_TAG_NAME }}
62-
tag_name: ${{ env.HMCL_TAG_NAME }}
63-
prerelease: true
64-
stable-check-update:
65-
if: ${{ github.repository_owner == 'HMCL-dev' }}
66-
needs: dev-check-update
67-
runs-on: ubuntu-latest
68-
steps:
69-
- uses: actions/checkout@v5
70-
- name: Set up JDK
71-
uses: actions/setup-java@v5
72-
with:
73-
distribution: 'temurin'
74-
java-version: '25'
75-
- name: Fetch tags
76-
run: git fetch --all --tags
77-
78-
- name: Fetch last version
79-
run: ./gradlew checkUpdateStable --no-daemon --info --stacktrace
80-
- name: Check for existing tags
81-
run: if ! git tag -l | grep -q "$HMCL_TAG_NAME"; then echo "continue=true" >> $GITHUB_ENV; fi
82-
- name: Download artifacts
83-
if: ${{ env.continue == 'true' }}
84-
run: |
85-
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.exe"
86-
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.exe.sha256"
87-
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.jar"
88-
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.jar.sha256"
89-
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.sh"
90-
wget "$HMCL_CI_DOWNLOAD_BASE_URI/HMCL-$HMCL_VERSION.sh.sha256"
9149
- name: Generate release note
9250
if: ${{ env.continue == 'true' }}
9351
run: |
94-
echo "**This version is a stable version.**" >> RELEASE_NOTE
95-
echo "" >> RELEASE_NOTE
96-
echo "The full changelogs can be found on the website: https://docs.hmcl.net/changelog/stable.html" >> RELEASE_NOTE
52+
if [ "${{ matrix.channel }}" = "stable" ]; then
53+
echo "**This version is a stable version.**" >> RELEASE_NOTE
54+
echo "" >> RELEASE_NOTE
55+
fi
56+
echo "The full changelogs can be found on the website: https://docs.hmcl.net/changelog/${{ matrix.channel }}.html" >> RELEASE_NOTE
9757
echo "" >> RELEASE_NOTE
9858
echo "*Notice: changelogs are written in Chinese.*" >> RELEASE_NOTE
9959
echo "" >> RELEASE_NOTE

0 commit comments

Comments
 (0)