Skip to content

Commit 9723e71

Browse files
committed
workflow: update compile action
1 parent 1d43296 commit 9723e71

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

.github/workflows/compile_meta_core.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,36 @@ jobs:
8383
- { goos: linux, goarch: loong64, output: loong64-abi2, upxflag: '--lzma --best' }
8484
- { goos: linux, goarch: loong64, abi: '1', output: loong64-abi1, upxflag: '--lzma --best' }
8585
steps:
86+
- name: Check if build needed
87+
id: check_skip
88+
run: |
89+
if [ "${{ matrix.core.type }}" = "meta" ] && [ "${{ needs.Get-Commit-id.outputs.current_id }}" = "${{ needs.Get-Commit-id.outputs.upstream_id }}" ]; then
90+
echo "Meta is up to date, skipping build"
91+
echo "skip=true" >> $GITHUB_OUTPUT
92+
elif [ "${{ matrix.core.type }}" = "smart" ] && [ "${{ needs.Get-Commit-id.outputs.current_smart_id }}" = "${{ needs.Get-Commit-id.outputs.upstream_smart_id }}" ]; then
93+
echo "Smart is up to date, skipping build"
94+
echo "skip=true" >> $GITHUB_OUTPUT
95+
else
96+
echo "skip=false" >> $GITHUB_OUTPUT
97+
fi
98+
8699
- name: Apt Update
100+
if: ${{ steps.check_skip.outputs.skip != 'true' }}
87101
env:
88102
DEBIAN_FRONTEND: noninteractive
89103
run: |
90104
sudo apt-get update
91105
sudo apt-get -y install wget git tar
92106
93107
- name: Setup UPX
108+
if: ${{ steps.check_skip.outputs.skip != 'true' }}
94109
run: |
95110
wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz
96111
tar xf upx-3.95-amd64_linux.tar.xz
97112
echo "upx=${{ github.workspace }}/upx-3.95-amd64_linux/upx" >> $GITHUB_ENV
98113
99114
- name: Setup Go
100-
if: ${{ !(matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1') }}
115+
if: ${{ steps.check_skip.outputs.skip != 'true' && !(matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1') }}
101116
uses: actions/setup-go@v6
102117
with:
103118
go-version: ${{ matrix.core.goversion }}
@@ -106,14 +121,14 @@ jobs:
106121

107122
- name: Cache Go loongarch abi1 tarball
108123
id: cache_go_abi1
109-
if: ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
124+
if: ${{ steps.check_skip.outputs.skip != 'true' && matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
110125
uses: actions/cache@v4
111126
with:
112127
path: ${{ runner.temp }}/go-archives/go1.26.0.linux-amd64-abi1.tar.gz
113128
key: go-loongarch-abi1-1.26.0
114129

115130
- name: Setup Go for loongarch abi1
116-
if: ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
131+
if: ${{ steps.check_skip.outputs.skip != 'true' && matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
117132
run: |
118133
GO_TAR_FILE="go1.26.0.linux-amd64-abi1.tar.gz"
119134
GO_ARCHIVE_DIR="${{ runner.temp }}/go-archives"
@@ -130,6 +145,7 @@ jobs:
130145
echo "/usr/local/go/bin" >> $GITHUB_PATH
131146
132147
- name: Clone source (${{ matrix.core.type }})
148+
if: ${{ steps.check_skip.outputs.skip != 'true' }}
133149
uses: actions/checkout@v6
134150
with:
135151
repository: ${{ matrix.core.repo }}
@@ -138,6 +154,7 @@ jobs:
138154

139155
- name: Build Core (${{ matrix.core.type }}-${{ matrix.jobs.output }})
140156
id: build
157+
if: ${{ steps.check_skip.outputs.skip != 'true' }}
141158
env:
142159
GOOS: ${{ matrix.jobs.goos }}
143160
GOARCH: ${{ matrix.jobs.goarch }}
@@ -168,10 +185,9 @@ jobs:
168185
${upx} ${{ matrix.jobs.upxflag }} ./bin/clash || true
169186
mkdir -p ../build_output
170187
tar -zcvf ../build_output/clash-linux-${{ matrix.jobs.output }}.tar.gz -C ./bin clash
171-
echo "skip=false" >> $GITHUB_OUTPUT
172188
173189
- name: Upload Core Artifact (${{ matrix.core.type }}-${{ matrix.jobs.output }})
174-
if: ${{ steps.build.outputs.skip != 'true' }}
190+
if: ${{ steps.check_skip.outputs.skip != 'true' }}
175191
uses: actions/upload-artifact@v4
176192
with:
177193
name: ${{ matrix.core.artifact }}-${{ matrix.jobs.output }}
@@ -205,7 +221,7 @@ jobs:
205221
206222
if [ "${{ needs.Get-Commit-id.outputs.current_id }}" != "${{ needs.Get-Commit-id.outputs.upstream_id }}" ]; then
207223
echo "Organizing MetaCubeX compiled files..."
208-
if [ "${{ needs.Compile_Core.result }}" == "success" ] || [ "${{ needs.Compile_Core.result }}" == "skipped" ]; then
224+
if [ "${{ needs.Compile_Core.result }}" == "success" ]; then
209225
rm -rf ./dev/meta/*
210226
for artifact_dir in ./downloaded-artifacts/meta-core-*/; do
211227
if [ -d "$artifact_dir" ] && [ -n "$(ls -A "$artifact_dir")" ]; then
@@ -225,7 +241,7 @@ jobs:
225241
226242
if [ "${{ needs.Get-Commit-id.outputs.current_smart_id }}" != "${{ needs.Get-Commit-id.outputs.upstream_smart_id }}" ]; then
227243
echo "Organizing vernesong compiled files..."
228-
if [ "${{ needs.Compile_Core.result }}" == "success" ] || [ "${{ needs.Compile_Core.result }}" == "skipped" ]; then
244+
if [ "${{ needs.Compile_Core.result }}" == "success" ]; then
229245
rm -rf ./dev/smart/*
230246
for artifact_dir in ./downloaded-artifacts/smart-core-*/; do
231247
if [ -d "$artifact_dir" ] && [ -n "$(ls -A "$artifact_dir")" ]; then

0 commit comments

Comments
 (0)