|
| 1 | +--- |
| 2 | +# Requires _prepare.yml re-usable workflow to have run. |
| 3 | +name: _build |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + artifact_prefix: |
| 8 | + description: Artifact prefix |
| 9 | + type: string |
| 10 | + required: false |
| 11 | + os: |
| 12 | + description: GitHub Actions runner OS |
| 13 | + type: string |
| 14 | + required: true |
| 15 | + git_ref: |
| 16 | + description: Git ref to build |
| 17 | + type: string |
| 18 | + required: true |
| 19 | + git_sha: |
| 20 | + description: Override git SHA to build |
| 21 | + type: string |
| 22 | + required: false |
| 23 | + build_args: |
| 24 | + description: Custom arguments passed to build script |
| 25 | + type: string |
| 26 | + required: false |
| 27 | + test_build_name: |
| 28 | + description: "Test build name" |
| 29 | + type: string |
| 30 | + required: false |
| 31 | + test_release_type: |
| 32 | + description: "prerelease or draft" |
| 33 | + type: string |
| 34 | + required: false |
| 35 | + default: "prerelease" |
| 36 | + secrets: |
| 37 | + APPLE_DEVELOPER_CERTIFICATE_P12_BASE64: |
| 38 | + description: Base64 encoded Apple Developer Certificate |
| 39 | + required: true |
| 40 | + APPLE_DEVELOPER_CERTIFICATE_PASSWORD: |
| 41 | + description: Password for Apple Developer Certificate |
| 42 | + required: true |
| 43 | + KEYCHAIN_PASSWORD: |
| 44 | + description: Password to use for temporary local keychain on runner |
| 45 | + required: true |
| 46 | + AC_USERNAME: |
| 47 | + description: Apple Connect Username |
| 48 | + required: true |
| 49 | + AC_PASSWORD: |
| 50 | + description: Apple Connect Password |
| 51 | + required: true |
| 52 | + AC_PROVIDER: |
| 53 | + description: Apple Connect Provider |
| 54 | + required: true |
| 55 | + AC_SIGN_IDENTITY: |
| 56 | + description: Apple Connect Signing Identify |
| 57 | + required: true |
| 58 | + TAP_REPO_TOKEN: |
| 59 | + description: Homebrew Tap Token |
| 60 | + required: true |
| 61 | + |
| 62 | +jobs: |
| 63 | + prepare: |
| 64 | + runs-on: ${{ inputs.os }} |
| 65 | + outputs: |
| 66 | + builder_sha: ${{ steps.builder_sha.outputs.sha }} |
| 67 | + emacs_sha_override: ${{ steps.emacs_sha.outputs.sha }} |
| 68 | + test_plan_args: ${{ steps.test_plan_args.outputs.args }} |
| 69 | + steps: |
| 70 | + - name: Download emacs-builder git SHA artifact |
| 71 | + uses: actions/download-artifact@v3 |
| 72 | + with: |
| 73 | + name: emacs-builder-git-sha |
| 74 | + path: ./ |
| 75 | + - name: Store builder Git SHA |
| 76 | + id: builder_sha |
| 77 | + run: >- |
| 78 | + echo "sha=$(cat emacs-builder-git-sha.txt)" >> $GITHUB_OUTPUT |
| 79 | + - name: Prepare plan test args |
| 80 | + id: test_plan_args |
| 81 | + if: ${{ inputs.test_build_name != '' }} |
| 82 | + run: >- |
| 83 | + echo "args=--test-build '${{ inputs.test_build_name }}' --test-release-type '${{ inputs.test_release_type }}'" >> $GITHUB_OUTPUT |
| 84 | + - name: Set git SHA override |
| 85 | + id: emacs_sha |
| 86 | + if: ${{ inputs.git_sha != '' }} |
| 87 | + run: >- |
| 88 | + echo "sha=--sha '${{ inputs.git_sha }}'" >> $GITHUB_OUTPUT |
| 89 | + plan: |
| 90 | + needs: [prepare] |
| 91 | + runs-on: ${{ inputs.os }} |
| 92 | + outputs: |
| 93 | + check: ${{ steps.check.outputs.result }} |
| 94 | + steps: |
| 95 | + - name: Download pre-built emacs-builder artifact |
| 96 | + uses: actions/download-artifact@v3 |
| 97 | + with: |
| 98 | + name: emacs-builder |
| 99 | + path: bin |
| 100 | + - name: Ensure emacs-builder is executable |
| 101 | + run: chmod +x bin/emacs-builder |
| 102 | + - name: Plan build |
| 103 | + run: >- |
| 104 | + bin/emacs-builder -l debug plan --output build-plan.yml |
| 105 | + --output-dir '${{ github.workspace }}/builds' |
| 106 | + ${{ needs.prepare.outputs.test_plan_args }} |
| 107 | + ${{ needs.prepare.outputs.emacs_sha_override }} |
| 108 | + '${{ inputs.git_ref }}' |
| 109 | + env: |
| 110 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 111 | + - name: Show plan |
| 112 | + run: cat build-plan.yml |
| 113 | + - name: Upload build-plan artifact |
| 114 | + uses: actions/upload-artifact@v3 |
| 115 | + with: |
| 116 | + name: ${{ inputs.artifact_prefix }}build-plan |
| 117 | + path: build-plan.yml |
| 118 | + if-no-files-found: error |
| 119 | + - name: Check if planned release and asset already exist |
| 120 | + id: check |
| 121 | + continue-on-error: true |
| 122 | + run: | |
| 123 | + echo "result=$((bin/emacs-builder -l debug release --plan build-plan.yml check && echo 'ok') || echo 'fail')" >> $GITHUB_OUTPUT |
| 124 | + env: |
| 125 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + - run: echo 'Planned release already seems to exist.' |
| 127 | + if: ${{ steps.check.outputs.result == 'fail' }} |
| 128 | + |
| 129 | + build: |
| 130 | + runs-on: ${{ inputs.os }} |
| 131 | + needs: [prepare, plan] |
| 132 | + # Only run if check for existing release and asset failed. |
| 133 | + if: ${{ needs.plan.outputs.check == 'fail' }} |
| 134 | + steps: |
| 135 | + - name: Checkout build-emacs-wr-for-macos repo |
| 136 | + uses: actions/checkout@v2 |
| 137 | + with: |
| 138 | + repository: declantsien/build-emacs-wr-for-macos |
| 139 | + ref: ${{ needs.prepare.outputs.builder_sha }} |
| 140 | + path: builder |
| 141 | + - uses: ruby/setup-ruby@v1 |
| 142 | + with: |
| 143 | + ruby-version: 2.7 |
| 144 | + - name: Update homebrew |
| 145 | + run: brew update |
| 146 | + - name: Install dependencies |
| 147 | + run: make bootstrap-ci |
| 148 | + working-directory: builder |
| 149 | + - name: Download build-plan artifact |
| 150 | + uses: actions/download-artifact@v3 |
| 151 | + with: |
| 152 | + name: ${{ inputs.artifact_prefix }}build-plan |
| 153 | + path: ./ |
| 154 | + - name: Build Emacs |
| 155 | + run: >- |
| 156 | + ./builder/build-emacs-for-macos --plan build-plan.yml |
| 157 | + --native-full-aot |
| 158 | + ${{ inputs.build_args }} |
| 159 | + env: |
| 160 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + - name: Upload unsigned app artifact |
| 162 | + uses: actions/upload-artifact@v3 |
| 163 | + with: |
| 164 | + name: ${{ inputs.artifact_prefix }}unsigned-app |
| 165 | + path: builds/*.tbz |
| 166 | + if-no-files-found: error |
| 167 | + - name: Upload Emacs source artifact |
| 168 | + uses: actions/upload-artifact@v3 |
| 169 | + with: |
| 170 | + name: ${{ inputs.artifact_prefix }}emacs-source |
| 171 | + path: builder/tarballs/*.tgz |
| 172 | + |
| 173 | + package: |
| 174 | + runs-on: ${{ inputs.os }} |
| 175 | + needs: [prepare, plan, build] |
| 176 | + # Only run if check for existing release and asset failed. |
| 177 | + steps: |
| 178 | + - uses: actions/setup-python@v4 |
| 179 | + with: |
| 180 | + python-version: "3.11" |
| 181 | + - name: Install dmgbuild |
| 182 | + run: | |
| 183 | + $(command -v pip3 || command -v pip) install --upgrade dmgbuild |
| 184 | + - name: Download pre-built emacs-builder artifact |
| 185 | + uses: actions/download-artifact@v3 |
| 186 | + with: |
| 187 | + name: emacs-builder |
| 188 | + path: bin |
| 189 | + - name: Ensure emacs-builder is executable |
| 190 | + run: chmod +x bin/emacs-builder |
| 191 | + - name: Download build-plan artifact |
| 192 | + uses: actions/download-artifact@v3 |
| 193 | + with: |
| 194 | + name: ${{ inputs.artifact_prefix }}build-plan |
| 195 | + path: ./ |
| 196 | + - name: Download unsigned app artifact |
| 197 | + uses: actions/download-artifact@v3 |
| 198 | + with: |
| 199 | + name: ${{ inputs.artifact_prefix }}unsigned-app |
| 200 | + path: builds |
| 201 | + - name: Extract unsigned app archive |
| 202 | + run: | |
| 203 | + find * -name '*.tbz' -exec tar xvjf "{}" \; |
| 204 | + working-directory: builds |
| 205 | + - name: Upload disk image artifacts |
| 206 | + uses: actions/upload-artifact@v3 |
| 207 | + with: |
| 208 | + name: tbz |
| 209 | + path: | |
| 210 | + builds/*.tbz |
| 211 | + if-no-files-found: error |
0 commit comments