Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Security vulnerability
url: https://github.com/tyldra-org/chargectl/security/advisories/new
url: https://github.com/tyldra/chargectl/security/advisories/new
about: Report vulnerabilities privately. Never open a public issue.
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ concurrency:
jobs:
merge:
name: merge
if: github.repository == 'tyldra-org/chargectl'
if: github.repository == 'tyldra/chargectl'
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# publish only once both passed: the GitHub release with the zip, its
# checksum and the Homebrew cask
# homebrew opens a pull request with the new cask in
# tyldra-org/homebrew-tools, which merges itself once the tap's
# tyldra/homebrew-tools, which merges itself once the tap's
# CI passes
# A failed homebrew job can be rerun on its own; the release stays published.
#
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
with:
client-id: ${{ vars.TAP_APP_CLIENT_ID }}
private-key: ${{ secrets.TAP_APP_PRIVATE_KEY }}
owner: tyldra-org
owner: tyldra
repositories: homebrew-tools
# Only what opening and auto-merging the pull request needs, not every
# permission of the app's installation.
Expand All @@ -201,7 +201,7 @@ jobs:

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: tyldra-org/homebrew-tools
repository: tyldra/homebrew-tools
token: ${{ steps.token.outputs.token }}
path: tap
# The git push below uses these credentials; nothing in this job uploads the folder.
Expand Down
1 change: 1 addition & 0 deletions App/AppModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ final class AppModel {
let files = FileManager.default
if files.isExecutableFile(atPath: brew.path),
files.fileExists(atPath: "\(prefix)/Caskroom/chargectl")
|| files.fileExists(atPath: "\(prefix)/Library/Taps/tyldra/homebrew-tools")
|| files.fileExists(atPath: "\(prefix)/Library/Taps/tyldra-org/homebrew-tools")
{
return brew
Expand Down
244 changes: 126 additions & 118 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide explains how to propose a change and what makes it easy to accept.

- Read the [Code of Conduct](CODE_OF_CONDUCT.md). It applies everywhere the
project operates.
- Search [existing issues](https://github.com/tyldra-org/chargectl/issues) first.
- Search [existing issues](https://github.com/tyldra/chargectl/issues) first.
- Every pull request starts from an issue. Find one or open one; for anything
larger than a small fix, agree on the approach there before writing code.
- Report security problems privately through [SECURITY.md](SECURITY.md), never
Expand All @@ -20,7 +20,7 @@ You need an Apple silicon Mac on macOS 27, Xcode 27 and XcodeGen.

```sh
brew install xcodegen
git clone https://github.com/tyldra-org/chargectl.git
git clone https://github.com/tyldra/chargectl.git
cd chargectl
./scripts/check.sh
```
Expand Down Expand Up @@ -212,7 +212,7 @@ matches `project.yml`, runs the tests, and builds and attests
`Chargectl-<version>.zip`, while the cask check runs on another runner. Once
both are done, it publishes the release with notes from the changelog, and
opens a pull request that updates the cask in
[tyldra-org/homebrew-tools](https://github.com/tyldra-org/homebrew-tools).
[tyldra/homebrew-tools](https://github.com/tyldra/homebrew-tools).
Running the workflow by hand from the Actions tab is a dry run: the same checks
and signed build, with nothing published. `./scripts/package.sh` builds the same
zip locally.
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</p>

<p align="center">
<a href="https://github.com/tyldra-org/chargectl/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/tyldra-org/chargectl/actions/workflows/ci.yml/badge.svg?branch=main"></a>
<a href="https://github.com/tyldra-org/chargectl/releases/latest"><img alt="Latest release" src="https://img.shields.io/github/v/release/tyldra-org/chargectl"></a>
<a href="https://github.com/tyldra/chargectl/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/tyldra/chargectl/actions/workflows/ci.yml/badge.svg?branch=main"></a>
<a href="https://github.com/tyldra/chargectl/releases/latest"><img alt="Latest release" src="https://img.shields.io/github/v/release/tyldra/chargectl"></a>
<a href="LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-blue.svg"></a>
<img alt="macOS 27" src="https://img.shields.io/badge/macOS-27-black.svg?logo=apple">
<img alt="Apple silicon" src="https://img.shields.io/badge/Apple%20silicon-arm64-black.svg">
Expand Down Expand Up @@ -53,11 +53,11 @@ working while the app is closed.
| macOS | 27 or later |

```sh
brew install --cask tyldra-org/tools/chargectl
brew install --cask tyldra/tools/chargectl
```

You can also download `Chargectl-<version>.zip` from
[Releases](https://github.com/tyldra-org/chargectl/releases/latest), or
[Releases](https://github.com/tyldra/chargectl/releases/latest), or
[build it from source](#build-from-source).

Then open **Chargectl** from Applications. A short welcome walks you through:
Expand Down Expand Up @@ -298,18 +298,18 @@ macOS charge limit, then removes everything Chargectl added. Details are under
### Homebrew

```sh
brew install --cask tyldra-org/tools/chargectl # install
brew update && brew upgrade --cask tyldra-org/tools/chargectl # update
brew uninstall --zap --cask tyldra-org/tools/chargectl # remove everything
brew install --cask tyldra/tools/chargectl # install
brew update && brew upgrade --cask tyldra/tools/chargectl # update
brew uninstall --zap --cask tyldra/tools/chargectl # remove everything
```

Chargectl updates itself, so `brew upgrade` without a name skips it. Use the
full name `tyldra-org/tools/chargectl`: Homebrew only loads casks from
other taps when you name them, or after `brew trust tyldra-org/tools`.
full name `tyldra/tools/chargectl`: Homebrew only loads casks from
other taps when you name them, or after `brew trust tyldra/tools`.

### Download

Each [release](https://github.com/tyldra-org/chargectl/releases) has
Each [release](https://github.com/tyldra/chargectl/releases) has
`Chargectl-<version>.zip`, its SHA-256 checksum and a build provenance
attestation. Unzip it and move Chargectl to Applications. Releases are not
notarized, so macOS blocks the first launch of a downloaded copy: open it once,
Expand All @@ -318,7 +318,7 @@ download:

```sh
shasum -a 256 -c Chargectl-<version>.zip.sha256
gh attestation verify Chargectl-<version>.zip --repo tyldra-org/chargectl
gh attestation verify Chargectl-<version>.zip --repo tyldra/chargectl
```

### Build from source
Expand All @@ -327,7 +327,7 @@ Needs Xcode 27 and [XcodeGen](https://github.com/yonaskolb/XcodeGen)
(`brew install xcodegen`).

```sh
git clone https://github.com/tyldra-org/chargectl.git
git clone https://github.com/tyldra/chargectl.git
cd chargectl
./scripts/install.sh # build and install the app
./scripts/install.sh --logs # same, then follow the helper's log
Expand All @@ -349,7 +349,7 @@ limit, and removes:
- the Login Items entries, preferences, caches and saved state;
- Chargectl's tile in the Dock, pinned or under recent apps;
- Homebrew's record of the cask, its cached download, and the
`tyldra-org/tools` tap when nothing else from it is installed.
`tyldra/tools` tap when nothing else from it is installed.

If the helper is not running, it asks for your password and does the same as an
administrator.
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Do not report security vulnerabilities through public issues, discussions or
pull requests.

Report privately through
[GitHub private vulnerability reporting](https://github.com/tyldra-org/chargectl/security/advisories/new).
[GitHub private vulnerability reporting](https://github.com/tyldra/chargectl/security/advisories/new).
If you cannot use GitHub, email yogeshprasad098@gmail.com.

Include as much of the following as you can:
Expand Down
20 changes: 13 additions & 7 deletions Shared/UninstallCleanup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
nonisolated enum UninstallCleanup {
static let bundleIdentifier = "com.tyldra.chargectl"
static let widgetsIdentifier = "com.tyldra.chargectl.widgets"
static let tap = "tyldra-org/tools"
static let tap = "tyldra/tools"
/// The tap's name before the organization was renamed. Installs from then keep it.
static let oldTap = "tyldra-org/tools"
/// The widget extension's process, which WidgetKit keeps running between timeline updates.
static let widgetsProcess = "ChargectlWidgets"

Expand Down Expand Up @@ -82,15 +84,19 @@ nonisolated enum UninstallCleanup {
/bin/rm -f "$plist"
"""

/// Removes Homebrew's record of the cask, its cached downloads, and the tap when nothing else
/// from it is installed. `$1` is brew. `--force` succeeds although the app is already
/// deleted; everything the cask's zap lists is already removed by then.
/// Removes Homebrew's record of the cask, its cached downloads, and the tap, under its current
/// or old name, when nothing else from it is installed. `$1` is brew. `--force` succeeds
/// although the app is already deleted; everything the cask's zap lists is already removed by
/// then.
static let homebrew = """
if [ -n "$1" ]; then
export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_ENV_HINTS=1
"$1" uninstall --cask --force \(tap)/chargectl
"$1" cleanup --prune=all \(tap)/chargectl
"$1" list --full-name 2>/dev/null | /usr/bin/grep -q '^\(tap)/' || "$1" untap \(tap)
"$1" uninstall --cask --force chargectl
"$1" cleanup --prune=all chargectl
for tap in \(tap) \(oldTap); do
"$1" tap | /usr/bin/grep -qx "$tap" || continue
"$1" list --full-name 2>/dev/null | /usr/bin/grep -q "^$tap/" || "$1" untap "$tap"
done
fi
"""

Expand Down
2 changes: 1 addition & 1 deletion Shared/Update/AppRelease.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nonisolated struct AppRelease: Equatable, Sendable {
/// Chargectl-<version>.zip.sha256
var checksum: URL

static let feed = URL(string: "https://api.github.com/repos/tyldra-org/chargectl/releases/latest")!
static let feed = URL(string: "https://api.github.com/repos/tyldra/chargectl/releases/latest")!

/// nil for a draft or prerelease, a tag that is not vMAJOR.MINOR.PATCH, or a release without
/// its zip and checksum.
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppReleaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Testing
{
let names = assets ?? ["Chargectl-0.2.0.zip", "Chargectl-0.2.0.zip.sha256", "chargectl.rb"]
let list = names.map {
#"{"name":"\#($0)","browser_download_url":"https://github.com/tyldra-org/chargectl/releases/download/\#(tag)/\#($0)"}"#
#"{"name":"\#($0)","browser_download_url":"https://github.com/tyldra/chargectl/releases/download/\#(tag)/\#($0)"}"#
}
return Data(
#"{"tag_name":"\#(tag)","draft":\#(draft),"prerelease":\#(prerelease),"assets":[\#(list.joined(separator: ","))]}"#
Expand Down
11 changes: 11 additions & 0 deletions Tests/UninstallCleanupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ import Testing
#expect(script.contains("$(section \(section))"))
}
}

/// Homebrew cleanup covers the tap under its current name and the one from before the
/// organization was renamed, and scripts/uninstall.sh fills in both.
@Test func homebrewCleanupCoversBothTapNames() throws {
let script = try String(
contentsOf: Self.root.appendingPathComponent("scripts/uninstall.sh"), encoding: .utf8)
#expect(UninstallCleanup.homebrew.contains(UninstallCleanup.tap))
#expect(UninstallCleanup.homebrew.contains(UninstallCleanup.oldTap))
#expect(script.contains(#"s|\\(tap)|\#(UninstallCleanup.tap)|g"#))
#expect(script.contains(#"s|\\(oldTap)|\#(UninstallCleanup.oldTap)|g"#))
}
}
10 changes: 5 additions & 5 deletions scripts/cask.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Prints the Homebrew cask for a Chargectl release. The release workflow writes it to
# Casks/chargectl.rb in tyldra-org/homebrew-tools.
# Casks/chargectl.rb in tyldra/homebrew-tools.
#
# ./scripts/cask.sh <version> <sha256 of Chargectl-<version>.zip>
#
Expand All @@ -17,16 +17,16 @@ sha256=$2
[[ "$sha256" =~ ^[0-9a-f]{64}$ ]] || { echo "cask.sh: bad SHA-256: $sha256" >&2; exit 2; }

cat <<CASK
# Generated by scripts/cask.sh in tyldra-org/chargectl; the release workflow
# Generated by scripts/cask.sh in tyldra/chargectl; the release workflow
# updates it. Edit the script there, not this file.
cask "chargectl" do
version "$version"
sha256 "$sha256"

url "https://github.com/tyldra-org/chargectl/releases/download/v#{version}/Chargectl-#{version}.zip"
url "https://github.com/tyldra/chargectl/releases/download/v#{version}/Chargectl-#{version}.zip"
name "Chargectl"
desc "Battery charge limiter for Apple silicon MacBooks"
homepage "https://github.com/tyldra-org/chargectl"
homepage "https://github.com/tyldra/chargectl"

livecheck do
url :url
Expand Down Expand Up @@ -77,7 +77,7 @@ cask "chargectl" do
Open Chargectl from Applications to install its helper and choose a limit.
To hand charging back to macOS before removing it, use
Settings > Uninstall Chargectl, or run:
brew uninstall --zap --cask tyldra-org/tools/chargectl
brew uninstall --zap --cask tyldra/tools/chargectl
EOS
end
CASK
2 changes: 1 addition & 1 deletion scripts/import-release-certificate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -euo pipefail
# SHA-1 of the certificate made with scripts/make-release-certificate.sh. Public; the private
# key exists only in the secrets and the maintainer's backup.
expected=653E52E5F86FE7D3F69BCAC212ABEFFC4DBCF82B
upstream=tyldra-org/chargectl
upstream=tyldra/chargectl
if [[ -z "${CERTIFICATE:-}" ]]; then
if [[ "${GITHUB_REPOSITORY:-}" == "$upstream" ]]; then
echo "::error::The release certificate secrets are missing. A release signed ad hoc would make every user install the helper again."
Expand Down
8 changes: 4 additions & 4 deletions scripts/release-notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
changelog="$root/CHANGELOG.md"
repo=https://github.com/tyldra-org/chargectl
repo=https://github.com/tyldra/chargectl
if [[ $# -ne 1 ]]; then
echo 'Usage: release-notes.sh <version>' >&2
exit 2
Expand Down Expand Up @@ -61,10 +61,10 @@ cat <<NOTES
## Install or update

\`\`\`sh
brew install --cask tyldra-org/tools/chargectl
brew install --cask tyldra/tools/chargectl
\`\`\`

Already installed with Homebrew? Run \`brew update && brew upgrade --cask tyldra-org/tools/chargectl\`. To install by hand,
Already installed with Homebrew? Run \`brew update && brew upgrade --cask tyldra/tools/chargectl\`. To install by hand,
download [\`$zip\`]($repo/releases/download/v$version/$zip), unzip it and move Chargectl to
Applications.

Expand All @@ -91,7 +91,7 @@ Actions:

\`\`\`sh
shasum -a 256 -c $zip.sha256
gh attestation verify $zip --repo tyldra-org/chargectl
gh attestation verify $zip --repo tyldra/chargectl
\`\`\`

</details>
Expand Down
4 changes: 2 additions & 2 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rm -rf "$app"
# What Homebrew keeps of the cask, when it installed Chargectl.
brew=
for prefix in /opt/homebrew /usr/local; do
if [[ -x "$prefix/bin/brew" && ( -d "$prefix/Caskroom/chargectl" || -d "$prefix/Library/Taps/tyldra-org/homebrew-tools" ) ]]; then
if [[ -x "$prefix/bin/brew" && ( -d "$prefix/Caskroom/chargectl" || -d "$prefix/Library/Taps/tyldra/homebrew-tools" || -d "$prefix/Library/Taps/tyldra-org/homebrew-tools" ) ]]; then
brew="$prefix/bin/brew"
fi
done
Expand All @@ -45,7 +45,7 @@ section() {
awk -v name="$1" '$0 ~ "static let " name " = \"\"\"" { take = 1; next } take && /^ """/ { exit } take { sub(/^ /, ""); print }' \
"$(dirname "$0")/../Shared/UninstallCleanup.swift" |
sed -e 's/\\(bundleIdentifier)/com.tyldra.chargectl/g' -e 's/\\(widgetsIdentifier)/com.tyldra.chargectl.widgets/g' \
-e 's/\\(widgetsProcess)/ChargectlWidgets/g' -e 's|\\(tap)|tyldra-org/tools|g'
-e 's/\\(widgetsProcess)/ChargectlWidgets/g' -e 's|\\(tap)|tyldra/tools|g' -e 's|\\(oldTap)|tyldra-org/tools|g'
}
cleanup="$(section files)
$(section trash)
Expand Down