Skip to content

Commit 5694a3e

Browse files
committed
Revert "Remove Homebrew tap setup workflow and associated formula for Cpw, streamlining the repository by eliminating unused files."
This reverts commit a9206a1.
1 parent a9206a1 commit 5694a3e

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

.github/workflows/setup_tap.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Setup Homebrew Tap
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
create_repo:
7+
description: 'Create tap repository if it does not exist'
8+
required: true
9+
default: 'true'
10+
11+
jobs:
12+
setup-tap:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Create tap repository
19+
if: ${{ github.event.inputs.create_repo == 'true' }}
20+
uses: actions/github-script@v6
21+
with:
22+
github-token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
23+
script: |
24+
try {
25+
const { data } = await github.rest.repos.get({
26+
owner: context.repo.owner,
27+
repo: 'homebrew-cpw'
28+
});
29+
console.log('Tap repository already exists');
30+
} catch (error) {
31+
if (error.status === 404) {
32+
console.log('Creating tap repository...');
33+
const { data } = await github.rest.repos.createInOrg({
34+
org: context.repo.owner,
35+
name: 'homebrew-cpw',
36+
description: 'Homebrew tap for CPW - Copy on Write file watcher',
37+
private: false,
38+
auto_init: true
39+
});
40+
console.log('Tap repository created: ' + data.html_url);
41+
} else {
42+
console.error('Error checking repository:', error);
43+
process.exit(1);
44+
}
45+
}
46+
47+
- name: Setup Git
48+
run: |
49+
git config --global user.email "action@github.com"
50+
git config --global user.name "GitHub Action"
51+
52+
- name: Clone tap repository
53+
run: |
54+
git clone https://${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/${{ github.repository_owner }}/homebrew-cpw.git tap
55+
56+
- name: Create formula directory
57+
run: |
58+
mkdir -p tap/Formula
59+
60+
- name: Copy formula template
61+
run: |
62+
cp Formula/cpw.rb tap/Formula/
63+
64+
- name: Commit and push
65+
working-directory: ./tap
66+
run: |
67+
git add Formula/cpw.rb
68+
git commit -m "Initial formula setup" || echo "No changes to commit"
69+
git push https://${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/${{ github.repository_owner }}/homebrew-cpw.git

Formula/cpw.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Cpw < Formula
2+
desc "File watcher that copies changed files to a destination"
3+
homepage "https://github.com/mxvsh/cpw"
4+
version "VERSION_PLACEHOLDER"
5+
6+
on_macos do
7+
if Hardware::CPU.arm?
8+
url "https://github.com/mxvsh/cpw/releases/download/vVERSION_PLACEHOLDER/cpw-darwin-arm64"
9+
sha256 "SHA256_PLACEHOLDER_DARWIN_ARM64"
10+
end
11+
end
12+
13+
on_linux do
14+
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
15+
url "https://github.com/mxvsh/cpw/releases/download/vVERSION_PLACEHOLDER/cpw-linux-arm64"
16+
sha256 "SHA256_PLACEHOLDER_LINUX_ARM64"
17+
end
18+
if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
19+
url "https://github.com/mxvsh/cpw/releases/download/vVERSION_PLACEHOLDER/cpw-linux-armv7"
20+
sha256 "SHA256_PLACEHOLDER_LINUX_ARM"
21+
end
22+
end
23+
24+
def install
25+
bin.install Dir["cpw-*"].first => "cpw"
26+
end
27+
28+
test do
29+
system "#{bin}/cpw", "-version"
30+
end
31+
end

0 commit comments

Comments
 (0)