From 31702b2b4a92120cc6f23a5688a812c21f54d88d Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Sun, 30 Jun 2024 17:20:53 +0200 Subject: [PATCH 1/2] Build app using github actions --- .github/workflows/macos.yml | 61 +++++++++++++++++++++++++++++++++++++ ExportOptions.plist | 18 +++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/macos.yml create mode 100644 ExportOptions.plist diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..42af0c5 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,61 @@ +name: Build macOS App + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + PROJECT_NAME: BrewServicesMenubar + SCHEME_NAME: BrewServicesMenubar + XCODE_VERSION: 15.4 + +jobs: + build: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app + + - name: Cache Swift packages + uses: actions/cache@v4 + with: + path: .build + key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm- + + - name: Build + run: | + xcodebuild clean build -project ${PROJECT_NAME}.xcodeproj -scheme ${SCHEME_NAME} -destination 'platform=macOS' + + - name: Archive app + run: | + xcodebuild -project ${PROJECT_NAME}.xcodeproj -scheme ${SCHEME_NAME} -configuration Release archive -archivePath $PWD/build/${PROJECT_NAME}.xcarchive + + - name: Export app + run: | + xcodebuild -exportArchive -archivePath $PWD/build/${PROJECT_NAME}.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath $PWD/build + + - name: Zip .app for upload + run: | + cd $PWD/build + zip -r ${{ env.PROJECT_NAME }}.zip ${{ env.PROJECT_NAME }}.app + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PROJECT_NAME }} + path: build/${{ env.PROJECT_NAME }}.zip + if: success() + + - name: Upload build directory (for debugging) + uses: actions/upload-artifact@v4 + with: + name: build-directory-contents + path: $PWD/build + if: failure() diff --git a/ExportOptions.plist b/ExportOptions.plist new file mode 100644 index 0000000..2117860 --- /dev/null +++ b/ExportOptions.plist @@ -0,0 +1,18 @@ + + + + + method + mac-application + teamID + PS3M4R7DP9 + signingStyle + automatic + stripSwiftSymbols + + uploadSymbols + + uploadBitcode + + + From dd12689e9968d7e8b16abbf3c1c1744da1a2238f Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Sun, 30 Jun 2024 18:16:28 +0200 Subject: [PATCH 2/2] Create a GitHub release when pushing a new vX.X tag --- .github/workflows/macos.yml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 42af0c5..9daacea 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -3,6 +3,8 @@ name: Build macOS App on: push: branches: [main] + tags: + - "v*" # This will trigger the workflow on push of tags starting with 'v' pull_request: branches: [main] @@ -41,16 +43,32 @@ jobs: run: | xcodebuild -exportArchive -archivePath $PWD/build/${PROJECT_NAME}.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath $PWD/build + - name: Get version + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + if: startsWith(github.ref, 'refs/tags/') + - name: Zip .app for upload run: | cd $PWD/build - zip -r ${{ env.PROJECT_NAME }}.zip ${{ env.PROJECT_NAME }}.app + if [[ $GITHUB_REF == refs/tags/* ]]; then + zip -r ${{ env.PROJECT_NAME }}-${{ steps.get_version.outputs.VERSION }}.zip ${{ env.PROJECT_NAME }}.app + else + zip -r ${{ env.PROJECT_NAME }}.zip ${{ env.PROJECT_NAME }}.app + fi + echo "ZIP_FILE=${{ env.PROJECT_NAME }}${{ startsWith(github.ref, 'refs/tags/') && format('-{0}', steps.get_version.outputs.VERSION) || '' }}.zip" >> $GITHUB_ENV + ls -la # Debug: List contents of current directory + + - name: Debug - List build directory + run: | + echo "Contents of $PWD/build:" + ls -R $PWD/build - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ env.PROJECT_NAME }} - path: build/${{ env.PROJECT_NAME }}.zip + path: ${{ github.workspace }}/build/${{ env.ZIP_FILE }} if: success() - name: Upload build directory (for debugging) @@ -59,3 +77,11 @@ jobs: name: build-directory-contents path: $PWD/build if: failure() + + - name: Create Release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: ${{ github.workspace }}/build/${{ env.ZIP_FILE }} + draft: false + prerelease: false