feature/ci-debian
yml 196 lines 5.59 KB
Raw
1 name: Homebrew Release
2
3 on:
4 release:
5 types: [published]
6 workflow_dispatch:
7 inputs:
8 tag:
9 description: "Release tag (e.g. v0.1.0)"
10 required: true
11
12 permissions:
13 contents: write
14
15 env:
16 PROJECT_NAME: proses
17 CARGO_TERM_COLOR: always
18
19 jobs:
20 build-macos:
21 name: Build macOS (${{ matrix.arch }})
22 runs-on: ${{ matrix.runner }}
23
24 strategy:
25 fail-fast: false
26 matrix:
27 include:
28 - arch: arm64
29 runner: macos-latest
30 target: aarch64-apple-darwin
31 - arch: amd64
32 runner: macos-15-intel
33 target: x86_64-apple-darwin
34
35 steps:
36 - name: Resolve release tag
37 id: tag
38 shell: bash
39 run: |
40 if [[ "${{ github.event_name }}" == "release" ]]; then
41 TAG="${{ github.event.release.tag_name }}"
42 else
43 TAG="${{ github.event.inputs.tag }}"
44 fi
45 echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
46
47 - name: Checkout
48 uses: actions/checkout@v6
49 with:
50 ref: ${{ steps.tag.outputs.tag }}
51
52 - name: Install Rust toolchain
53 uses: dtolnay/rust-toolchain@stable
54
55 - name: Setup Rust cache
56 uses: Swatinem/rust-cache@v2
57 with:
58 key: homebrew-${{ matrix.target }}
59
60 - name: Build
61 shell: bash
62 run: |
63 cargo build --release --locked --target ${{ matrix.target }}
64
65 - name: Package tarball
66 shell: bash
67 run: |
68 ARCHIVE_NAME="${PROJECT_NAME}-macos-${{ matrix.arch }}.tar.gz"
69
70 mkdir -p staging
71 cp "target/${{ matrix.target }}/release/${PROJECT_NAME}" staging/
72 strip "staging/${PROJECT_NAME}"
73
74 tar -C staging -czf "${ARCHIVE_NAME}" "${PROJECT_NAME}"
75
76 shasum -a 256 "${ARCHIVE_NAME}" | awk '{print $1}' > "${ARCHIVE_NAME}.sha256"
77
78 echo "Archive: ${ARCHIVE_NAME}"
79 echo "SHA256: $(cat "${ARCHIVE_NAME}.sha256")"
80
81 - name: Upload artifact
82 uses: actions/upload-artifact@v4
83 with:
84 name: proses-macos-${{ matrix.arch }}
85 path: |
86 proses-macos-${{ matrix.arch }}.tar.gz
87 proses-macos-${{ matrix.arch }}.tar.gz.sha256
88
89 - name: Attach to GitHub Release
90 uses: softprops/action-gh-release@v2
91 with:
92 tag_name: ${{ steps.tag.outputs.tag }}
93 files: proses-macos-${{ matrix.arch }}.tar.gz
94
95 update-homebrew-tap:
96 name: Update Homebrew tap
97 needs: build-macos
98 runs-on: ubuntu-latest
99
100 steps:
101 - name: Resolve tag and version
102 id: release
103 shell: bash
104 run: |
105 if [[ "${{ github.event_name }}" == "release" ]]; then
106 TAG="${{ github.event.release.tag_name }}"
107 else
108 TAG="${{ github.event.inputs.tag }}"
109 fi
110 VERSION="${TAG#v}"
111
112 echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
113 echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
114
115 - name: Download artifacts
116 uses: actions/download-artifact@fa0a91b85d4f404e444306234406b6c83c46849f # v4.1.8
117 with:
118 path: artifacts/
119
120 - name: Read SHA256 checksums
121 id: sha
122 shell: bash
123 run: |
124 ARM64_SHA=$(cat artifacts/proses-macos-arm64/proses-macos-arm64.tar.gz.sha256)
125 AMD64_SHA=$(cat artifacts/proses-macos-amd64/proses-macos-amd64.tar.gz.sha256)
126
127 echo "arm64=${ARM64_SHA}" >> "$GITHUB_OUTPUT"
128 echo "amd64=${AMD64_SHA}" >> "$GITHUB_OUTPUT"
129
130 echo "ARM64 SHA256: ${ARM64_SHA}"
131 echo "AMD64 SHA256: ${AMD64_SHA}"
132
133 - name: Checkout Homebrew tap
134 uses: actions/checkout@v6
135 with:
136 repository: smbcloudXYZ/homebrew-tap
137 token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
138 path: homebrew-tap
139
140 - name: Generate formula
141 shell: bash
142 run: |
143 VERSION="${{ steps.release.outputs.version }}"
144 TAG="${{ steps.release.outputs.tag }}"
145 ARM64_SHA="${{ steps.sha.outputs.arm64 }}"
146 AMD64_SHA="${{ steps.sha.outputs.amd64 }}"
147 REPO="smbcloudXYZ/proses"
148
149 mkdir -p homebrew-tap/Formula
150
151 cat > homebrew-tap/Formula/proses.rb <<FORMULA
152 # frozen_string_literal: true
153
154 # Homebrew formula for Proses (\`proses\` binary).
155 class Proses < Formula
156 desc 'Professional Secure Execution System — fast, secure process manager'
157 homepage 'https://github.com/${REPO}'
158 version '${VERSION}'
159 license 'MIT'
160
161 on_macos do
162 on_arm do
163 url 'https://github.com/${REPO}/releases/download/${TAG}/proses-macos-arm64.tar.gz'
164 sha256 '${ARM64_SHA}'
165 end
166 on_intel do
167 url 'https://github.com/${REPO}/releases/download/${TAG}/proses-macos-amd64.tar.gz'
168 sha256 '${AMD64_SHA}'
169 end
170 end
171
172 def install
173 bin.install 'proses'
174 end
175
176 test do
177 system "#{bin}/proses", '--version'
178 end
179 end
180 FORMULA
181
182 echo "Generated formula:"
183 cat homebrew-tap/Formula/proses.rb
184
185 - name: Commit and push
186 shell: bash
187 run: |
188 VERSION="${{ steps.release.outputs.version }}"
189
190 cd homebrew-tap
191 git config user.name "github-actions[bot]"
192 git config user.email "github-actions[bot]@users.noreply.github.com"
193 git add Formula/proses.rb
194 git diff --cached --quiet && echo "No changes to commit." && exit 0
195 git commit -m "Update proses to ${VERSION}"
196 git push