Skip to content

Commit

Permalink
chore: update beta.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfan0 committed Aug 28, 2024
1 parent 1e8f598 commit cce6157
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ jobs:
name: build-mac-arm-${{ env.VERSION }}-beta
path: dist/fideo-${{ env.VERSION }}-arm64.dmg
create_release:
needs: [build] # 确保在所有构建完成后运行
runs-on: ubuntu-latest # 使用一个固定的环境
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand All @@ -74,50 +74,49 @@ jobs:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
run: |
# 获取版本号
VERSION=$(node -p -e "require('./package.json').version")
# 定义变量
RELEASE_TAG="$VERSION-beta"
RELEASE_NAME="Release $RELEASE_TAG"
RELEASE_DESCRIPTION="Automated release for version $RELEASE_TAG"
# 上传并获取资产URL的函数
upload_asset() {
local file=$1
local name=$2
local url=$(curl --fail --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--form "file=@$file" \
"https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/uploads" | jq -r '.url')
if [ -z "$url" ]; then
echo "Failed to upload $name"
exit 1
fi
echo "$name=$url"
}
# 上传资产
WIN_ASSET_URL=$(upload_asset "artifacts/build-win-$VERSION-beta/fideo-$VERSION.exe" "Windows")
MAC_X64_ASSET_URL=$(upload_asset "artifacts/build-mac-x64-$VERSION-beta/fideo-$VERSION-x64.dmg" "macOS x64")
MAC_ARM_ASSET_URL=$(upload_asset "artifacts/build-mac-arm-$VERSION-beta/fideo-$VERSION-arm64.dmg" "macOS ARM")
# 创建GitLab发布
response=$(curl --fail --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
# 创建GitLab release
release_response=$(curl --fail --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--data "name=$RELEASE_NAME" \
--data "tag_name=$RELEASE_TAG" \
--data "description=$RELEASE_DESCRIPTION" \
--data "assets[links][][name]=Windows" \
--data "assets[links][][url]=$WIN_ASSET_URL" \
--data "assets[links][][name]=macOS x64" \
--data "assets[links][][url]=$MAC_X64_ASSET_URL" \
--data "assets[links][][name]=macOS ARM" \
--data "assets[links][][url]=$MAC_ARM_ASSET_URL" \
"https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/releases")
if [ $? -ne 0 ]; then
echo "Failed to create GitLab release"
echo "$response"
echo "$release_response"
exit 1
fi
echo "GitLab release created successfully"
# 获取release ID
release_id=$(echo $release_response | jq -r '.id')
# 上传文件函数
upload_file() {
local file=$1
local asset_name=$2
local asset_link_name=$3
response=$(curl --fail --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--form "file=@$file" \
--form "asset_link_name=$asset_link_name" \
"https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/releases/$release_id/assets/links")
if [ $? -ne 0 ]; then
echo "Failed to upload $asset_name"
echo "$response"
exit 1
fi
echo "Uploaded $asset_name successfully"
}
# 上传文件
upload_file "artifacts/build-win-$VERSION-beta/fideo-$VERSION.exe" "Windows" "Windows Executable"
upload_file "artifacts/build-mac-x64-$VERSION-beta/fideo-$VERSION-x64.dmg" "macOS x64" "macOS x64 Disk Image"
upload_file "artifacts/build-mac-arm-$VERSION-beta/fideo-$VERSION-arm64.dmg" "macOS ARM" "macOS ARM Disk Image"
echo "GitLab release created and assets uploaded successfully"

0 comments on commit cce6157

Please sign in to comment.