name: Release on: push: tags: - 'v*' permissions: contents: write jobs: build-native: strategy: fail-fast: false matrix: include: - os: ubuntu-latest artifact: barn-linux-x64 - os: ubuntu-24.04-arm artifact: barn-linux-arm64 - os: macos-latest artifact: barn-macos-arm64 - os: macos-15-intel artifact: barn-macos-x64 - os: windows-latest artifact: barn-windows-x64 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Set up GraalVM uses: graalvm/setup-graalvm@v1 with: java-version: '21' distribution: 'graalvm' cache: 'maven' - name: Build native image (Unix) if: runner.os != 'Windows' run: | mvn package -Pnative -DskipTests -Dspotbugs.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true mv target/barn target/${{ matrix.artifact }} - name: Build native image (Windows) if: runner.os == 'Windows' shell: pwsh run: | mvn package -Pnative -DskipTests "-Dspotbugs.skip=true" "-Dpmd.skip=true" "-Dcheckstyle.skip=true" Move-Item -Path "target\barn.exe" -Destination "target\${{ matrix.artifact }}.exe" -Force Get-ChildItem target\*.exe - name: Build Windows installer if: runner.os == 'Windows' shell: pwsh run: | $version = "${{ github.ref_name }}" -replace '^v', '' choco install innosetup -y iscc /DAppVersion=$version installer\barn.iss Get-ChildItem dist\*.exe - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} path: target/${{ matrix.artifact }}* - name: Upload Windows installer if: runner.os == 'Windows' uses: actions/upload-artifact@v4 with: name: windows-installer path: dist/*.exe release: needs: build-native runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts/ - name: Prepare release files run: | mkdir release find artifacts -type f -exec mv {} release/ \; # Add installer scripts cp install.sh release/ cp install.ps1 release/ cd release sha256sum * > SHA256SUMS ls -la - name: Extract version id: version run: | VERSION=${GITHUB_REF#refs/tags/v} echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Extract changelog id: changelog run: | VERSION=${{ steps.version.outputs.version }} if [ -f CHANGELOG.md ]; then sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | head -n -1 > release_notes.md || true fi if [ ! -s release_notes.md ]; then echo "Release $VERSION" > release_notes.md fi - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: body_path: release_notes.md files: release/* draft: false prerelease: ${{ contains(github.ref, '-') }} - name: Get checksums for Homebrew id: checksums run: | cd release echo "macos_arm64_sha=$(grep barn-macos-arm64 SHA256SUMS | awk '{print $1}')" >> $GITHUB_OUTPUT echo "macos_x64_sha=$(grep barn-macos-x64 SHA256SUMS | awk '{print $1}')" >> $GITHUB_OUTPUT echo "linux_arm64_sha=$(grep barn-linux-arm64 SHA256SUMS | awk '{print $1}')" >> $GITHUB_OUTPUT echo "linux_x64_sha=$(grep barn-linux-x64 SHA256SUMS | awk '{print $1}')" >> $GITHUB_OUTPUT - name: Generate Homebrew tap token uses: actions/create-github-app-token@v2 id: homebrew-token with: app-id: ${{ vars.HOMEBREW_APP_ID }} private-key: ${{ secrets.HOMEBREW_APP_PRIVATE_KEY }} owner: samson-media repositories: homebrew-tap - name: Checkout homebrew tap uses: actions/checkout@v4 with: repository: samson-media/homebrew-tap token: ${{ steps.homebrew-token.outputs.token }} path: homebrew-tap - name: Update Homebrew formula env: VERSION: ${{ steps.version.outputs.version }} MACOS_ARM64_SHA: ${{ steps.checksums.outputs.macos_arm64_sha }} MACOS_X64_SHA: ${{ steps.checksums.outputs.macos_x64_sha }} LINUX_ARM64_SHA: ${{ steps.checksums.outputs.linux_arm64_sha }} LINUX_X64_SHA: ${{ steps.checksums.outputs.linux_x64_sha }} run: | cat > homebrew-tap/Formula/barn.rb << EOF class Barn < Formula desc "Cross-platform job daemon for media processing" homepage "https://github.com/samson-media/barn" version "${VERSION}" license "MIT" on_macos do on_arm do url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-macos-arm64" sha256 "${MACOS_ARM64_SHA}" def install bin.install "barn-macos-arm64" => "barn" end end on_intel do url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-macos-x64" sha256 "${MACOS_X64_SHA}" def install bin.install "barn-macos-x64" => "barn" end end end on_linux do on_arm do url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-linux-arm64" sha256 "${LINUX_ARM64_SHA}" def install bin.install "barn-linux-arm64" => "barn" end end on_intel do url "https://github.com/samson-media/barn/releases/download/v${VERSION}/barn-linux-x64" sha256 "${LINUX_X64_SHA}" def install bin.install "barn-linux-x64" => "barn" end end end test do assert_match "barn", shell_output("#{bin}/barn --version") end end EOF - name: Commit and push to Homebrew tap run: | cd homebrew-tap git config user.name "GitHub Actions" git config user.email "actions@github.com" git add Formula/barn.rb git diff --staged --quiet || git commit -m "Update barn to ${{ steps.version.outputs.version }}" git push