Files
simslim-mirror/.github/workflows/release.yml
Interlap ffd3a13d34 refactor: split into an importable library and a cmd/simslim CLI (#14)
The repo root becomes `package simslim`, an importable library holding every
piece of slimming logic; the CLI moves to `cmd/simslim`. Previously everything
was `package main`, so nothing here could be imported at all.

The library carries no external dependencies — urfave/cli stays on the CLI side,
along with all terminal-facing code: the interactive profile wizard, writeJSON,
truncate/humanBytes, fatal and usage. The library never writes to stdout; it
returns values and reports progress through the Reporter callback.

Renames forced by collisions with existing types: status() -> ReadStatus,
statusForDevice() -> ReadStatusForDevice, diskCleanupPlan() -> PlanDiskCleanup.
The shutdown/boot timeouts move to simctl.go as ShutdownTimeout/BootTimeout.

`go install` gains a path element: github.com/mobai-app/simslim/cmd/simslim.
The installed binary is still named simslim, and -X main.version still applies.
packaging/homebrew/simslim.rb.in is updated to match, since std_go_args passes
no package path.

Verified live against a real simulator: list, profiles, status, doctor, size,
disk-plan, measure, boot, shutdown, on, off, on --except, on --profile, clone,
rename, delete and the interactive wizard all behave identically to the previous
build. JSON output, human output, help text and exit codes are unchanged.
2026-07-23 12:39:20 +02:00

72 lines
2.5 KiB
YAML

name: release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: Existing release tag to add a Homebrew bottle to
required: true
type: string
env:
SIMSLIM_RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
permissions:
contents: write
jobs:
release:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
if: github.event_name == 'push'
run: |
SIMSLIM_VERSION="${SIMSLIM_RELEASE_TAG#v}"
go test ./...
go build -ldflags "-X main.version=${SIMSLIM_VERSION}" -o simslim ./cmd/simslim
codesign --force --sign - simslim
tar -czf "simslim-${SIMSLIM_RELEASE_TAG}-macos-arm64.tar.gz" simslim
shasum -a 256 "simslim-${SIMSLIM_RELEASE_TAG}-macos-arm64.tar.gz"
- name: Build Homebrew bottle
run: |
SIMSLIM_SOURCE_URL="https://github.com/${GITHUB_REPOSITORY}/archive/refs/tags/${SIMSLIM_RELEASE_TAG}.tar.gz"
SIMSLIM_SOURCE_TARBALL="${RUNNER_TEMP}/simslim-source.tar.gz"
SIMSLIM_BUILD_TAP="mobai-app/simslim-release"
curl --fail --location --retry 3 "${SIMSLIM_SOURCE_URL}" --output "${SIMSLIM_SOURCE_TARBALL}"
SIMSLIM_SOURCE_SHA256="$(shasum -a 256 "${SIMSLIM_SOURCE_TARBALL}" | cut -d ' ' -f 1)"
brew tap-new --no-git "${SIMSLIM_BUILD_TAP}"
SIMSLIM_FORMULA="$(brew --repository "${SIMSLIM_BUILD_TAP}")/Formula/simslim.rb"
mkdir -p "$(dirname "${SIMSLIM_FORMULA}")"
sed \
-e "s|@SOURCE_URL@|${SIMSLIM_SOURCE_URL}|g" \
-e "s|@SOURCE_SHA256@|${SIMSLIM_SOURCE_SHA256}|g" \
packaging/homebrew/simslim.rb.in > "${SIMSLIM_FORMULA}"
brew install --build-bottle "${SIMSLIM_BUILD_TAP}/simslim"
brew test "${SIMSLIM_BUILD_TAP}/simslim"
brew bottle \
--json \
--no-rebuild \
--root-url "https://github.com/${GITHUB_REPOSITORY}/releases/download/${SIMSLIM_RELEASE_TAG}" \
"${SIMSLIM_BUILD_TAP}/simslim"
# brew uses a double dash locally; custom HTTP bottle URLs use one.
for SIMSLIM_BOTTLE in simslim--*.bottle*.tar.gz; do
mv "${SIMSLIM_BOTTLE}" "${SIMSLIM_BOTTLE/--/-}"
done
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.SIMSLIM_RELEASE_TAG }}
files: |
simslim-*-macos-arm64.tar.gz
simslim-*.bottle*.tar.gz