1- name : beta release
1+ name : Build and Release
22
33on :
4+ workflow_dispatch :
45 push :
5- branches : [ 'main' ]
6+ branches : [main]
7+ pull_request :
8+ branches : [main]
69
710concurrency :
811 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -11,26 +14,36 @@ concurrency:
1114permissions :
1215 contents : write
1316
17+ env :
18+ ORG_NAME : openlistteam
19+ IMAGE_NAME : openlist-git
20+ REGISTRY : ghcr.io
21+ ARTIFACT_NAME_DOCKER_BINARY : ' docker_binaries'
22+ ARTIFACT_NAME_BETA_BINARIES : ' beta_binaries'
23+ ARTIFACT_NAME_DOCKER_IMAGES : ' docker_images'
24+ RELEASE_PLATFORMS : ' linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64'
25+ IMAGE_PUSH : false
26+
1427jobs :
15- release :
28+ build_beta_binaries :
29+ name : Build Beta Binaries
30+ runs-on : ubuntu-latest
1631 strategy :
1732 matrix :
1833 include :
19- - target : ' !(*musl*|*windows-arm64*|*android*|*freebsd*)' # xgo
34+ - target : ' !(*musl*|*windows-arm64*|*android*|*freebsd*)'
2035 hash : " md5"
21- - target : ' linux-!(arm*)-musl*' # musl-not-arm
36+ - target : ' linux-!(arm*)-musl*'
2237 hash : " md5-linux-musl"
23- - target : ' linux-arm*-musl*' # musl-arm
38+ - target : ' linux-arm*-musl*'
2439 hash : " md5-linux-musl-arm"
25- - target : ' windows-arm64' # win-arm64
40+ - target : ' windows-arm64'
2641 hash : " md5-windows-arm64"
27- - target : ' android-*' # android
42+ - target : ' android-*'
2843 hash : " md5-android"
29- - target : ' freebsd-*' # freebsd
44+ - target : ' freebsd-*'
3045 hash : " md5-freebsd"
3146
32- name : Beta Release
33- runs-on : ubuntu-latest
3447 steps :
3548 - name : Checkout
3649 uses : actions/checkout@v4
4558 - name : Setup web
4659 run : bash build.sh dev web
4760
48- - name : Build
49- uses : go-cross/cgo-actions@454cfd6d20816878926b0253ca8f2dbbd2f7d731 # V1.1.0
61+ - name : Build binaries
62+ uses : go-cross/cgo-actions@454cfd6d20816878926b0253ca8f2dbbd2f7d731
5063 with :
5164 targets : ${{ matrix.target }}
5265 musl-target-format : $os-$musl-$arch
@@ -59,29 +72,153 @@ jobs:
5972 github.com/alist-org/alist/v3/internal/conf.GitCommit=$git_commit
6073 github.com/alist-org/alist/v3/internal/conf.Version=$tag
6174 github.com/alist-org/alist/v3/internal/conf.WebVersion=dev
62- - name : Compress
75+
76+ - name : Compress binaries
6377 run : |
6478 bash build.sh zip ${{ matrix.hash }}
65- # See above
66- # - name: Upload assets
67- # uses: softprops/action-gh-release@v2
68- # with:
69- # files: build/compress/*
70- # prerelease: true
71- # tag_name: beta
72-
73- - name : Clean illegal characters from matrix.target
74- id : clean_target_name
79+
80+ - name : Clean target names
81+ id : clean_target
7582 run : |
76- ILLEGAL_CHARS_REGEX='[":<>|*?\\/\r\n]'
77- CLEANED_TARGET=$(echo "${{ matrix.target }}" | sed -E "s/$ILLEGAL_CHARS_REGEX//g")
78- echo "Original target: ${{ matrix.target }}"
79- echo "Cleaned target: $CLEANED_TARGET"
83+ CLEANED_TARGET=$(echo "${{ matrix.target }}" | tr -d '":<>|*?\\/\r\n')
8084 echo "cleaned_target=$CLEANED_TARGET" >> $GITHUB_ENV
81- - name : Upload assets
85+
86+ - name : Prepare beta binaries artifact
87+ run : |
88+ mkdir -p beta_binaries
89+ for f in build/compress/*; do
90+ ext="${f##*.}"
91+ mv "$f" "beta_binaries/openlist-${{ env.cleaned_target }}.$ext"
92+ done
93+
94+ - name : Upload beta binaries
8295 uses : actions/upload-artifact@v4
8396 with :
84- name : beta builds for ${{ env.cleaned_target }}
85- path : ${{ github.workspace }}/build/compress/*
86- compression-level : 0
87- if-no-files-found : error # 'warn' or 'ignore' are also available, defaults to `warn`
97+ name : ${{ env.ARTIFACT_NAME_BETA_BINARIES }}
98+ path : beta_binaries/*
99+ retention-days : 1
100+
101+ build_docker_binary :
102+ name : Build Docker Binary
103+ runs-on : ubuntu-latest
104+ steps :
105+ - name : Checkout
106+ uses : actions/checkout@v4
107+
108+ - uses : actions/setup-go@v5
109+ with :
110+ go-version : stable
111+
112+ - name : Cache Musl
113+ id : cache-musl
114+ uses : actions/cache@v4
115+ with :
116+ path : build/musl-libs
117+ key : docker-musl-libs-v2
118+
119+ - name : Download Musl Library
120+ if : steps.cache-musl.outputs.cache-hit != 'true'
121+ run : bash build.sh prepare docker-multiplatform
122+
123+ - name : Build go binary
124+ run : bash build.sh beta docker-multiplatform
125+
126+ - name : Upload Docker binaries
127+ uses : actions/upload-artifact@v4
128+ with :
129+ name : ${{ env.ARTIFACT_NAME_DOCKER_BINARY }}
130+ path : build/
131+ exclude : |
132+ **/*.tgz
133+ **/musl-libs/**
134+ retention-days : 1
135+
136+ build_docker_images :
137+ needs : build_docker_binary
138+ name : Build Docker Images
139+ runs-on : ubuntu-latest
140+ strategy :
141+ matrix :
142+ variant : ["", "ffmpeg", "aria2", "aio"]
143+ include :
144+ - variant : " "
145+ tag_suffix : " latest"
146+ build_args : " "
147+ - variant : " ffmpeg"
148+ tag_suffix : " ffmpeg"
149+ build_args : " INSTALL_FFMPEG=true"
150+ - variant : " aria2"
151+ tag_suffix : " aria2"
152+ build_args : " INSTALL_ARIA2=true"
153+ - variant : " aio"
154+ tag_suffix : " aio"
155+ build_args : " INSTALL_FFMPEG=true INSTALL_ARIA2=true"
156+
157+ steps :
158+ - name : Checkout
159+ uses : actions/checkout@v4
160+
161+ - name : Download binaries
162+ uses : actions/download-artifact@v4
163+ with :
164+ name : ${{ env.ARTIFACT_NAME_DOCKER_BINARY }}
165+ path : build/
166+
167+ - name : Setup Docker Buildx
168+ uses : docker/setup-buildx-action@v3
169+
170+ - name : Build Docker image
171+ run : |
172+ mkdir -p docker_images
173+ docker buildx build \
174+ --file Dockerfile.ci \
175+ --build-arg ${{ matrix.build_args }} \
176+ --platform ${{ env.RELEASE_PLATFORMS }} \
177+ --output type=docker,dest=docker_images/image-${{ matrix.tag_suffix }}.tar \
178+ .
179+
180+ - name : Upload Docker images
181+ uses : actions/upload-artifact@v4
182+ with :
183+ name : ${{ env.ARTIFACT_NAME_DOCKER_IMAGES }}
184+ path : docker_images/*.tar
185+ retention-days : 1
186+
187+ create_release :
188+ needs : [build_beta_binaries, build_docker_images]
189+ runs-on : ubuntu-latest
190+ steps :
191+ - name : Download all artifacts
192+ run : |
193+ mkdir -p release_assets
194+ artifacts=(beta_binaries docker_images)
195+ for art in "${artifacts[@]}"; do
196+ artifact_name=$(echo $art | tr '[:lower:]' '[:upper:]' | sed 's/_/ /g')
197+ gh release download --repo $GITHUB_REPOSITORY \
198+ --pattern "$artifact_name*" \
199+ --dir release_assets/$art
200+ done
201+
202+ - name : Prepare release assets
203+ run : |
204+ mkdir -p combined_assets
205+ # 合并所有构建产物
206+ find release_assets -type f -exec cp {} combined_assets \;
207+ echo "Total files: $(ls -1 combined_assets | wc -l)"
208+
209+ - name : Generate UTC timestamp
210+ id : timestamp
211+ run : |
212+ UTC_TIME=$(date -u +"%Y-%m-%d %H:%M")
213+ echo "release_title=Build @ UTC $UTC_TIME" >> $GITHUB_ENV
214+ echo "release_tag=build-$(date -u +"%Y%m%d-%H%M")" >> $GITHUB_ENV
215+
216+ - name : Create Release
217+ uses : softprops/action-gh-release@v2
218+ with :
219+ tag_name : ${{ env.release_tag }}
220+ name : ${{ env.release_title }}
221+ files : combined_assets/*
222+ token : ${{ secrets.WF_TOKEN }}
223+ draft : false
224+ prerelease : true
0 commit comments