|
| 1 | +name: Release macOS Preview |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # GitHub Actions schedules are approximate and may be delayed by queueing. |
| 6 | + - cron: "17 3 * * *" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + source_branch: |
| 10 | + description: "Preview branch to build" |
| 11 | + required: true |
| 12 | + default: "preview/0.3.0" |
| 13 | + type: string |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: release-preview-macos |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +env: |
| 23 | + PREVIEW_BRANCH: preview/0.3.0 |
| 24 | + PREVIEW_VERSION: 0.3.0 |
| 25 | + PREVIEW_TAG: preview-0.3.0 |
| 26 | + |
| 27 | +jobs: |
| 28 | + build: |
| 29 | + name: Build ${{ matrix.architecture }} preview |
| 30 | + if: github.actor == github.repository_owner || github.event_name == 'schedule' |
| 31 | + runs-on: macos-14 |
| 32 | + timeout-minutes: 30 |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + architecture: |
| 37 | + - arm64 |
| 38 | + - x86_64 |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Check out preview source |
| 42 | + uses: actions/checkout@v7 |
| 43 | + with: |
| 44 | + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.source_branch || env.PREVIEW_BRANCH }} |
| 45 | + |
| 46 | + - name: Record source revision |
| 47 | + id: source |
| 48 | + shell: bash |
| 49 | + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 50 | + |
| 51 | + - name: Set up Swift |
| 52 | + uses: swift-actions/setup-swift@v2 |
| 53 | + with: |
| 54 | + swift-version: "6.2" |
| 55 | + |
| 56 | + - name: Set up Rust target |
| 57 | + uses: dtolnay/rust-toolchain@stable |
| 58 | + with: |
| 59 | + targets: ${{ matrix.architecture == 'arm64' && 'aarch64-apple-darwin' || 'x86_64-apple-darwin' }} |
| 60 | + |
| 61 | + - name: Restore SwiftPM dependencies |
| 62 | + uses: actions/cache@v6 |
| 63 | + with: |
| 64 | + path: | |
| 65 | + .build/checkouts |
| 66 | + .build/repositories |
| 67 | + ~/.cache/org.swift.swiftpm |
| 68 | + key: swiftpm-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }} |
| 69 | + |
| 70 | + - name: Restore Cargo dependencies |
| 71 | + uses: actions/cache@v6 |
| 72 | + with: |
| 73 | + path: | |
| 74 | + ~/.cargo/git |
| 75 | + ~/.cargo/registry |
| 76 | + key: cargo-dependencies-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }} |
| 77 | + |
| 78 | + - name: Build and package the preview app |
| 79 | + env: |
| 80 | + LITHE_ARCH: ${{ matrix.architecture }} |
| 81 | + LITHE_VERSION: ${{ env.PREVIEW_VERSION }} |
| 82 | + LITHE_BUILD_NUMBER: ${{ github.run_number }} |
| 83 | + run: | |
| 84 | + ./scripts/package-app.sh |
| 85 | + ./scripts/create-dmg.sh |
| 86 | + dmg_name="Lithe-${LITHE_VERSION}-${LITHE_ARCH}.dmg" |
| 87 | + (cd dist && shasum -a 256 "$dmg_name" > "$dmg_name.sha256") |
| 88 | +
|
| 89 | + - name: Verify the preview bundle and disk image |
| 90 | + env: |
| 91 | + LITHE_ARCH: ${{ matrix.architecture }} |
| 92 | + LITHE_VERSION: ${{ env.PREVIEW_VERSION }} |
| 93 | + run: | |
| 94 | + app_path="dist/Lithe-${LITHE_ARCH}.app" |
| 95 | + dmg_path="dist/Lithe-${LITHE_VERSION}-${LITHE_ARCH}.dmg" |
| 96 | + codesign --verify --deep --strict "$app_path" |
| 97 | + /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$app_path/Contents/Info.plist" |
| 98 | + /usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$app_path/Contents/Info.plist" |
| 99 | + lipo "$app_path/Contents/MacOS/Lithe" -verify_arch "$LITHE_ARCH" |
| 100 | + hdiutil imageinfo "$dmg_path" > /dev/null |
| 101 | + test -s "$dmg_path" |
| 102 | + (cd dist && shasum -a 256 -c "Lithe-${LITHE_VERSION}-${LITHE_ARCH}.dmg.sha256") |
| 103 | +
|
| 104 | + - name: Upload preview artifacts |
| 105 | + uses: actions/upload-artifact@v7 |
| 106 | + with: |
| 107 | + name: macos-preview-${{ matrix.architecture }} |
| 108 | + path: | |
| 109 | + dist/Lithe-${{ env.PREVIEW_VERSION }}-${{ matrix.architecture }}.dmg |
| 110 | + dist/Lithe-${{ env.PREVIEW_VERSION }}-${{ matrix.architecture }}.dmg.sha256 |
| 111 | + if-no-files-found: error |
| 112 | + retention-days: 14 |
| 113 | + |
| 114 | + publish: |
| 115 | + name: Publish rolling macOS preview |
| 116 | + needs: build |
| 117 | + runs-on: ubuntu-latest |
| 118 | + permissions: |
| 119 | + contents: write |
| 120 | + |
| 121 | + steps: |
| 122 | + - name: Check out preview source |
| 123 | + uses: actions/checkout@v7 |
| 124 | + with: |
| 125 | + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.source_branch || env.PREVIEW_BRANCH }} |
| 126 | + |
| 127 | + - name: Record source revision |
| 128 | + id: source |
| 129 | + shell: bash |
| 130 | + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 131 | + |
| 132 | + - name: Download preview artifacts |
| 133 | + uses: actions/download-artifact@v8 |
| 134 | + with: |
| 135 | + pattern: macos-preview-* |
| 136 | + path: dist |
| 137 | + merge-multiple: true |
| 138 | + |
| 139 | + - name: Verify downloaded preview artifacts |
| 140 | + env: |
| 141 | + LITHE_VERSION: ${{ env.PREVIEW_VERSION }} |
| 142 | + shell: bash |
| 143 | + run: | |
| 144 | + for architecture in arm64 x86_64; do |
| 145 | + (cd dist && shasum -a 256 -c "Lithe-${LITHE_VERSION}-${architecture}.dmg.sha256") |
| 146 | + done |
| 147 | +
|
| 148 | + - name: Create or update rolling preview Release |
| 149 | + env: |
| 150 | + GH_TOKEN: ${{ github.token }} |
| 151 | + RELEASE_TAG: ${{ env.PREVIEW_TAG }} |
| 152 | + LITHE_VERSION: ${{ env.PREVIEW_VERSION }} |
| 153 | + SOURCE_SHA: ${{ steps.source.outputs.sha }} |
| 154 | + shell: bash |
| 155 | + run: | |
| 156 | + if ! gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then |
| 157 | + gh release create "$RELEASE_TAG" \ |
| 158 | + --repo "$GITHUB_REPOSITORY" \ |
| 159 | + --target "$SOURCE_SHA" \ |
| 160 | + --title "Lithe ${LITHE_VERSION} Preview" \ |
| 161 | + --notes "Rolling Preview build from ${SOURCE_SHA}. This release is replaced by the next scheduled build." \ |
| 162 | + --prerelease |
| 163 | + else |
| 164 | + gh release edit "$RELEASE_TAG" \ |
| 165 | + --repo "$GITHUB_REPOSITORY" \ |
| 166 | + --target "$SOURCE_SHA" \ |
| 167 | + --title "Lithe ${LITHE_VERSION} Preview" \ |
| 168 | + --notes "Rolling Preview build from ${SOURCE_SHA}. This release is replaced by the next scheduled build." \ |
| 169 | + --prerelease |
| 170 | + fi |
| 171 | +
|
| 172 | + gh release upload "$RELEASE_TAG" \ |
| 173 | + "dist/Lithe-${LITHE_VERSION}-arm64.dmg" \ |
| 174 | + "dist/Lithe-${LITHE_VERSION}-arm64.dmg.sha256" \ |
| 175 | + "dist/Lithe-${LITHE_VERSION}-x86_64.dmg" \ |
| 176 | + "dist/Lithe-${LITHE_VERSION}-x86_64.dmg.sha256" \ |
| 177 | + --repo "$GITHUB_REPOSITORY" \ |
| 178 | + --clobber |
0 commit comments