Skip to content

Commit

Permalink
Adding homebrew build
Browse files Browse the repository at this point in the history
  • Loading branch information
kebernet committed Jul 31, 2024
1 parent f6ae8cf commit 6195b7e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 32 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ jobs:
asset_name: github-actions-notifier-${{ needs.project-info.outputs.PROJECT_VERSION }}-1.x86_64.rpm
asset_content_type: application/x-rpm
- name: Upload Mac ARM
id: mac-arm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -296,8 +297,14 @@ jobs:
- name: Build Homebrew Formula
run: |
wget https://github.com/atl-tw/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}/archive/refs/tags/${{ needs.project-info.outputs.PROJECT_VERSION }}.zip
ZIP_SHA=$(shasum -a 256 ${{ needs.project-info.outputs.PROJECT_VERSION }}.zip | awk '{print $1}')
./mvnw "-Dbrew.asset.url=https://github.com/atl-tw/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}/archive/refs/tags/${{ needs.project-info.outputs.PROJECT_VERSION }}.zip" -Dbrew.asset.hash=$ZIP_SHA --batch-mode package
ARM_SHA=$(shasum -a 256 ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-ARM_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | awk '{print $1}')
X86_SHA=$(shasum -a 256 ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-ARM_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | awk '{print $1}')
./mvnw "-Dbrew.arm.asset.url=${{ steps.mac-arm.outputs.browser_download_url}}" \
"-Dbrew.arm.asset.hash=$ARM_SHA" \
"-Dbrew.x86.asset.url=${{ steps.mac-arm.outputs.browser_download_url}}" \
"-Dbrew.x86.asset.hash=$ARM_SHA" \
--batch-mode package
- name: Publish Homebrew
env:
DESTINATION_BRANCH: main
Expand Down
50 changes: 37 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
<junit.version>5.10.2</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClassName>com.thoughtworks.gha.notifier.GitHubNotifier</mainClassName>
<brew.formula.name>GhaNotifier</brew.formula.name>
<brew.formula.name>GitHub Actions Notifier</brew.formula.name>
<brew.arm.asset.url>http://arm/url</brew.arm.asset.url>
<brew.arm.asset.hash>BBBB</brew.arm.asset.hash>
<brew.x86.asset.url>http://x86/url</brew.x86.asset.url>
<brew.x86.asset.hash>AAAA</brew.x86.asset.hash>
</properties>
<repositories>
<repository>
Expand Down Expand Up @@ -129,9 +133,9 @@
<goal>replace</goal>
</goals>
<configuration>
<file>src/main/brew/Formula.rb</file>
<file>src/main/brew/Cask.rb</file>
<outputFile>
target/brew/${project.artifactId}/Formula/${project.artifactId}.rb
target/brew/${project.artifactId}/Casks/${project.artifactId}.rb
</outputFile>
<replacements>
<replacement>
Expand All @@ -144,13 +148,23 @@
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@asseturl@</token>
<value>${brew.asset.url}</value>
<token>@armasseturl@</token>
<value>${brew.arm.asset.url}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@assethash@</token>
<value>${brew.asset.hash}</value>
<token>@armassethash@</token>
<value>${brew.arm.asset.hash}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@x86asseturl@</token>
<value>${brew.x86.asset.url}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@x86assethash@</token>
<value>${brew.x86.asset.hash}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
Expand All @@ -176,9 +190,9 @@
<goal>replace</goal>
</goals>
<configuration>
<file>src/main/brew/Formula.rb</file>
<file>src/main/brew/Cask.rb</file>
<outputFile>
target/brew/${project.artifactId}/Formula/${project.artifactId}@${project.version}.rb
target/brew/${project.artifactId}/Casks/${project.artifactId}@${project.version}.rb
</outputFile>
<replacements>
<replacement>
Expand All @@ -191,13 +205,23 @@
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@asseturl@</token>
<value>${brew.asset.url}</value>
<token>@armasseturl@</token>
<value>${brew.arm.asset.url}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@armassethash@</token>
<value>${brew.arm.asset.hash}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@x86asseturl@</token>
<value>${brew.x86.asset.url}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
<token>@assethash@</token>
<value>${brew.asset.hash}</value>
<token>@x86assethash@</token>
<value>${brew.x86.asset.hash}</value>
</replacement>
<replacement>
<!--suppress UnresolvedMavenProperty -->
Expand Down
23 changes: 23 additions & 0 deletions src/main/brew/Cask.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cask "@artifactId@" do
version "@version@"

# Define URLs for different architectures
if Hardware::CPU.arm?
url "@armasseturl@"
sha256 "@armassethash@"
else
url "@x86asseturl@"
sha256 :"@x86assethash@"
end

name "@name@""
homepage "@homepage@" # Replace with the application's homepage
app "@name@.app"
postflight do
system_command "xattr",
args: ["-d", "com.apple.quarantine", "#{appdir}/@name@.app"],
sudo: true
end

end
17 changes: 0 additions & 17 deletions src/main/brew/Formula.rb

This file was deleted.

0 comments on commit 6195b7e

Please sign in to comment.