From a7eaaa41a516ebc1114aef2d8848e71ce45edb06 Mon Sep 17 00:00:00 2001 From: ririxi Date: Sun, 21 Jul 2024 01:28:14 +0200 Subject: [PATCH] feat: build `macos-helper` --- .github/actions/release/linux/action.yml | 36 --------- .github/actions/release/macos/action.yml | 40 ---------- .github/actions/release/windows/action.yml | 45 ------------ .github/workflows/release-linux.yml | 40 ++++++++++ .github/workflows/release-macos.yml | 71 ++++++++++++++++++ .github/workflows/release-windows.yml | 51 +++++++++++++ .github/workflows/release.yml | 58 --------------- build/macos/build.sh | 24 +++--- build/macos/main.applescript | 85 ---------------------- 9 files changed, 172 insertions(+), 278 deletions(-) delete mode 100644 .github/actions/release/linux/action.yml delete mode 100644 .github/actions/release/macos/action.yml delete mode 100644 .github/actions/release/windows/action.yml create mode 100644 .github/workflows/release-linux.yml create mode 100644 .github/workflows/release-macos.yml create mode 100644 .github/workflows/release-windows.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 build/macos/main.applescript diff --git a/.github/actions/release/linux/action.yml b/.github/actions/release/linux/action.yml deleted file mode 100644 index a5d6977464..0000000000 --- a/.github/actions/release/linux/action.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Release for linux -inputs: - tag: - description: Tag - required: true - type: string - GH_TOKEN: - description: GitHub token - required: true - type: string -runs: - using: composite - steps: - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - - name: Build - shell: bash - run: | - set -e - mkdir dist - cd build/linux - chmod +x build.sh - ./build.sh ${{ inputs.tag }} amd64 - mv spicetify ../../dist/spicetify-${{ inputs.tag }}-linux-amd64 - ./build.sh ${{ inputs.tag }} arm64 - mv spicetify ../../dist/spicetify-${{ inputs.tag }}-linux-arm64 - - - name: Release - uses: softprops/action-gh-release@v2 - with: - files: "dist/*" - env: - GITHUB_TOKEN: ${{ inputs.GH_TOKEN }} diff --git a/.github/actions/release/macos/action.yml b/.github/actions/release/macos/action.yml deleted file mode 100644 index b0f436362d..0000000000 --- a/.github/actions/release/macos/action.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Release for macos -inputs: - tag: - description: Tag - required: true - type: string - GH_TOKEN: - description: GitHub token - required: true - type: string -runs: - using: composite - steps: - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - - shell: bash - run: brew install xmlstarlet - - - shell: bash - run: brew install create-dmg - - - name: Build - shell: bash - run: | - set -e - mkdir dist - cd build/macos - chmod +x build.sh - ./build.sh ${{ inputs.tag }} - mv spicetify.dmg ../../dist/spicetify-${{ inputs.tag }}.dmg - - - name: Release - uses: softprops/action-gh-release@v2 - with: - files: "dist/*" - env: - GITHUB_TOKEN: ${{ inputs.GH_TOKEN }} diff --git a/.github/actions/release/windows/action.yml b/.github/actions/release/windows/action.yml deleted file mode 100644 index aadab1945e..0000000000 --- a/.github/actions/release/windows/action.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Release for windows -inputs: - tag: - description: Tag - required: true - type: string - GH_TOKEN: - description: GitHub token - required: true - type: string -runs: - using: composite - steps: - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - - - name: Setup Wix - shell: pwsh - run: | - $ErrorActionPreference = 'Stop' - dotnet tool install -g wix - wix extension add -g WixToolset.Util.wixext - wix extension add -g WixToolset.UI.wixext - - - name: Build - shell: pwsh - run: | - $ErrorActionPreference = 'Stop' - mkdir dist - cd build\windows - .\build.ps1 -version ${{ inputs.tag }} -platform amd64 - mv spicetify.msi ..\..\dist\spicetify-${{ inputs.tag }}-amd64.msi - .\build.ps1 -version ${{ inputs.tag }} -platform arm64 - mv spicetify.msi ..\..\dist\spicetify-${{ inputs.tag }}-arm64.msi - .\build.ps1 -version ${{ inputs.tag }} -platform 386 - mv spicetify.msi ..\..\dist\spicetify-${{ inputs.tag }}-386.msi - - - name: Release - uses: softprops/action-gh-release@v2 - with: - files: "dist/*" - env: - GITHUB_TOKEN: ${{ inputs.GH_TOKEN }} diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml new file mode 100644 index 0000000000..af884b748f --- /dev/null +++ b/.github/workflows/release-linux.yml @@ -0,0 +1,40 @@ +name: Release (Linux) + +on: + release: + types: [published] + +jobs: + build: + permissions: + id-token: write + contents: write + attestations: write + name: Release (Linux) + strategy: + matrix: + arch: ["amd64", "arm64"] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v3') + steps: + - name: Set Tag in env + run: echo "tag=${GITHUB_REF#refs/*/v}" >> "$GITHUB_ENV" + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + - name: Build + shell: bash + run: | + mkdir dist + go build -o dist/spicetify-${{ env.tag }}-linux-${{ matrix.arch }} -ldflags "-X main.version=${{ env.tag }}" + env: + GOARCH: ${{ matrix.arch }} + - name: Upload artifact to release + uses: softprops/action-gh-release@v2 + with: + files: "dist/*" + env: + GITHUB_TOKEN: ${{ inputs.GH_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml new file mode 100644 index 0000000000..f573fbbd9a --- /dev/null +++ b/.github/workflows/release-macos.yml @@ -0,0 +1,71 @@ +name: Release (macOS) + +on: + release: + types: [published] + +jobs: + build: + permissions: + id-token: write + contents: write + attestations: write + name: Release (macOS) + strategy: + matrix: + arch: ["amd64", "arm64"] + runs-on: macos-latest + if: startsWith(github.ref, 'refs/tags/v3') + steps: + - name: Set Tag in env + run: echo "tag=${GITHUB_REF#refs/*/v}" >> "$GITHUB_ENV" + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + - name: Build + shell: bash + run: | + mkdir dist + go build -o dist/spicetify-${{ matrix.arch }} -ldflags "-X main.version=${{ env.tag }}" + env: + GOARCH: ${{ matrix.arch }} + - name: Upload macOS artifact + uses: actions/upload-artifact@v4 + with: + name: spicetify-${{ matrix.arch }} + path: dist/spicetify-${{ matrix.arch }} + + combine-release: + name: Combine macOS release + needs: [build] + runs-on: macos-latest + steps: + - name: Set Tag in env + run: echo "tag=${GITHUB_REF#refs/*/v}" >> "$GITHUB_ENV" + - name: Checkout + uses: actions/checkout@v4 + - shell: bash + run: mkdir dist + - name: Download macOS artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts/ + merge-multiple: true + - name: Combine releases + shell: bash + run: | + set -e + brew install create-dmg + cd build/macos + chmod +x build.sh + ./build.sh ${{ env.tag }} + mv spicetify.dmg ../../dist/spicetify-${{ env.tag }}.dmg + - name: Upload artifact to release + uses: softprops/action-gh-release@v2 + with: + files: "dist/*" + env: + GITHUB_TOKEN: ${{ inputs.GH_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml new file mode 100644 index 0000000000..d7cb7999cc --- /dev/null +++ b/.github/workflows/release-windows.yml @@ -0,0 +1,51 @@ +name: Release (Windows) + +on: + release: + types: [published] + +jobs: + build: + permissions: + id-token: write + contents: write + attestations: write + name: Release (Windows) + strategy: + matrix: + arch: ["amd64", "arm64", "386"] + runs-on: windows-latest + if: startsWith(github.ref, 'refs/tags/v3') + steps: + - name: Set Tag in env + shell: pwsh + run: | + $version = $env:GITHUB_REF -replace 'refs/.*/v', '' + echo "tag=$version" >> $env:GITHUB_ENV + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + - name: Setup Wix + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + dotnet tool install -g wix + wix extension add -g WixToolset.Util.wixext + wix extension add -g WixToolset.UI.wixext + - name: Build + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + mkdir dist + cd build\windows + .\build.ps1 -version ${{ env.tag }} -platform ${{ matrix.arch }} + mv spicetify.msi ..\..\dist\spicetify-${{ env.tag }}-${{ matrix.arch }}.msi + - name: Upload artifact to release + uses: softprops/action-gh-release@v2 + with: + files: "dist/*" + env: + GITHUB_TOKEN: ${{ inputs.GH_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a9e34af1dc..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Release - -on: - release: - types: [published] - -jobs: - release: - permissions: - id-token: write - contents: write - attestations: write - name: Release - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v3') - outputs: - tag: ${{ steps.set-env.outputs.tag }} - steps: - - id: set-env - name: Set Env - run: echo "tag=${GITHUB_REF#refs/*/v}" >> "$GITHUB_OUTPUT" - - macos: - name: Release for macos - needs: release - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: ./.github/actions/release/macos - with: - tag: ${{ needs.release.outputs.tag }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - linux: - name: Release for linux - needs: release - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: ./.github/actions/release/linux - with: - tag: ${{ needs.release.outputs.tag }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - windows: - name: Release for windows - needs: release - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: ./.github/actions/release/windows - with: - tag: ${{ needs.release.outputs.tag }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build/macos/build.sh b/build/macos/build.sh index c680bd4927..d9cdda707c 100644 --- a/build/macos/build.sh +++ b/build/macos/build.sh @@ -1,21 +1,17 @@ #!/usr/bin/env sh set -e -version=$1 +mkdir Volume && mkdir -p bin +lipo -create -output bin/spicetify ../../artifacts/spicetify-amd64 ../../artifacts/spicetify-arm64 && echo "Built universal binary" -mkdir Volume -osacompile -x -o Volume/Spicetify.app main.applescript -rm Volume/Spicetify.app/Contents/Resources/applet.icns -cp installer/AppIcon.icns Volume/Spicetify.app/Contents/Resources/AppIcon.icns - -GOARCH="amd64" go build -C ../../ -o build/macos/spicetify-amd64 -ldflags "-X main.version=$version" -GOARCH="arm64" go build -C ../../ -o build/macos/spicetify-arm64 -ldflags "-X main.version=$version" -mkdir -p Volume/Spicetify.app/Contents/MacOS/bin -lipo -create -output Volume/Spicetify.app/Contents/MacOS/bin/spicetify spicetify-amd64 spicetify-arm64 - -plutil -replace CFBundleName -string "Spicetify" Volume/Spicetify.app/Contents/Info.plist -plutil -replace CFBundleIconFile -string AppIcon.icns Volume/Spicetify.app/Contents/Info.plist -plutil -replace CFBundleURLTypes -xml 'CFBundleURLNameSpicetifyCFBundleURLSchemesspicetify' Volume/Spicetify.app/Contents/Info.plist +# Build the helper app with xcode +git clone https://github.com/rxri/spicetify-macos-helper.git +cd spicetify-macos-helper +cp -r ../bin spicetify/bin +sudo xcode-select -s /Applications/Xcode_15.4.app/Contents/Developer +xcodebuild -project spicetify.xcodeproj -scheme spicetify -configuration Release build SYMROOT="$(pwd)/build" +cp -r build/Release/spicetify.app ../Volume/Spicetify.app +cd .. codesign --deep --force --sign - --timestamp=none Volume/Spicetify.app diff --git a/build/macos/main.applescript b/build/macos/main.applescript deleted file mode 100644 index 5b9a5138bb..0000000000 --- a/build/macos/main.applescript +++ /dev/null @@ -1,85 +0,0 @@ -on ensureLineInFileIfExists(filePath, lineToAdd) - set ok to false - try - set fileAlias to POSIX file filePath as alias - local fileDescriptor - set fileDescriptor to open for access fileAlias with write permission - try - set lns to paragraphs of (read fileDescriptor) - repeat with ln in lns - if ln is lineToAdd then - set ok to true - exit repeat - end if - end repeat - if ok is false then - write return & lineToAdd & return to fileDescriptor starting at eof - set ok to true - end if - end try - close access fileDescriptor - end try - return ok -end findLineInFile - -on addLineToShellConfigs(lineToAdd) - set homeFolder to POSIX path of (path to home folder) - set configFiles to {homeFolder & ".bash_profile", homeFolder & ".zshrc"} - - repeat with configFile in configFiles - ensureLineInFileIfExists(configFile, lineToAdd) - end repeat -end addLineToShellConfigs - -on launchAgentExists(agentName) - try - do shell script "launchctl list | grep " & quoted form of agentName - return true - on error - return false - end try -end launchAgentExists - -on createLaunchAgent(plistPath, agentName, binPath) - set plistPathQ to quoted form of plistPath - do shell script "plutil -create xml1 " & plistPathQ - do shell script "plutil -insert Label -string " & quoted form of launchAgentName & " " & plistPathQ - do shell script "plutil -insert ProgramArguments -array -string " & quoted form of binPath & " -string daemon " & plistPathQ - do shell script "plutil -insert RunAtLoad -bool true " & plistPathQ -end createLaunchAgent - -on setupEnvironment(binFolder, binPath, launchAgentName) - set homeFolder to POSIX path of (path to home folder) - - set exportString to "export PATH=" & quote & binFolder & ":$PATH" & quote & " # Added by Spicetify" - addLineToShellConfigs(exportString) - - set launchAgentsFolder to homeFolder & "Library/LaunchAgents/" - set plistPath to launchAgentsFolder & launchAgentName & ".plist" - if not launchAgentExists(launchAgentName) then - createLaunchAgent(plistPath, launchAgentName, binPath) - do shell script "launchctl load -w " & quoted form of plistPath - do shell script quoted form of binPath & " init" - end if -end setupEnvironment - -on open location input - set dirname to POSIX path of (path to me) - set binFolder to dirname & "Contents/MacOS/bin/" - set binPath to binFolder & "spicetify" - - do shell script (quoted form of binPath) & " protocol " & (quoted form of input) -end open location - -on run - set dirname to POSIX path of (path to me) - set binFolder to dirname & "Contents/MacOS/bin/" - set binPath to binFolder & "spicetify" - - setupEnvironment(binFolder, binPath, "app.spicetify.daemon") - - tell application "Terminal" - activate - do script quoted form of binPath - end tell -end run