diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml deleted file mode 100644 index 3669951..0000000 --- a/.github/workflows/build-and-release.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Build and Release - -on: - push: - branches: ["main"] - -jobs: - build: - runs-on: macos-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Xcode - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Build - run: | - xcodebuild clean archive \ - -project MacMusicPlayer.xcodeproj \ - -scheme MacMusicPlayer \ - -archivePath $PWD/build/MacMusicPlayer.xcarchive \ - -configuration Release - CODE_SIGN_IDENTITY="" \ - CODE_SIGNING_REQUIRED=NO \ - ONLY_ACTIVE_ARCH=NO \ - ARCHS="arm64 x86_64" - - - name: Create app - run: | - xcodebuild -exportArchive \ - -archivePath $PWD/build/MacMusicPlayer.xcarchive \ - -exportOptionsPlist exportOptions.plist \ - -exportPath $PWD/build/export \ - ONLY_ACTIVE_ARCH=NO \ - ARCHS="arm64 x86_64" - - - name: Prepare for DMG - run: | - mkdir -p dist/dmg_temp - mv build/export/MacMusicPlayer.app dist/dmg_temp/ - ln -s /Applications dist/dmg_temp/Applications - ls -R dist/dmg_temp - - - name: Create DMG - run: | - hdiutil create -volname MacMusicPlayer \ - -srcfolder dist/dmg_temp \ - -ov -format UDZO dist/MacMusicPlayer.dmg - - - name: Create Release and Upload Asset - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create v${{ github.run_number }} \ - --title "Release ${{ github.run_number }}" \ - --notes "Release ${{ github.run_number }}" \ - ./dist/MacMusicPlayer.dmg diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 0000000..f9fab81 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,51 @@ +name: PR Check + +on: + pull_request: + branches: [ main ] + paths-ignore: + - '**.md' + - '.gitignore' + - '.github/**' + - '!.github/workflows/**' + +jobs: + build: + name: Build and Test + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Build + run: | + xcodebuild clean build -project MacMusicPlayer.xcodeproj \ + -scheme MacMusicPlayer \ + -destination "platform=macOS" \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGNING_ALLOWED=NO + + - name: Check Build Status + if: failure() + uses: actions/github-script@v6 + with: + script: | + core.setFailed('Build failed. Please check the build logs for details.') + + - name: Comment PR + if: failure() + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '❌ Build failed. Please check the build logs and fix the issues before merging.' + }) \ No newline at end of file diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml deleted file mode 100644 index 3464a62..0000000 --- a/.github/workflows/pr-test.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Pull Request Test - -on: - pull_request: - branches: [ "main" ] # 监听针对 main 分支的 PR - -jobs: - build-and-test: - runs-on: macos-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Xcode - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Build - run: | - xcodebuild clean build \ - -project MacMusicPlayer.xcodeproj \ - -scheme MacMusicPlayer \ - -configuration Release \ - -sdk macosx \ - -destination 'generic/platform=macOS,name=Any Mac' \ - -derivedDataPath build \ - CODE_SIGN_IDENTITY="" \ - CODE_SIGNING_REQUIRED=NO \ - ONLY_ACTIVE_ARCH=NO \ - ARCHS="x86_64 arm64" - - - name: Verify Architectures - run: | - # 定义构建的应用程序路径 - APP_PATH="build/Build/Products/Release/MacMusicPlayer.app" - echo "App Path: $APP_PATH" - - # 检查应用程序是否存在 - if [ ! -d "$APP_PATH" ]; then - echo "Error: Application not found at $APP_PATH" - exit 1 - fi - - # 查找可执行文件的路径 - EXECUTABLE_PATH="$APP_PATH/Contents/MacOS/MacMusicPlayer" - echo "Executable Path: $EXECUTABLE_PATH" - - # 显示可执行文件的架构信息 - lipo -info "$EXECUTABLE_PATH" - - # 验证是否支持 x86_64 架构 - if lipo -info "$EXECUTABLE_PATH" | grep -q "x86_64"; then - echo "x86_64 architecture is supported." - else - echo "Error: x86_64 architecture is not supported!" - exit 1 - fi - - # 验证是否支持 arm64 架构 - if lipo -info "$EXECUTABLE_PATH" | grep -q "arm64"; then - echo "arm64 architecture is supported." - else - echo "Error: arm64 architecture is not supported!" - exit 1 - fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d11ea2e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + release: + name: Create Release + runs-on: macos-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Get version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build + run: | + xcodebuild clean archive -project MacMusicPlayer.xcodeproj \ + -scheme MacMusicPlayer \ + -archivePath ./build/MacMusicPlayer.xcarchive \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGNING_ALLOWED=NO + + - name: Create DMG + run: | + # Create a temporary directory for mounting + TEMP_DIR=$(mktemp -d) + + # Create a DMG + hdiutil create -volname "MacMusicPlayer" -srcfolder "./build/MacMusicPlayer.xcarchive/Products/Applications/MacMusicPlayer.app" \ + -ov -format UDZO "MacMusicPlayer-${{ env.VERSION }}.dmg" + + - name: Generate Release Notes + id: release_notes + run: | + echo "## MacMusicPlayer ${{ env.VERSION }}" > release_notes.md + echo "" >> release_notes.md + echo "### 更新内容" >> release_notes.md + echo "- 请查看具体提交记录了解详细更新内容" >> release_notes.md + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + name: MacMusicPlayer ${{ env.VERSION }} + body_path: release_notes.md + draft: false + prerelease: false + files: | + MacMusicPlayer-${{ env.VERSION }}.dmg + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update Latest Tag + run: | + git tag -f latest + git push origin latest --force \ No newline at end of file