Skip to content

Merge pull request #51 from muxinc/dj/missing-api-endpoints #7

Merge pull request #51 from muxinc/dj/missing-api-endpoints

Merge pull request #51 from muxinc/dj/missing-api-endpoints #7

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: darwin-arm64
os: macos-latest
- target: darwin-x64
os: macos-15-intel
- target: linux-x64
os: ubuntu-latest
- target: linux-arm64
os: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: oven-sh/setup-bun@v2
- run: pnpm install --frozen-lockfile
- name: Set version from tag
run: node -e "const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.version='${GITHUB_REF_NAME#v}';fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n');"
- name: Build binary
run: bun build --compile --minify --sourcemap ./src/index.ts --target=bun-${{ matrix.target }} --outfile ./dist/mux-${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: mux-${{ matrix.target }}
path: ./dist/mux-${{ matrix.target }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/*
publish:
name: Publish to npm
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Publish to npm
run: ./scripts/publish.sh "${GITHUB_REF_NAME#v}" ./artifacts
homebrew:
name: Update Homebrew Tap
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Compute SHA256 checksums
id: checksums
run: |
echo "darwin_arm64=$(sha256sum artifacts/mux-darwin-arm64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
echo "darwin_x64=$(sha256sum artifacts/mux-darwin-x64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
echo "linux_arm64=$(sha256sum artifacts/mux-linux-arm64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
echo "linux_x64=$(sha256sum artifacts/mux-linux-x64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.HOMEBREW_APP_ID }}
private-key: ${{ secrets.HOMEBREW_APP_PRIVATE_KEY }}
owner: muxinc
repositories: homebrew-tap
- uses: actions/checkout@v4
with:
repository: muxinc/homebrew-tap
token: ${{ steps.app-token.outputs.token }}
- name: Generate formula
run: |
VERSION="${GITHUB_REF_NAME#v}"
BASE_URL="https://github.com/muxinc/cli/releases/download/${GITHUB_REF_NAME}"
mkdir -p Formula
cat > Formula/mux.rb << RUBY
class Mux < Formula
desc "The official Mux CLI"
homepage "https://github.com/muxinc/cli"
version "${VERSION}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "${BASE_URL}/mux-darwin-arm64"
sha256 "${{ steps.checksums.outputs.darwin_arm64 }}"
else
url "${BASE_URL}/mux-darwin-x64"
sha256 "${{ steps.checksums.outputs.darwin_x64 }}"
end
end
on_linux do
if Hardware::CPU.arm?
url "${BASE_URL}/mux-linux-arm64"
sha256 "${{ steps.checksums.outputs.linux_arm64 }}"
else
url "${BASE_URL}/mux-linux-x64"
sha256 "${{ steps.checksums.outputs.linux_x64 }}"
end
end
def install
binary = Dir.glob("mux-*").first || "mux"
bin.install binary => "mux"
end
test do
assert_match version.to_s, shell_output("#{bin}/mux --version")
end
end
RUBY
- name: Commit and push formula
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/mux.rb
git commit -m "mux ${GITHUB_REF_NAME}"
git push