|
| 1 | +name: Build macOS App |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: |
| 7 | + - "v*" # This will trigger the workflow on push of tags starting with 'v' |
| 8 | + pull_request: |
| 9 | + branches: [main] |
| 10 | + |
| 11 | +env: |
| 12 | + PROJECT_NAME: BrewServicesMenubar |
| 13 | + SCHEME_NAME: BrewServicesMenubar |
| 14 | + XCODE_VERSION: 15.4 |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: macos-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Select Xcode |
| 24 | + run: sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app |
| 25 | + |
| 26 | + - name: Cache Swift packages |
| 27 | + uses: actions/cache@v4 |
| 28 | + with: |
| 29 | + path: .build |
| 30 | + key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-spm- |
| 33 | +
|
| 34 | + - name: Build |
| 35 | + run: | |
| 36 | + xcodebuild clean build -project ${PROJECT_NAME}.xcodeproj -scheme ${SCHEME_NAME} -destination 'platform=macOS' |
| 37 | +
|
| 38 | + - name: Archive app |
| 39 | + run: | |
| 40 | + xcodebuild -project ${PROJECT_NAME}.xcodeproj -scheme ${SCHEME_NAME} -configuration Release archive -archivePath $PWD/build/${PROJECT_NAME}.xcarchive |
| 41 | +
|
| 42 | + - name: Export app |
| 43 | + run: | |
| 44 | + xcodebuild -exportArchive -archivePath $PWD/build/${PROJECT_NAME}.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath $PWD/build |
| 45 | +
|
| 46 | + - name: Get version |
| 47 | + id: get_version |
| 48 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 49 | + if: startsWith(github.ref, 'refs/tags/') |
| 50 | + |
| 51 | + - name: Zip .app for upload |
| 52 | + run: | |
| 53 | + cd $PWD/build |
| 54 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 55 | + zip -r ${{ env.PROJECT_NAME }}-${{ steps.get_version.outputs.VERSION }}.zip ${{ env.PROJECT_NAME }}.app |
| 56 | + else |
| 57 | + zip -r ${{ env.PROJECT_NAME }}.zip ${{ env.PROJECT_NAME }}.app |
| 58 | + fi |
| 59 | + echo "ZIP_FILE=${{ env.PROJECT_NAME }}${{ startsWith(github.ref, 'refs/tags/') && format('-{0}', steps.get_version.outputs.VERSION) || '' }}.zip" >> $GITHUB_ENV |
| 60 | + ls -la # Debug: List contents of current directory |
| 61 | +
|
| 62 | + - name: Debug - List build directory |
| 63 | + run: | |
| 64 | + echo "Contents of $PWD/build:" |
| 65 | + ls -R $PWD/build |
| 66 | +
|
| 67 | + - name: Upload artifact |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: ${{ env.PROJECT_NAME }} |
| 71 | + path: ${{ github.workspace }}/build/${{ env.ZIP_FILE }} |
| 72 | + if: success() |
| 73 | + |
| 74 | + - name: Upload build directory (for debugging) |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: build-directory-contents |
| 78 | + path: $PWD/build |
| 79 | + if: failure() |
| 80 | + |
| 81 | + - name: Create Release |
| 82 | + if: startsWith(github.ref, 'refs/tags/') |
| 83 | + uses: softprops/action-gh-release@v2 |
| 84 | + with: |
| 85 | + files: ${{ github.workspace }}/build/${{ env.ZIP_FILE }} |
| 86 | + draft: false |
| 87 | + prerelease: false |
0 commit comments