fix: clean build folder before building release and update architectu… #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| build-and-test: | |
| name: Build and Test | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Cache Swift packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .build | |
| .build/checkouts | |
| .build/reports | |
| .swiftpm | |
| key: ${{ runner.os }}-swift-${{ hashFiles('Package.resolved') }} | |
| restore-keys: | | |
| ${{ runner.os }}-swift- | |
| - name: Show Swift version | |
| run: swift --version | |
| - name: Build | |
| run: swift build | |
| - name: Test | |
| run: swift test --verbose || true | |
| release: | |
| name: Release on Tag | |
| runs-on: macos-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: build-and-test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Show Swift version | |
| run: swift --version | |
| - name: Clean build folder | |
| run: make clean # Guarantees SPM doesn't use old cached files | |
| - name: Build .app bundle | |
| run: make app | |
| - name: Verify Universal Binary | |
| run: | | |
| echo "Checking architecture of the compiled binary..." | |
| BINARY_PATH="build/ScreenPrankLocker.app/Contents/MacOS/ScreenPrankLocker" | |
| lipo -info "$BINARY_PATH" | |
| if ! lipo -info "$BINARY_PATH" | grep -q "x86_64"; then | |
| echo "Error: Missing x86_64 (Intel) architecture!" | |
| exit 1 | |
| fi | |
| if ! lipo -info "$BINARY_PATH" | grep -q "arm64"; then | |
| echo "Error: Missing arm64 (Apple Silicon) architecture!" | |
| exit 1 | |
| fi | |
| echo "Success: Binary is universally fat and ready to pack!" | |
| - name: Build DMG | |
| run: make dmg | |
| - name: Upload DMG as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: screenpranklocker-dmg | |
| path: build/*.dmg | |
| - name: Find DMG | |
| id: find_dmg | |
| run: | | |
| set -e | |
| dmg=$(ls build/*.dmg | head -n1) | |
| echo "dmg=$dmg" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| release_name: Release ${{ github.ref_name }} | |
| body: "Automated release built by CI" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload DMG to Release | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_dmg.outputs.dmg }} | |
| asset_name: ${{ steps.find_dmg.outputs.dmg }} | |
| asset_content_type: application/x-apple-diskimage |