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 cce6157 commit 019ec3d
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,35 @@ jobs:
GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
run: |
VERSION=$(node -p -e "require('./package.json').version")
RELEASE_TAG="$VERSION-beta"
RELEASE_TAG="v$VERSION-beta"
RELEASE_NAME="Release $RELEASE_TAG"
RELEASE_DESCRIPTION="Automated release for version $RELEASE_TAG"
# 创建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" \
"https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/releases")
if [ $? -ne 0 ]; then
echo "Failed to create GitLab release"
echo "$release_response"
exit 1
fi
RELEASE_DESCRIPTION="Automated release for version $VERSION (Beta)"
# 检查release是否已存在
existing_release=$(curl --silent --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
"https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/releases/$RELEASE_TAG")
if [ "$(echo $existing_release | jq -r '.message')" != "404 Release Not Found" ]; then
echo "Release $RELEASE_TAG already exists. Skipping creation."
else
# 创建GitLab release
release_response=$(curl --fail --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--header "Content-Type: application/json" \
--data "{
\"name\": \"$RELEASE_NAME\",
\"tag_name\": \"$RELEASE_TAG\",
\"description\": \"$RELEASE_DESCRIPTION\"
}" \
"https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/releases")
if [ $? -ne 0 ]; then
echo "Failed to create GitLab release"
echo "$release_response"
exit 1
fi
# 获取release ID
release_id=$(echo $release_response | jq -r '.id')
echo "GitLab release created successfully"
fi
# 上传文件函数
upload_file() {
Expand All @@ -103,8 +113,9 @@ jobs:
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")
--form "link_type=package" \
--form "name=$asset_link_name" \
"https://gitlab.com/api/v4/projects/$GITLAB_PROJECT_ID/releases/$RELEASE_TAG/assets/links")
if [ $? -ne 0 ]; then
echo "Failed to upload $asset_name"
Expand All @@ -119,4 +130,4 @@ jobs:
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"
echo "Assets uploaded successfully"

0 comments on commit 019ec3d

Please sign in to comment.