Fix path for Switcher #4
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: 🏗️ CI/CD | |
on: push | |
jobs: | |
ci: | |
name: 🛠️ Build | |
runs-on: macos-latest | |
steps: | |
- name: 📥 Checkout code | |
uses: actions/checkout@v4 | |
- name: 🔨 Build Xcode project | |
uses: sersoft-gmbh/xcodebuild-action@v3 | |
with: | |
project: Switcher.xcodeproj | |
scheme: Switcher | |
destination: platform=macOS | |
configuration: Release | |
action: build | |
build-settings: CONFIGURATION_BUILD_DIR=build/Release | |
- name: 💿 Create .dmg | |
run: | | |
mkdir -p build/dmg/Switcher | |
cp -R build/Release/Switcher.app build/dmg/Switcher/ | |
ln -s /Applications build/dmg/Switcher/Applications | |
hdiutil create -volname Switcher \ | |
-srcfolder build/dmg/Switcher \ | |
-ov -format UDRO \ | |
build/dmg/Switcher-${{ github.ref_type == 'tag' && github.ref_name || github.sha }}.dmg | |
- name: 💎 Upload Build Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Switcher-Build | |
path: build/dmg/Switcher-${{ github.ref_type == 'tag' && github.ref_name || github.sha }}.dmg | |
cd: | |
name: 🚀 Release | |
needs: ci | |
if: github.ref_type == 'tag' | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: 📥 Checkout code | |
uses: actions/checkout@v4 | |
- name: 📝 Generate release changelog | |
id: changelog_step | |
uses: janheinrichmerker/action-github-changelog-generator@v2.3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: 📦 Download Build Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: Switcher-Build | |
- name: 🎈 Create or Update GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body: ${{ steps.changelog_step.outputs.changelog }} | |
files: Switcher-${{ github.ref_name }}.dmg | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 🍺 Update Homebrew Formula | |
uses: actions4git/setup-git@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 🍺 Update Homebrew Formula | |
run: | | |
sha256sum Switcher-${{ github.ref_name }}.dmg | awk '{ print $1 }' > /tmp/checksum | |
checksum=$(cat /tmp/checksum) | |
git clone https://github.com/Bobronium/homebrew-tap.git | |
cd homebrew-tap | |
formula_file="Formula/switcher.rb" | |
sed -i '' "s|url \".*\"|url \"https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/Switcher-${{ github.ref_name }}.dmg\"|" $formula_file | |
sed -i '' "s|sha256 \".*\"|sha256 \"$checksum\"|" $formula_file | |
git add Formula/switcher.rb | |
git commit -m "Bump version to ${{ github.ref_name }}" | |
git push |