Support brew. #174
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
permissions: | |
contents: write | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: macOS-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# Set the build number using the first 8 characters of the commit SHA | |
- name: Set Build Number from Commit SHA | |
run: | | |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-8) | |
/usr/bin/xcrun agvtool new-version -all $SHORT_SHA | |
# Import macOS code-signing certificates | |
- name: Import Code-Signing Certificates | |
uses: Apple-Actions/import-codesign-certs@v3 | |
with: | |
p12-file-base64: ${{ secrets.MACOS_CERTS_P12 }} | |
p12-password: ${{ secrets.P12_PASSWORD }} | |
# Install Dependencies | |
- name: Install Dependencies | |
run: | | |
brew install create-dmg | |
# Set Xcode Version | |
- uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: latest-stable | |
# Build Xcode Project for both architectures | |
- name: Build Xcode Project | |
run: | | |
xcodebuild -project "Amazon Bedrock Client for Mac.xcodeproj" \ | |
-scheme "Amazon Bedrock Client for Mac" \ | |
-configuration Release \ | |
-arch x86_64 -arch arm64 \ | |
-derivedDataPath DerivedData \ | |
-skipMacroValidation \ | |
ONLY_ACTIVE_ARCH=NO | |
# Package as DMG | |
- name: Package as DMG | |
run: | | |
export APP_PATH="$(pwd)/DerivedData/Build/Products/Release/Amazon Bedrock.app" | |
create-dmg --window-pos 200 120 \ | |
--window-size 800 400 \ | |
--icon-size 100 \ | |
--icon "Amazon Bedrock.app" 200 190 \ | |
--hide-extension "Amazon Bedrock.app" \ | |
--app-drop-link 600 185 \ | |
'Amazon Bedrock Client for Mac.dmg' "$APP_PATH" | |
# Upload Artifact (for both tags and main branch) | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "Amazon Bedrock Client for Mac" | |
path: "Amazon Bedrock Client for Mac.dmg" | |
# The following steps only run for tag pushes (releases) | |
- name: Calculate SHA256 for Homebrew cask | |
if: startsWith(github.ref, 'refs/tags/v') | |
id: shasum | |
run: | | |
DMG_SHA256=$(shasum -a 256 'Amazon Bedrock Client for Mac.dmg' | awk '{print $1}') | |
echo "sha=$DMG_SHA256" >> $GITHUB_OUTPUT | |
# Extract version from tag | |
- name: Extract version | |
if: startsWith(github.ref, 'refs/tags/v') | |
id: get_version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/v} | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
# Create Release | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: Amazon Bedrock Client for Mac.dmg | |
draft: false | |
prerelease: false | |
# Bump Homebrew Cask | |
- name: Bump Homebrew Cask | |
if: startsWith(github.ref, 'refs/tags/v') | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.BREW_TOKEN }} | |
run: | | |
brew tap didhd/tap | |
brew bump-formula-pr -f --cask --version=${{ steps.get_version.outputs.version }} --no-browse --no-audit \ | |
--sha256=${{ steps.shasum.outputs.sha }} \ | |
--url="https://github.com/aws-samples/amazon-bedrock-client-for-mac/releases/download/v${{ steps.get_version.outputs.version }}/Amazon.Bedrock.Client.for.Mac.dmg" \ | |
didhd/tap/amazon-bedrock-client |