Skip to content

Commit 00ad0de

Browse files
authored
refactor: ci流程[skip ci] (#365)
* refactor: ci * fix: 规范性修正
1 parent 4c12633 commit 00ad0de

7 files changed

Lines changed: 96 additions & 101 deletions

File tree

.github/workflows/alpha.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ jobs:
1010
contents: write
1111

1212
steps:
13-
- name: Checkout source code
14-
uses: actions/checkout@v4
15-
16-
- uses: actions/download-artifact@v4
13+
- name: Download Artifacts
14+
uses: actions/download-artifact@v8
1715
with:
1816
name: outputs
1917
path: ${{ github.workspace }}/outputs/
@@ -29,15 +27,15 @@ jobs:
2927
cat $GITHUB_WORKSPACE/outputs/changelog
3028
echo "BSEOF"
3129
} >> "$GITHUB_OUTPUT"
32-
APK_FILENAME="FzuHelper_${APP_VERSION_NAME}(${APP_VERSION_CODE}).apk"
33-
echo "apk_filename=$APK_FILENAME" >> "$GITHUB_OUTPUT"
30+
APK_FILENAME="FzuHelper_${APP_VERSION_NAME}.${APP_VERSION_CODE}.apk"
31+
echo "APK_FILENAME=$APK_FILENAME" >> "$GITHUB_OUTPUT"
3432
mv $GITHUB_WORKSPACE/outputs/apk/release/app-arm64-v8a-release.apk $APK_FILENAME
3533
36-
- name: Delete alpha using GitHub CLI
34+
- name: Delete alpha by GitHub CLI
3735
run: |
3836
gh release delete alpha --yes --cleanup-tag >/dev/null 2>&1 || echo "No alpha release exists."
3937
env:
40-
GITHUB_TOKEN: ${{ github.token }}
38+
GH_TOKEN: ${{ github.token }}
4139

4240
- name: Create GitHub Pre-Release
4341
uses: softprops/action-gh-release@v2
@@ -50,4 +48,4 @@ jobs:
5048
此版本为新架构测试版,请提前加入内测群 1020036141 了解详情
5149
prerelease: true
5250
files: |
53-
${{ steps.version-info.outputs.apk_filename }}
51+
${{ steps.version-info.outputs.APK_FILENAME }}
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
timeout-minutes: 60
1010

1111
steps:
12-
- name: Checkout source code
13-
uses: actions/checkout@v4
12+
- name: Checkout Source Code
13+
uses: actions/checkout@v6
1414
with:
1515
fetch-depth: 0
1616

1717
- name: Restore Cache
18-
uses: actions/cache@v4
18+
uses: actions/cache@v5
1919
with:
2020
path: |
2121
${{ github.workspace }}/node_modules
@@ -24,22 +24,23 @@ jobs:
2424
${{ runner.os }}-
2525
2626
- name: Setup Node.js
27-
uses: actions/setup-node@v4
27+
uses: actions/setup-node@v6
2828
with:
2929
node-version: 22
3030
cache: yarn
3131

32-
- uses: actions/setup-java@v4
32+
- name: Setup Java
33+
uses: actions/setup-java@v5
3334
with:
3435
distribution: temurin
3536
java-version: 17
3637

3738
- name: Setup Gradle
38-
uses: gradle/actions/setup-gradle@v4
39+
uses: gradle/actions/setup-gradle@v5
3940
with:
4041
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
4142

42-
- name: Install dependencies
43+
- name: Install Dependencies
4344
run: yarn install --frozen-lockfile --prefer-offline
4445

4546
- name: Prebuild
@@ -65,8 +66,8 @@ jobs:
6566
echo "$(grep 'versionName' android/app/build.gradle | awk -F '"' '{print $2}')" > android/app/build/outputs/version-name
6667
echo "$(git log -3 --pretty=format:"%s%n%b%n")" > android/app/build/outputs/changelog
6768
68-
- name: Upload outputs
69-
uses: actions/upload-artifact@v4
69+
- name: Upload Artifacts
70+
uses: actions/upload-artifact@v7
7071
with:
7172
name: outputs
7273
path: android/app/build/outputs

.github/workflows/beta.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,34 @@ jobs:
99
environment: beta
1010

