@smbcloud / proses / commits / f370734

Add GitHub action workflow for crate and Homebrew distribution

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