build-hoppscotch-agent.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. on:
  2. workflow_dispatch:
  3. inputs:
  4. version:
  5. description: Tag of the version to build
  6. required: true
  7. env:
  8. CARGO_TERM_COLOR: always
  9. jobs:
  10. build:
  11. strategy:
  12. fail-fast: false
  13. matrix:
  14. platform: [macos-latest, ubuntu-22.04, windows-latest]
  15. runs-on: ${{ matrix.platform }}
  16. defaults:
  17. run:
  18. shell: bash
  19. steps:
  20. - name: Checkout hoppscotch/hoppscotch
  21. uses: actions/checkout@v3
  22. with:
  23. repository: hoppscotch/hoppscotch
  24. ref: main
  25. token: ${{ secrets.CHECKOUT_GITHUB_TOKEN }}
  26. - name: Setup Node.js
  27. uses: actions/setup-node@v3
  28. with:
  29. node-version: 20
  30. - name: Setup pnpm
  31. uses: pnpm/action-setup@v2
  32. with:
  33. version: 9
  34. - name: Install Rust
  35. uses: actions-rs/toolchain@v1
  36. with:
  37. toolchain: stable
  38. override: true
  39. - name: Install Rust targets (Mac)
  40. if: matrix.platform == 'macos-latest'
  41. run: |
  42. rustup target add aarch64-apple-darwin
  43. rustup target add x86_64-apple-darwin
  44. - name: Install additional tools (Linux)
  45. if: matrix.platform == 'ubuntu-22.04'
  46. run: |
  47. # Install Tauri CLI (binary)
  48. curl -LO "https://github.com/tauri-apps/tauri/releases/download/tauri-cli-v2.0.1/cargo-tauri-x86_64-unknown-linux-gnu.tgz"
  49. tar -xzf cargo-tauri-x86_64-unknown-linux-gnu.tgz
  50. chmod +x cargo-tauri
  51. sudo mv cargo-tauri /usr/local/bin/tauri
  52. # Install Trunk (binary)
  53. curl -LO "https://github.com/thedodd/trunk/releases/download/v0.17.5/trunk-x86_64-unknown-linux-gnu.tar.gz"
  54. tar -xzf trunk-x86_64-unknown-linux-gnu.tar.gz
  55. chmod +x trunk
  56. sudo mv trunk /usr/local/bin/
  57. - name: Install additional tools (Mac)
  58. if: matrix.platform == 'macos-latest'
  59. run: |
  60. # Install Tauri CLI (binary)
  61. mkdir __dist/
  62. cd __dist/
  63. curl -LO "https://github.com/tauri-apps/tauri/releases/download/tauri-cli-v2.0.1/cargo-tauri-aarch64-apple-darwin.zip"
  64. unzip cargo-tauri-aarch64-apple-darwin.zip
  65. chmod +x cargo-tauri
  66. sudo mv cargo-tauri /usr/local/bin/tauri
  67. - name: Install system dependencies (Ubuntu only)
  68. if: matrix.platform == 'ubuntu-22.04'
  69. run: |
  70. sudo apt-get update
  71. sudo apt-get install -y libwebkit2gtk-4.1-dev \
  72. build-essential \
  73. curl \
  74. wget \
  75. file \
  76. libxdo-dev \
  77. libssl-dev \
  78. libayatana-appindicator3-dev \
  79. librsvg2-dev
  80. - name: Setting up Windows Environment and injecting before bundle command (Windows only)
  81. if: matrix.platform == 'windows-latest'
  82. shell: bash
  83. env:
  84. WINDOWS_SIGN_COMMAND: trusted-signing-cli -e ${{ secrets.AZURE_ENDPOINT }} -a ${{ secrets.AZURE_CODE_SIGNING_NAME }} -c ${{ secrets.AZURE_CERT_PROFILE_NAME }} %1
  85. run: |
  86. cd packages/hoppscotch-agent
  87. # Inject signing command into main conf.
  88. cat './src-tauri/tauri.conf.json' | jq '.bundle .windows += { "signCommand": env.WINDOWS_SIGN_COMMAND}' > './src-tauri/temp.json' && mv './src-tauri/temp.json' './src-tauri/tauri.conf.json'
  89. # Inject signing command into portable conf.
  90. cat './src-tauri/tauri.portable.conf.json' | jq '.bundle .windows += { "signCommand": env.WINDOWS_SIGN_COMMAND}' > './src-tauri/temp_portable.json' && mv './src-tauri/temp_portable.json' './src-tauri/tauri.portable.conf.json'
  91. cargo install trusted-signing-cli@0.3.0
  92. - name: Set platform-specific variables
  93. run: |
  94. if [ "${{ matrix.platform }}" = "ubuntu-22.04" ]; then
  95. echo "target_arch=$(rustc -Vv | grep host | awk '{print $2}')" >> $GITHUB_ENV
  96. echo "target_ext=" >> $GITHUB_ENV
  97. echo "target_os_name=linux" >> $GITHUB_ENV
  98. elif [ "${{ matrix.platform }}" = "windows-latest" ]; then
  99. echo "target_arch=x86_64-pc-windows-msvc" >> $GITHUB_ENV
  100. echo "target_ext=.exe" >> $GITHUB_ENV
  101. echo "target_os_name=win" >> $GITHUB_ENV
  102. elif [ "${{ matrix.platform }}" = "macos-latest" ]; then
  103. echo "target_os_name=mac" >> $GITHUB_ENV
  104. fi
  105. - name: Setup macOS code signing
  106. if: matrix.platform == 'macos-latest'
  107. env:
  108. APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
  109. APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  110. APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
  111. KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
  112. run: |
  113. echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
  114. security create-keychain -p $KEYCHAIN_PASSWORD build.keychain
  115. security default-keychain -s build.keychain
  116. security unlock-keychain -p $KEYCHAIN_PASSWORD build.keychain
  117. security import certificate.p12 -k build.keychain -P $APPLE_CERTIFICATE_PASSWORD -T /usr/bin/codesign
  118. security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $KEYCHAIN_PASSWORD build.keychain
  119. - name: Cache Rust dependencies
  120. uses: actions/cache@v3
  121. with:
  122. path: |
  123. ~/.cargo/registry
  124. ~/.cargo/git
  125. target
  126. key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  127. - name: Install dependencies
  128. shell: bash
  129. run: |
  130. cd packages/hoppscotch-agent
  131. pnpm install --filter hoppscotch-agent
  132. - name: Build Tauri app (Linux)
  133. if: matrix.platform == 'ubuntu-22.04'
  134. env:
  135. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  136. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.AGENT_TAURI_SIGNING_PRIVATE_KEY }}
  137. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.AGENT_TAURI_SIGNING_PASSWORD }}
  138. run: |
  139. cd packages/hoppscotch-agent
  140. pnpm tauri build --verbose -b deb -b appimage -b updater
  141. - name: Build Tauri app (Mac)
  142. if: matrix.platform == 'macos-latest'
  143. env:
  144. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  145. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.AGENT_TAURI_SIGNING_PRIVATE_KEY }}
  146. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.AGENT_TAURI_SIGNING_PASSWORD }}
  147. APPLE_ID: ${{ secrets.APPLE_ID }}
  148. APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
  149. APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
  150. APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
  151. run: |
  152. cd packages/hoppscotch-agent
  153. pnpm tauri build --verbose --target x86_64-apple-darwin
  154. pnpm tauri build --verbose --target aarch64-apple-darwin
  155. - name: Build Tauri app (Windows)
  156. if: matrix.platform == 'windows-latest'
  157. shell: powershell
  158. env:
  159. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  160. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.AGENT_TAURI_SIGNING_PRIVATE_KEY }}
  161. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.AGENT_TAURI_SIGNING_PASSWORD }}
  162. AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
  163. AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
  164. AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
  165. run: |
  166. cd packages/hoppscotch-agent
  167. # Build the portable version first and move it.
  168. # This way the next build will regenerate `hoppscotch-agent.exe`.
  169. pnpm tauri build --verbose --config src-tauri/tauri.portable.conf.json -- --no-default-features --features portable
  170. Rename-Item -Path "src-tauri/target/release/hoppscotch-agent.exe" -NewName "hoppscotch-agent-portable.exe"
  171. # Build the installer version.
  172. pnpm tauri build --verbose -b msi -b updater
  173. - name: Zip portable executable (Windows)
  174. if: matrix.platform == 'windows-latest'
  175. shell: powershell
  176. run: |
  177. Compress-Archive -Path "packages/hoppscotch-agent/src-tauri/target/release/hoppscotch-agent-portable.exe" -DestinationPath "packages/hoppscotch-agent/src-tauri/target/release/Hoppscotch_Agent_win_x64_portable.zip"
  178. - name: Prepare artifacts
  179. shell: bash
  180. run: |
  181. mkdir artifacts
  182. mkdir artifacts/sigs
  183. if [ "${{ matrix.platform }}" = "ubuntu-22.04" ]; then
  184. mv packages/hoppscotch-agent/src-tauri/target/release/bundle/appimage/*.AppImage artifacts/Hoppscotch_Agent_linux_x64.AppImage
  185. mv packages/hoppscotch-agent/src-tauri/target/release/bundle/appimage/*.AppImage.sig artifacts/sigs/Hoppscotch_Agent_linux_x64.AppImage.sig
  186. mv packages/hoppscotch-agent/src-tauri/target/release/bundle/deb/*.deb artifacts/Hoppscotch_Agent_linux_x64.deb
  187. elif [ "${{ matrix.platform }}" = "macos-latest" ]; then
  188. mv packages/hoppscotch-agent/src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*_x64.dmg artifacts/Hoppscotch_Agent_mac_x64.dmg
  189. mv packages/hoppscotch-agent/src-tauri/target/x86_64-apple-darwin/release/bundle/macos/*.app.tar.gz artifacts/Hoppscotch_Agent_mac_update_x64.tar.gz
  190. mv packages/hoppscotch-agent/src-tauri/target/x86_64-apple-darwin/release/bundle/macos/*.app.tar.gz.sig artifacts/sigs/Hoppscotch_Agent_mac_update_x64.tar.gz.sig
  191. mv packages/hoppscotch-agent/src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*_aarch64.dmg artifacts/Hoppscotch_Agent_mac_aarch64.dmg
  192. mv packages/hoppscotch-agent/src-tauri/target/aarch64-apple-darwin/release/bundle/macos/*.app.tar.gz artifacts/Hoppscotch_Agent_mac_update_aarch64.tar.gz
  193. mv packages/hoppscotch-agent/src-tauri/target/aarch64-apple-darwin/release/bundle/macos/*.app.tar.gz.sig artifacts/sigs/Hoppscotch_Agent_mac_update_aarch64.tar.gz.sig
  194. elif [ "${{ matrix.platform }}" = "windows-latest" ]; then
  195. mv packages/hoppscotch-agent/src-tauri/target/release/bundle/msi/*_x64_en-US.msi artifacts/Hoppscotch_Agent_win_x64.msi
  196. mv packages/hoppscotch-agent/src-tauri/target/release/bundle/msi/*_x64_en-US.msi.sig artifacts/sigs/Hoppscotch_Agent_win_x64.msi.sig
  197. mv packages/hoppscotch-agent/src-tauri/target/release/Hoppscotch_Agent_win_x64_portable.zip artifacts/Hoppscotch_Agent_win_x64_portable.zip
  198. fi
  199. - name: Generate checksums (Linux)
  200. if: matrix.platform == 'ubuntu-22.04'
  201. run: |
  202. cd artifacts
  203. mkdir shas
  204. for file in *; do
  205. if [ -f "$file" ]; then
  206. sha256sum "$file" > "shas/${file}.sha256"
  207. fi
  208. done
  209. - name: Generate checksums (Mac)
  210. if: matrix.platform == 'macos-latest'
  211. run: |
  212. cd artifacts
  213. mkdir shas
  214. for file in *; do
  215. if [ -f "$file" ]; then
  216. shasum -a 256 "$file" > "shas/${file}.sha256"
  217. fi
  218. done
  219. - name: Upload artifacts
  220. uses: actions/upload-artifact@v4
  221. with:
  222. name: Hoppscotch_Agent-${{ matrix.platform }}
  223. path: artifacts/*