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
112 changes: 108 additions & 4 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,120 @@ on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
workflow_dispatch:
inputs:
tag:
description: "Tag to build and publish (e.g. v0.4.1)"
required: true
type: string

jobs:
release-please:
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}

build-release:
needs: [release-please]
runs-on: macos-26
if: >-
${{ !cancelled() &&
(needs.release-please.outputs.release_created == 'true' ||
github.event_name == 'workflow_dispatch') }}
permissions:
contents: write
env:
RELEASE_TAG: ${{ inputs.tag || needs.release-please.outputs.tag_name }}
steps:
- name: Verify release exists
run: gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_TAG }}

- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Build release binary
run: |
swift build -c release --product mocker
strip .build/release/mocker

- name: Create tarball
run: |
VERSION="${RELEASE_TAG}"
tar -czf "mocker-${VERSION}-arm64-apple-macosx.tar.gz" \
-C .build/release mocker
echo "TARBALL=mocker-${VERSION}-arm64-apple-macosx.tar.gz" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV

- name: Compute SHA256
run: |
SHA256=$(shasum -a 256 "$TARBALL" | awk '{print $1}')
echo "SHA256=${SHA256}" >> $GITHUB_ENV
echo "SHA256: ${SHA256}"

- name: Upload binary to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
files: ${{ env.TARBALL }}

- name: Update Homebrew formula
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
FORMULA_URL="https://github.com/${{ github.repository }}/releases/download/${VERSION}/${TARBALL}"

git clone https://x-access-token:${GH_TOKEN}@github.com/us/homebrew-tap.git /tmp/homebrew-tap
cd /tmp/homebrew-tap

cat > Formula/mocker.rb << EOF
class Mocker < Formula
desc "Docker-compatible container CLI built on Apple's Containerization framework"
homepage "https://github.com/us/mocker"
url "${FORMULA_URL}"
sha256 "${SHA256}"
license "MIT"
version "${VERSION#v}"

def install
bin.install "mocker"
end

def caveats
<<~EOS
Mocker requires Apple's container CLI to be installed:
https://github.com/apple/container

macOS 26+ and Apple Silicon are required.
EOS
end

test do
assert_match "${VERSION#v}", shell_output("#{bin}/mocker --version")
end
end
EOF

git config user.email "[email protected]"
git config user.name "us"
git add Formula/mocker.rb
git commit -m "chore: update mocker to ${VERSION}"
git push
100 changes: 0 additions & 100 deletions .github/workflows/release.yml

This file was deleted.

Loading