refactoring #1
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| env: | |
| DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Select Xcode | |
| run: sudo xcode-select -switch /Applications/Xcode_15.4.app/Contents/Developer | |
| - name: Install dependencies | |
| run: | | |
| brew install swiftlint swiftformat create-dmg | |
| - name: Setup certificates | |
| env: | |
| BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | |
| P12_PASSWORD: ${{ secrets.P12_PASSWORD }} | |
| KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
| run: | | |
| # Create temporary keychain | |
| security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
| security default-keychain -s build.keychain | |
| security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
| # Import certificate | |
| echo $BUILD_CERTIFICATE_BASE64 | base64 --decode > certificate.p12 | |
| security import certificate.p12 -k build.keychain -P "$P12_PASSWORD" -T /usr/bin/codesign | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain | |
| - name: Get version from tag | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Building version: $VERSION" | |
| - name: Lint code | |
| run: make lint | |
| - name: Run tests | |
| run: make test | |
| - name: Build release | |
| run: make release | |
| env: | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| DEVELOPMENT_TEAM: ${{ secrets.DEVELOPMENT_TEAM }} | |
| - name: Notarize DMG | |
| run: make notarize | |
| env: | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
| DEVELOPMENT_TEAM: ${{ secrets.DEVELOPMENT_TEAM }} | |
| - name: Generate checksums | |
| run: | | |
| cd build | |
| shasum -a 256 ModSwitchIME.dmg > ModSwitchIME.dmg.sha256 | |
| cat ModSwitchIME.dmg.sha256 | |
| - name: Generate release notes | |
| id: release_notes | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.VERSION }} | |
| # Generate changelog since last tag | |
| LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -n "$LAST_TAG" ]; then | |
| echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT | |
| echo "## Changes since $LAST_TAG" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"- %s (%h)" $LAST_TAG..HEAD >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "CHANGELOG=Initial release" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: ModSwitchIME v${{ steps.get_version.outputs.VERSION }} | |
| body: | | |
| ## ModSwitchIME v${{ steps.get_version.outputs.VERSION }} | |
| A macOS menu bar helper that switches between English input and native IME by pressing left/right ⌘ keys individually. | |
| ### Installation | |
| 1. Download `ModSwitchIME.dmg` from the assets below | |
| 2. Open the DMG file and drag ModSwitchIME.app to your Applications folder | |
| 3. Launch ModSwitchIME and grant accessibility permissions when prompted | |
| 4. The app will appear in your menu bar | |
| ### Features | |
| - **Left ⌘ key**: Switch to native IME (Japanese, Chinese, Korean, etc.) | |
| - **Right ⌘ key**: Switch to English input | |
| - **Optional idle timeout**: Automatically switch to English after no input | |
| - **Menu bar integration**: Easy access to preferences and controls | |
| - **Launch at login**: Optional automatic startup | |
| ### System Requirements | |
| - macOS 11.0 (Big Sur) or later | |
| - Accessibility permissions (granted during first launch) | |
| ### Changelog | |
| ${{ steps.release_notes.outputs.CHANGELOG }} | |
| ### Verification | |
| SHA256 checksum: See `ModSwitchIME.dmg.sha256` file in assets. | |
| draft: false | |
| prerelease: false | |
| - name: Upload DMG | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./build/ModSwitchIME.dmg | |
| asset_name: ModSwitchIME.dmg | |
| asset_content_type: application/octet-stream | |
| - name: Upload checksum | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./build/ModSwitchIME.dmg.sha256 | |
| asset_name: ModSwitchIME.dmg.sha256 | |
| asset_content_type: text/plain | |
| - name: Cleanup keychain | |
| if: always() | |
| run: | | |
| security delete-keychain build.keychain || true | |
| rm certificate.p12 || true | |
| homebrew: | |
| name: Update Homebrew Cask | |
| runs-on: macos-latest | |
| needs: release | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version and download URL | |
| id: get_info | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}/ModSwitchIME.dmg" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "DOWNLOAD_URL=$DOWNLOAD_URL" >> $GITHUB_OUTPUT | |
| - name: Download and get SHA256 | |
| run: | | |
| curl -L "${{ steps.get_info.outputs.DOWNLOAD_URL }}" -o ModSwitchIME.dmg | |
| SHA256=$(shasum -a 256 ModSwitchIME.dmg | cut -d' ' -f1) | |
| echo "SHA256=$SHA256" >> $GITHUB_ENV | |
| - name: Create Homebrew Cask PR | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} | |
| push-to-fork: ${{ github.repository_owner }}/homebrew-cask | |
| branch: update-modswitchime-${{ steps.get_info.outputs.VERSION }} | |
| title: 'ModSwitchIME: update to ${{ steps.get_info.outputs.VERSION }}' | |
| body: | | |
| Update ModSwitchIME to version ${{ steps.get_info.outputs.VERSION }} | |
| - Version: ${{ steps.get_info.outputs.VERSION }} | |
| - Download URL: ${{ steps.get_info.outputs.DOWNLOAD_URL }} | |
| - SHA256: ${{ env.SHA256 }} | |
| Generated automatically by GitHub Actions. | |
| commit-message: 'ModSwitchIME: update to ${{ steps.get_info.outputs.VERSION }}' |