1111
steps:
12-
- uses: actions/download-artifact@v4
13-
with:
14-
name: outputs
15-
path: ${{ github.workspace }}/outputs/
16-
17-
- name: Extract Version Info
12+
- name: Download APK and Extract Version Info
1813
id: version-info
1914
shell: bash
2015
run: |
21-
echo "APP_VERSION_CODE=$(cat $GITHUB_WORKSPACE/outputs/version-code)" >> "$GITHUB_OUTPUT"
22-
echo "APP_VERSION_NAME=$(cat $GITHUB_WORKSPACE/outputs/version-name)" >> "$GITHUB_OUTPUT"
16+
mkdir -p "$GITHUB_WORKSPACE/outputs/apk/release"
17+
gh release download alpha --pattern "FzuHelper_*.apk" --dir "$GITHUB_WORKSPACE/outputs/apk/release"
18+
19+
APK_PATH=$(ls "$GITHUB_WORKSPACE"/outputs/apk/release/FzuHelper_*.apk | head -n 1)
20+
APK_FILENAME=$(basename "$APK_PATH")
21+
if [[ "$APK_FILENAME" =~ ^FzuHelper_([0-9]+\.[0-9]+\.[0-9]+)\.([0-9]+)\.apk$ ]]; then
22+
APP_VERSION_NAME="${BASH_REMATCH[1]}"
23+
APP_VERSION_CODE="${BASH_REMATCH[2]}"
24+
else
25+
echo "Unexpected APK filename format: $APK_FILENAME"
26+
exit 1
27+
fi
28+
CHANGELOG=$(gh release view alpha --json body --jq .body)
29+
30+
echo "APK_FILENAME=$APK_FILENAME" >> "$GITHUB_OUTPUT"
31+
echo "APP_VERSION_NAME=$APP_VERSION_NAME" >> "$GITHUB_OUTPUT"
32+
echo "APP_VERSION_CODE=$APP_VERSION_CODE" >> "$GITHUB_OUTPUT"
2333
{
2434
echo "CHANGELOG<<BSEOF"
25-
cat $GITHUB_WORKSPACE/outputs/changelog
35+
echo "$CHANGELOG"
2636
echo "BSEOF"
2737
} >> "$GITHUB_OUTPUT"
38+
env:
39+
GH_TOKEN: ${{ github.token }}
2840

