fix: stop repeated keychain prompts during session (#13) #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*'] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-release: | |
| runs-on: macos-15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Extract version | |
| id: version | |
| run: | | |
| TAG="${GITHUB_REF_NAME}" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "number=${TAG#v}" >> "$GITHUB_OUTPUT" | |
| - name: Build release binary | |
| run: | | |
| cd TokenMeter | |
| swift build -c release | |
| - name: Create app bundle | |
| run: | | |
| APP="TokenMeter.app" | |
| mkdir -p "${APP}/Contents/MacOS" | |
| mkdir -p "${APP}/Contents/Resources" | |
| cp TokenMeter/.build/release/TokenMeter "${APP}/Contents/MacOS/" | |
| # Copy icon if present | |
| if [ -f TokenMeter/TokenMeter/Resources/AppIcon.icns ]; then | |
| cp TokenMeter/TokenMeter/Resources/AppIcon.icns "${APP}/Contents/Resources/" | |
| fi | |
| # Generate Info.plist | |
| VERSION="${{ steps.version.outputs.number }}" | |
| cat > "${APP}/Contents/Info.plist" << PLIST | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>CFBundleExecutable</key> | |
| <string>TokenMeter</string> | |
| <key>CFBundleIdentifier</key> | |
| <string>com.tokenmeter.app</string> | |
| <key>CFBundleName</key> | |
| <string>TokenMeter</string> | |
| <key>CFBundleDisplayName</key> | |
| <string>TokenMeter</string> | |
| <key>CFBundleShortVersionString</key> | |
| <string>${VERSION}</string> | |
| <key>CFBundleVersion</key> | |
| <string>${VERSION}</string> | |
| <key>CFBundlePackageType</key> | |
| <string>APPL</string> | |
| <key>CFBundleIconFile</key> | |
| <string>AppIcon</string> | |
| <key>LSUIElement</key> | |
| <true/> | |
| <key>LSMinimumSystemVersion</key> | |
| <string>14.0</string> | |
| </dict> | |
| </plist> | |
| PLIST | |
| - name: Ad-hoc code sign | |
| run: | | |
| codesign --force --deep --sign - TokenMeter.app | |
| - name: Verify signature | |
| run: | | |
| codesign -dv --verbose=4 TokenMeter.app | |
| - name: Create zip | |
| env: | |
| ZIP_NAME: TokenMeter-${{ steps.version.outputs.tag }}-macos-aarch64.zip | |
| run: | | |
| ditto -c -k --keepParent TokenMeter.app "$ZIP_NAME" | |
| shasum -a 256 "$ZIP_NAME" | awk '{print $1}' > sha256.txt | |
| echo "SHA256: $(cat sha256.txt)" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: TokenMeter-${{ steps.version.outputs.tag }}-macos-aarch64.zip | |
| generate_release_notes: true | |
| - name: Update Homebrew cask | |
| env: | |
| GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.version.outputs.number }}" | |
| SHA256=$(cat sha256.txt) | |
| TAG="${{ steps.version.outputs.tag }}" | |
| CASK_CONTENT=$(cat <<RUBY | |
| cask "tokenmeter" do | |
| version "${VERSION}" | |
| sha256 "${SHA256}" | |
| url "https://github.com/Priyans-hu/tokenmeter/releases/download/${TAG}/TokenMeter-${TAG}-macos-aarch64.zip" | |
| name "TokenMeter" | |
| desc "macOS menu bar app for tracking Claude Code usage, rate limits, and costs" | |
| homepage "https://github.com/Priyans-hu/tokenmeter" | |
| depends_on macos: ">= :sonoma" | |
| app "TokenMeter.app" | |
| postflight do | |
| system_command "/usr/bin/xattr", | |
| args: ["-cr", "#{appdir}/TokenMeter.app"], | |
| sudo: false | |
| end | |
| zap trash: [ | |
| "~/Library/Application Support/com.priyanshugarg.tokenmeter", | |
| ] | |
| end | |
| RUBY | |
| ) | |
| # Get current file SHA from homebrew-tap repo | |
| FILE_SHA=$(gh api repos/Priyans-hu/homebrew-tap/contents/Casks/tokenmeter.rb --jq '.sha') | |
| # Update the cask file | |
| echo "$CASK_CONTENT" | gh api repos/Priyans-hu/homebrew-tap/contents/Casks/tokenmeter.rb \ | |
| -X PUT \ | |
| -f message="Update tokenmeter to ${TAG}" \ | |
| -f content="$(echo "$CASK_CONTENT" | base64)" \ | |
| -f sha="$FILE_SHA" \ | |
| --silent | |
| echo "Homebrew cask updated to ${TAG}" |