|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: macos-14 |
| 17 | + target: darwin-arm64 |
| 18 | + - os: macos-13 |
| 19 | + target: darwin-x64 |
| 20 | + - os: ubuntu-latest |
| 21 | + target: linux-x64 |
| 22 | + - os: ubuntu-latest |
| 23 | + target: linux-arm64 |
| 24 | + |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Setup Bun |
| 32 | + uses: oven-sh/setup-bun@v2 |
| 33 | + with: |
| 34 | + bun-version: latest |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: bun install |
| 38 | + |
| 39 | + - name: Build binary |
| 40 | + run: | |
| 41 | + cat > build-single.ts << 'EOF' |
| 42 | + import solidPlugin from "./node_modules/@opentui/solid/scripts/solid-plugin"; |
| 43 | + const target = process.argv[2]; |
| 44 | + const result = await Bun.build({ |
| 45 | + entrypoints: ["./src/index.tsx"], |
| 46 | + target: "bun", |
| 47 | + plugins: [solidPlugin], |
| 48 | + minify: true, |
| 49 | + compile: { |
| 50 | + target: `bun-${target}` as any, |
| 51 | + outfile: `dist/devproc-${target}`, |
| 52 | + }, |
| 53 | + }); |
| 54 | + if (!result.success) { |
| 55 | + console.error("Build failed:", result.logs); |
| 56 | + process.exit(1); |
| 57 | + } |
| 58 | + EOF |
| 59 | + mkdir -p dist |
| 60 | + bun run build-single.ts ${{ matrix.target }} |
| 61 | +
|
| 62 | + - name: Create tarball |
| 63 | + run: | |
| 64 | + cd dist |
| 65 | + tar -czf devproc-${{ github.ref_name }}-${{ matrix.target }}.tar.gz --transform 's/devproc-${{ matrix.target }}/devproc/' devproc-${{ matrix.target }} |
| 66 | + shasum -a 256 devproc-${{ github.ref_name }}-${{ matrix.target }}.tar.gz > devproc-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256 |
| 67 | +
|
| 68 | + - name: Upload artifact |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: devproc-${{ matrix.target }} |
| 72 | + path: | |
| 73 | + dist/devproc-${{ github.ref_name }}-${{ matrix.target }}.tar.gz |
| 74 | + dist/devproc-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256 |
| 75 | +
|
| 76 | + release: |
| 77 | + needs: build |
| 78 | + runs-on: ubuntu-latest |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Download all artifacts |
| 85 | + uses: actions/download-artifact@v4 |
| 86 | + with: |
| 87 | + path: artifacts |
| 88 | + merge-multiple: true |
| 89 | + |
| 90 | + - name: Create checksums and get SHAs |
| 91 | + id: checksums |
| 92 | + run: | |
| 93 | + cd artifacts |
| 94 | + cat *.sha256 > checksums.txt |
| 95 | + cat checksums.txt |
| 96 | + echo "darwin_arm64=$(grep darwin-arm64 *.sha256 | head -1 | cut -d' ' -f1)" >> $GITHUB_OUTPUT |
| 97 | + echo "darwin_x64=$(grep darwin-x64 *.sha256 | head -1 | cut -d' ' -f1)" >> $GITHUB_OUTPUT |
| 98 | + echo "linux_x64=$(grep linux-x64 *.sha256 | head -1 | cut -d' ' -f1)" >> $GITHUB_OUTPUT |
| 99 | + echo "linux_arm64=$(grep linux-arm64 *.sha256 | head -1 | cut -d' ' -f1)" >> $GITHUB_OUTPUT |
| 100 | +
|
| 101 | + - name: Create Release |
| 102 | + uses: softprops/action-gh-release@v2 |
| 103 | + with: |
| 104 | + files: | |
| 105 | + artifacts/*.tar.gz |
| 106 | + artifacts/checksums.txt |
| 107 | + generate_release_notes: true |
| 108 | + draft: false |
| 109 | + prerelease: ${{ contains(github.ref, '-') }} |
| 110 | + |
| 111 | + - name: Extract version |
| 112 | + id: version |
| 113 | + run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT |
| 114 | + |
| 115 | + - name: Update Homebrew formula |
| 116 | + run: | |
| 117 | + VERSION="${{ steps.version.outputs.version }}" |
| 118 | + DARWIN_ARM64="${{ steps.checksums.outputs.darwin_arm64 }}" |
| 119 | + DARWIN_X64="${{ steps.checksums.outputs.darwin_x64 }}" |
| 120 | + LINUX_X64="${{ steps.checksums.outputs.linux_x64 }}" |
| 121 | + LINUX_ARM64="${{ steps.checksums.outputs.linux_arm64 }}" |
| 122 | +
|
| 123 | + cat > Formula/devproc.rb << EOF |
| 124 | + # typed: false |
| 125 | + # frozen_string_literal: true |
| 126 | +
|
| 127 | + class Devproc < Formula |
| 128 | + desc "Terminal UI for managing local development environments" |
| 129 | + homepage "https://github.com/captjt/devproc" |
| 130 | + version "${VERSION}" |
| 131 | + license "MIT" |
| 132 | +
|
| 133 | + on_macos do |
| 134 | + if Hardware::CPU.arm? |
| 135 | + url "https://github.com/captjt/devproc/releases/download/v${VERSION}/devproc-v${VERSION}-darwin-arm64.tar.gz" |
| 136 | + sha256 "${DARWIN_ARM64}" |
| 137 | + else |
| 138 | + url "https://github.com/captjt/devproc/releases/download/v${VERSION}/devproc-v${VERSION}-darwin-x64.tar.gz" |
| 139 | + sha256 "${DARWIN_X64}" |
| 140 | + end |
| 141 | + end |
| 142 | +
|
| 143 | + on_linux do |
| 144 | + if Hardware::CPU.arm? |
| 145 | + url "https://github.com/captjt/devproc/releases/download/v${VERSION}/devproc-v${VERSION}-linux-arm64.tar.gz" |
| 146 | + sha256 "${LINUX_ARM64}" |
| 147 | + else |
| 148 | + url "https://github.com/captjt/devproc/releases/download/v${VERSION}/devproc-v${VERSION}-linux-x64.tar.gz" |
| 149 | + sha256 "${LINUX_X64}" |
| 150 | + end |
| 151 | + end |
| 152 | +
|
| 153 | + def install |
| 154 | + bin.install "devproc" |
| 155 | + end |
| 156 | +
|
| 157 | + test do |
| 158 | + assert_match "DevProc v#{version}", shell_output("#{bin}/devproc --version") |
| 159 | + end |
| 160 | + end |
| 161 | + EOF |
| 162 | +
|
| 163 | + - name: Commit formula update |
| 164 | + run: | |
| 165 | + git config user.name "github-actions[bot]" |
| 166 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 167 | + git add Formula/devproc.rb |
| 168 | + git commit -m "Update Homebrew formula to v${{ steps.version.outputs.version }}" |
| 169 | + git push origin HEAD:master |
0 commit comments