|
| 1 | +name: ProBuild |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - v*.*.* |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-latest |
| 16 | + arch: [ arm64, amd64 ] |
| 17 | + - os: macos-latest |
| 18 | + arch: [ arm64, amd64 ] |
| 19 | + - os: windows-latest |
| 20 | + arch: [ arm64, amd64 ] |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout Code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Git clone repo |
| 27 | + if: runner.os == 'Linux' || runner.os == 'macOS' |
| 28 | + env: |
| 29 | + GIT_USER: ${{ secrets.GIT_USER }} |
| 30 | + GIT_PASS: ${{ secrets.GIT_PASS }} |
| 31 | + GIT_REPO_BASE: ${{ secrets.GIT_REPO_BASE }} |
| 32 | + GIT_HOST: ${{ secrets.GIT_HOST }} |
| 33 | + run: | |
| 34 | + git clone -b main "https://${GIT_USER}:${GIT_PASS}@${GIT_HOST}/${GIT_REPO_BASE}/linkandroid-pro.git" code |
| 35 | +
|
| 36 | + - name: Git clone repo |
| 37 | + if: runner.os == 'Windows' |
| 38 | + env: |
| 39 | + GIT_USER: ${{ secrets.GIT_USER }} |
| 40 | + GIT_PASS: ${{ secrets.GIT_PASS }} |
| 41 | + GIT_REPO_BASE: ${{ secrets.GIT_REPO_BASE }} |
| 42 | + GIT_HOST: ${{ secrets.GIT_HOST }} |
| 43 | + shell: pwsh |
| 44 | + run: | |
| 45 | + git clone -b main "https://${env:GIT_USER}:${env:GIT_PASS}@${env:GIT_HOST}/${env:GIT_REPO_BASE}/linkandroid-pro.git" code |
| 46 | +
|
| 47 | + - name: Setup Node.js |
| 48 | + uses: actions/setup-node@v4 |
| 49 | + with: |
| 50 | + node-version: 20 |
| 51 | + |
| 52 | + - name: Build Prepare (macOS) |
| 53 | + if: runner.os == 'macOS' |
| 54 | + run: | |
| 55 | + brew install python-setuptools |
| 56 | +
|
| 57 | + - name: Cert Prepare (macOS) |
| 58 | + if: runner.os == 'macOS' |
| 59 | + env: |
| 60 | + MACOS_CERTIFICATE: ${{ secrets.CORP_MACOS_CERTIFICATE }} |
| 61 | + MACOS_CERTIFICATE_PASSWORD: ${{ secrets.CORP_MACOS_CERTIFICATE_PASSWORD }} |
| 62 | + run: | |
| 63 | + echo "find-identity" |
| 64 | + security find-identity -p codesigning |
| 65 | + echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12 |
| 66 | + security create-keychain -p "" build.keychain |
| 67 | + security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign |
| 68 | + security list-keychains -s build.keychain |
| 69 | + security set-keychain-settings -t 3600 -u build.keychain |
| 70 | + security unlock-keychain -p "" build.keychain |
| 71 | + echo "find-identity" |
| 72 | + security find-identity -v -p codesigning build.keychain |
| 73 | + echo "find-identity" |
| 74 | + security find-identity -p codesigning |
| 75 | + echo "set-key-partition-list" |
| 76 | + security set-key-partition-list -S apple-tool:,apple: -s -k "" -l "Mac Developer ID Application: Xi'an Yanyi Information Technology Co., Ltd" -t private build.keychain |
| 77 | + echo "export" |
| 78 | + security export -k build.keychain -t certs -f x509 -p -o certificate.cer |
| 79 | + echo "add-trusted-cert" |
| 80 | + sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain certificate.cer |
| 81 | + echo "find-identity" |
| 82 | + security find-identity -p codesigning |
| 83 | +
|
| 84 | + - name: Install Dependencies |
| 85 | + working-directory: code |
| 86 | + run: npm install |
| 87 | + |
| 88 | + - name: Build Release Files |
| 89 | + working-directory: code |
| 90 | + run: | |
| 91 | + npm run build |
| 92 | + env: |
| 93 | + DEBUG: "electron-notarize:*" |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 96 | + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} |
| 97 | + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} |
| 98 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 99 | + |
| 100 | + - name: Set Build Name ( Linux / macOS ) |
| 101 | + if: runner.os == 'Linux' || runner.os == 'macOS' |
| 102 | + run: | |
| 103 | + DIST_FILE_NAME=${{ runner.os }}-${{ runner.arch }}-v$(date +%Y%m%d_%H%M%S)-${RANDOM} |
| 104 | + echo ::add-mask::$DIST_FILE_NAME |
| 105 | + echo DIST_FILE_NAME=$DIST_FILE_NAME >> $GITHUB_ENV |
| 106 | +
|
| 107 | + - name: Set Build Name ( Windows ) |
| 108 | + if: runner.os == 'Windows' |
| 109 | + shell: pwsh |
| 110 | + run: | |
| 111 | + $randomNumber = Get-Random -Minimum 10000 -Maximum 99999 |
| 112 | + $DIST_FILE_NAME = "Windows-X64-v$(Get-Date -Format 'yyyyMMdd_HHmmss')-$randomNumber" |
| 113 | + Write-Host "::add-mask::$DIST_FILE_NAME" |
| 114 | + echo "DIST_FILE_NAME=$DIST_FILE_NAME" >> $env:GITHUB_ENV |
| 115 | +
|
| 116 | + - name: Rename output files (Linux/macOS) |
| 117 | + if: runner.os == 'Linux' || runner.os == 'macOS' |
| 118 | + run: | |
| 119 | + find code/dist-release/ -type f -name 'LinkAndroidPro-*' -exec bash -c 'f="{}"; mv "$f" "${f/LinkAndroidPro-/LinkAndroid-}"' \; |
| 120 | +
|
| 121 | + - name: Rename output files (Windows) |
| 122 | + if: runner.os == 'Windows' |
| 123 | + shell: pwsh |
| 124 | + run: | |
| 125 | + Get-ChildItem code\dist-release\LinkAndroidPro-* | Rename-Item -NewName { $_.Name -replace 'LinkAndroidPro-','LinkAndroid-' } |
| 126 | +
|
| 127 | + - name: Release Assets |
| 128 | + uses: softprops/action-gh-release@v2 |
| 129 | + with: |
| 130 | + draft: false |
| 131 | + prerelease: false |
| 132 | + fail_on_unmatched_files: false |
| 133 | + files: | |
| 134 | + code/dist-release/*.exe |
| 135 | + code/dist-release/*.dmg |
| 136 | + code/dist-release/*.AppImage |
| 137 | + code/dist-release/*.deb |
| 138 | + env: |
| 139 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
0 commit comments