fix: avoid Swift release compiler crash #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release macOS | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Semantic version to release, for example 0.1.0" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| name: Build and publish Lithe for macOS | |
| runs-on: macos-14 | |
| steps: | |
| - name: Check out source | |
| uses: actions/checkout@v4 | |
| - name: Set up Swift | |
| # v2 downloads the macOS toolchain package directly. The beta v3 | |
| # Swiftly installer is currently unstable on the macos-14 runner. | |
| uses: swift-actions/setup-swift@v2 | |
| with: | |
| swift-version: "6.2" | |
| - name: Set up Rust targets | |
| run: | | |
| rustup toolchain install stable --profile minimal | |
| rustup default stable | |
| rustup target add aarch64-apple-darwin x86_64-apple-darwin | |
| - name: Resolve release version | |
| id: version | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| MANUAL_VERSION: ${{ inputs.version }} | |
| shell: bash | |
| run: | | |
| if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then | |
| version="$MANUAL_VERSION" | |
| else | |
| version="${GITHUB_REF_NAME#v}" | |
| fi | |
| if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Release version must use the form MAJOR.MINOR.PATCH: $version" | |
| exit 1 | |
| fi | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$version" >> "$GITHUB_OUTPUT" | |
| echo "build_number=$GITHUB_RUN_NUMBER" >> "$GITHUB_OUTPUT" | |
| - name: Build the App bundle | |
| env: | |
| LITHE_VERSION: ${{ steps.version.outputs.version }} | |
| LITHE_BUILD_NUMBER: ${{ steps.version.outputs.build_number }} | |
| run: | | |
| chmod +x scripts/package-app.sh | |
| chmod +x scripts/create-dmg.sh | |
| for architecture in arm64 x86_64; do | |
| LITHE_ARCH="$architecture" ./scripts/package-app.sh | |
| LITHE_ARCH="$architecture" ./scripts/create-dmg.sh | |
| shasum -a 256 \ | |
| "dist/Lithe-${LITHE_VERSION}-${architecture}.dmg" \ | |
| > "dist/Lithe-${LITHE_VERSION}-${architecture}.dmg.sha256" | |
| done | |
| - name: Verify the bundle and disk image | |
| env: | |
| LITHE_VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| for architecture in arm64 x86_64; do | |
| app_path="dist/Lithe-${architecture}.app" | |
| dmg_path="dist/Lithe-${LITHE_VERSION}-${architecture}.dmg" | |
| codesign --verify --deep --strict "$app_path" | |
| /usr/libexec/PlistBuddy \ | |
| -c "Print :CFBundleShortVersionString" \ | |
| "$app_path/Contents/Info.plist" | |
| /usr/libexec/PlistBuddy \ | |
| -c "Print :CFBundleVersion" \ | |
| "$app_path/Contents/Info.plist" | |
| lipo "$app_path/Contents/MacOS/Lithe" -verify_arch "$architecture" | |
| hdiutil imageinfo "$dmg_path" > /dev/null | |
| test -s "$dmg_path" | |
| done | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| RELEASE_TAG: ${{ steps.version.outputs.tag }} | |
| LITHE_VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| notes_file="docs/releases/v${LITHE_VERSION}.md" | |
| release_args=( | |
| "$RELEASE_TAG" | |
| "dist/Lithe-${LITHE_VERSION}-arm64.dmg" | |
| "dist/Lithe-${LITHE_VERSION}-arm64.dmg.sha256" | |
| "dist/Lithe-${LITHE_VERSION}-x86_64.dmg" | |
| "dist/Lithe-${LITHE_VERSION}-x86_64.dmg.sha256" | |
| --repo "$GITHUB_REPOSITORY" | |
| --target "$GITHUB_SHA" | |
| --title "Lithe $RELEASE_TAG" | |
| ) | |
| if [[ -f "$notes_file" ]]; then | |
| release_args+=(--notes-file "$notes_file") | |
| else | |
| release_args+=(--generate-notes) | |
| fi | |
| gh release create "${release_args[@]}" |