Skip to content

Commit

Permalink
feat: support pr test,and support x86_64
Browse files Browse the repository at this point in the history
Signed-off-by: samzong <[email protected]>
  • Loading branch information
samzong committed Oct 22, 2024
1 parent 8a379bb commit b430240
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 36 deletions.
82 changes: 47 additions & 35 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,56 @@ name: Build and Release

on:
push:
branches: [ "main" ]
branches: ["main"]

jobs:
build:
runs-on: macos-latest

steps:
- 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 CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
- name: Create app
run: |
xcodebuild -exportArchive -archivePath $PWD/build/MacMusicPlayer.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build/export
- name: Prepare for DMG
run: |
mkdir -p dist
mv build/export/MacMusicPlayer.app dist/
ls -R dist
- name: Create DMG
run: |
hdiutil create -volname MacMusicPlayer -srcfolder dist -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
- 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
- name: Prepare for DMG
run: |
mkdir -p dist
mv build/export/MacMusicPlayer.app dist/
ls -R dist
- name: Create DMG
run: |
hdiutil create -volname MacMusicPlayer \
-srcfolder dist \
-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
42 changes: 42 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Pull Request Test

on:
pull_request:
branches: ["main"] # Listen for PRs targeting the main branch

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 \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
ONLY_ACTIVE_ARCH=NO \
ARCHS="x86_64 arm64"
- name: Verify Architectures
run: |
# Find the path of the application.
APP_PATH=$(find $PWD -name MacMusicPlayer.app -type d | head -n 1)
echo "App Path: $APP_PATH"
# Find the path of the executable file.
EXECUTABLE_PATH="$APP_PATH/Contents/MacOS/MacMusicPlayer"
echo "Executable Path: $EXECUTABLE_PATH"
# Display the architecture information
lipo -info "$EXECUTABLE_PATH"
2 changes: 1 addition & 1 deletion MacMusicPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
MACOSX_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down

0 comments on commit b430240

Please sign in to comment.