2941
- name: Get Upload Params
3042
id: upload-params
@@ -40,7 +52,6 @@ jobs:
4052
id: upload-apk
4153
run: |
4254
cd $GITHUB_WORKSPACE/outputs/apk/release
43-
mv app-arm64-v8a-release.apk $APK_FILENAME
4455
RESPONSE=$(curl -X POST "https://v0.api.upyun.com/fzuhelper-filedown" \
4556
-F "file=@$APK_FILENAME" \
4657
-F "policy=$UPYUN_POLICY" \
@@ -50,7 +61,7 @@ jobs:
5061
5162
echo "DOWNLOAD_URL=$DOWNLOAD_URL" >> "$GITHUB_OUTPUT"
5263
env:
53-
APK_FILENAME: FzuHelper_${{ steps.version-info.outputs.APP_VERSION_NAME }}(${{ steps.version-info.outputs.APP_VERSION_CODE }}).apk
64+
APK_FILENAME: ${{ steps.version-info.outputs.APK_FILENAME }}
5465
UPYUN_POLICY: ${{ steps.upload-params.outputs.UPYUN_POLICY }}
5566
UPYUN_AUTH: ${{ steps.upload-params.outputs.UPYUN_AUTH }}
5667

.github/workflows/ios.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@ on:
66
jobs:
77
build_ipa:
88
runs-on: macos-latest
9+
timeout-minutes: 60
910
env:
1011
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
1112

1213
steps:
13-
- uses: actions/checkout@v4
14+
- name: Checkout Source Code
15+
uses: actions/checkout@v6
1416
with:
1517
fetch-depth: 0
1618

1719
- name: Restore Cache
18-
uses: actions/cache@v4
20+
uses: actions/cache@v5
1921
with:
2022
path: |
2123
${{ github.workspace }}/node_modules
2224
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
2325
restore-keys: |
2426
${{ runner.os }}-
2527
26-
- name: Setup Node
28+
- name: Setup Node.js
2729
uses: actions/setup-node@v6
2830
with:
2931
node-version: 22
@@ -33,14 +35,12 @@ jobs:
3335
run: yarn install --frozen-lockfile --prefer-offline
3436

3537
- name: Download EAS CLI
36-
uses: robinraju/release-downloader@v1
37-
with:
38-
repository: linrongda/eas-cli
39-
latest: true
40-
tag: local-submit-v1
41-
fileName: eas-cli.tar.gz
42-
out-file-path: eas-cli
43-
extract: true
38+
run: |
39+
mkdir -p eas-cli
40+
gh release download --repo linrongda/eas-cli --pattern eas-cli.tar.gz --dir eas-cli
41+
tar -xzf eas-cli/eas-cli.tar.gz -C eas-cli
42+
env:
43+
GH_TOKEN: ${{ github.token }}
4444

4545
- name: Compute and Inject buildNumber
4646
run: |

.github/workflows/main.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,34 @@ on:
88
- '[0-9]+.[0-9]+.[0-9]+'
99
workflow_dispatch:
1010

11-
jobs:
12-
build:
13-
uses: ./.github/workflows/build.yml
14-
secrets: inherit
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
1514

15+
jobs:
1616
ios:
1717
if: github.ref == 'refs/heads/master'
1818
uses: ./.github/workflows/ios.yml
1919
secrets: inherit
2020

21+
android:
22+
if: github.ref == 'refs/heads/master'
23+
uses: ./.github/workflows/android.yml
24+
secrets: inherit
25+
2126
alpha:
2227
if: github.ref == 'refs/heads/master'
23-
needs: build
28+
needs: android
2429
uses: ./.github/workflows/alpha.yml
2530
secrets: inherit
2631

2732
beta:
2833
if: github.event_name == 'workflow_dispatch'
29-
needs: build
3034
uses: ./.github/workflows/beta.yml
3135
secrets: inherit
3236

3337
release:
3438
if: startsWith(github.ref, 'refs/tags/')
35-
needs: build
3639
uses: ./.github/workflows/release.yml
3740
secrets: inherit
3841

.github/workflows/release.yml

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,45 @@ jobs:
1010
contents: write
1111

1212
steps:
13-
- name: Checkout source code
14-
uses: actions/checkout@v4
13+
- name: Checkout Source Code
14+
uses: actions/checkout@v6
1515
with:
1616
fetch-depth: 0
1717

18-
- uses: actions/download-artifact@v4
19-
with:
20-
name: outputs
21-
path: ${{ github.workspace }}/outputs/
22-
23-
- name: Extract APK
24-
id: apk-info
18+
- name: Download APK
19+
id: apk
2520
shell: bash
2621
run: |
27-
APP_VERSION_CODE=$(cat $GITHUB_WORKSPACE/outputs/version-code)
28-
APP_VERSION_NAME=$(cat $GITHUB_WORKSPACE/outputs/version-name)
29-
APK_FILENAME="FzuHelper_${APP_VERSION_NAME}(${APP_VERSION_CODE}).apk"
30-
echo "apk_filename=$APK_FILENAME" >> "$GITHUB_OUTPUT"
31-
mv $GITHUB_WORKSPACE/outputs/apk/release/app-arm64-v8a-release.apk $APK_FILENAME
32-
33-
- name: Get version info
34-
id: version-info
35-
run: |
36-
CURRENT_VERSION=${GITHUB_REF_NAME}
37-
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
22+
mkdir -p "$GITHUB_WORKSPACE/outputs/apk/release"
23+
gh release download alpha --pattern "FzuHelper_*.apk" --dir "$GITHUB_WORKSPACE/outputs/apk/release"
3824
39-
git fetch --tags --force
40-
ALL_TAGS=$(git tag -l "*.*.*" --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$')
25+
APK_PATH=$(ls "$GITHUB_WORKSPACE"/outputs/apk/release/FzuHelper_*.apk | head -n 1)
26+
if [[ -z "$APK_PATH" ]]; then
27+
echo "Error: APK file not found in the release assets."
28+
exit 1
29+
fi
4130
42-
PREV_TAG=$(echo "$ALL_TAGS" | grep -B1 "$GITHUB_REF_NAME" | head -n1)
31+
echo "APK_PATH=$APK_PATH" >> "$GITHUB_OUTPUT"
32+
env:
33+
GH_TOKEN: ${{ github.token }}
4334

44-
[ -z "$PREV_TAG" ] && PREV_TAG=$(git rev-list --max-parents=0 HEAD)
45-
46-
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
47-
48-
- name: Generate changelog
49-
id: changelog
35+
- name: Generate Release Info
36+
id: info
5037
run: |
51-
CHANGELOG=$(git log --pretty=format:"- [%%h] %%s (by %%an)" \
52-
--date=short \
53-
--no-merges \
54-
${{ steps.version-info.outputs.prev_tag }}..HEAD | sed 's/%/%%/g')
55-
56-
COMPARE_URL="https://github.com/${{ github.repository }}/compare/${{ steps.version-info.outputs.prev_tag }}...${{ github.ref_name }}"
38+
CURRENT_VERSION=${GITHUB_REF_NAME}
39+
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_OUTPUT
5740
58-
echo "changelog<<EOF" >> $GITHUB_OUTPUT
59-
echo "## [${{ steps.version-info.outputs.current_version }}]($COMPARE_URL)" >> $GITHUB_OUTPUT
41+
echo "DATE_TIME<<EOF" >> $GITHUB_OUTPUT
6042
echo "### $(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
61-
echo "$CHANGELOG" >> $GITHUB_OUTPUT
6243
echo "EOF" >> $GITHUB_OUTPUT
6344
6445
- name: Create GitHub Release
6546
uses: softprops/action-gh-release@v2
6647
with:
6748
tag_name: ${{ github.ref_name }}
68-
name: ${{ steps.version-info.outputs.current_version }}
49+
name: ${{ steps.info.outputs.CURRENT_VERSION }}
6950
generate_release_notes: true # 自动生成发布说明
70-
body: ${{ steps.changelog.outputs.changelog }}
51+
body: ${{ steps.info.outputs.DATE_TIME }}
7152
make_latest: true
7253
files: |
73-
${{ steps.apk-info.outputs.apk_filename }}
54+
${{ steps.apk.outputs.APK_PATH }}

.github/workflows/version.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ jobs:
1111
pull-requests: write
1212

1313
steps:
14-
- uses: actions/checkout@v4
14+
- name: Checkout Source Code
15+
uses: actions/checkout@v6
1516
with:
1617
fetch-depth: 0
1718

18-
- name: Extract current tag
19+
- name: Extract Current Tag
1920
id: tag
2021
run: |
2122
CURRENT_TAG=${GITHUB_REF_NAME}
22-
echo "current=$CURRENT_TAG" >> $GITHUB_OUTPUT
23+
echo "CURRENT_TAG=$CURRENT_TAG" >> $GITHUB_OUTPUT
2324
24-
- name: Calculate next version
25+
- name: Calculate Next Version
2526
id: version
2627
run: |
27-
IFS='.' read -r major minor patch <<< "${{ steps.tag.outputs.current }}"
28+
IFS='.' read -r major minor patch <<< "${{ steps.tag.outputs.CURRENT_TAG }}"
2829
2930
if [ "$patch" -lt 9 ]; then
3031
patch=$((patch+1))
@@ -39,19 +40,19 @@ jobs:
3940
fi
4041
4142
NEXT_VERSION="$major.$minor.$patch"
42-
echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
43+
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
4344
44-
- name: Bump version
45+
- name: Bump Version
4546
run: |
46-
jq '.version = "${{ steps.version.outputs.next }}"' package.json > package.tmp && mv package.tmp package.json
47+
jq '.version = "${{ steps.version.outputs.NEXT_VERSION }}"' package.json > package.tmp && mv package.tmp package.json
4748
4849
- name: Create Pull Request
49-
uses: peter-evans/create-pull-request@v7
50+
uses: peter-evans/create-pull-request@v8
5051
with:
5152
token: ${{ github.token }}
52-
title: 'chore: bump version to ${{ steps.version.outputs.next }}'
53-
body: 'Auto bump version to ${{ steps.version.outputs.next }} (detected tag ${{ steps.tag.outputs.current }})'
53+
title: 'chore: bump version to ${{ steps.version.outputs.NEXT_VERSION }}'
54+
body: 'Auto bump version to ${{ steps.version.outputs.NEXT_VERSION }} (detected tag ${{ steps.tag.outputs.CURRENT_TAG }})'
5455
base: master
55-
branch: bump-version-${{ steps.version.outputs.next }}
56-
commit-message: 'chore: bump version to ${{ steps.version.outputs.next }}'
56+
branch: bump-version-${{ steps.version.outputs.NEXT_VERSION }}
57+
commit-message: 'chore: bump version to ${{ steps.version.outputs.NEXT_VERSION }}'
5758
sign-commits: true

0 commit comments

Comments
 (0)