changelog #32
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image with FFmpeg 8 | |
| run: | | |
| docker build -f Dockerfile.build -t reels-builder . | |
| - name: Build binary in container | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| docker run --rm -v ${{ github.workspace }}:/app reels-builder \ | |
| sh -c "go build -buildvcs=false -ldflags '-X main.Version=$VERSION' -o reels-linux-amd64 ." | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: reels-linux-amd64 | |
| path: reels-linux-amd64 | |
| build-macos: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| - name: Install dependencies | |
| run: | | |
| brew update | |
| brew install ffmpeg-full | |
| brew upgrade ffmpeg-full 2>/dev/null || true | |
| echo "PKG_CONFIG_PATH=$(brew --prefix ffmpeg-full)/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV | |
| echo "LDFLAGS=-L$(brew --prefix ffmpeg-full)/lib" >> $GITHUB_ENV | |
| echo "CFLAGS=-I$(brew --prefix ffmpeg-full)/include" >> $GITHUB_ENV | |
| echo "CGO_LDFLAGS=-L$(brew --prefix ffmpeg-full)/lib" >> $GITHUB_ENV | |
| echo "CGO_CFLAGS=-I$(brew --prefix ffmpeg-full)/include" >> $GITHUB_ENV | |
| - name: Build | |
| env: | |
| CGO_ENABLED: 1 | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| go build -ldflags "-X main.Version=$VERSION" -o reels-darwin-arm64 . | |
| # Rewrite dylib references to use @rpath so the binary works with any | |
| # FFmpeg 8+ installation, not just ffmpeg-full from Homebrew. | |
| for dylib_path in $(otool -L reels-darwin-arm64 | grep "Cellar/ffmpeg\|/opt/homebrew" | awk '{print $1}'); do | |
| filename=$(basename "$dylib_path") | |
| stable_name=$(echo "$filename" | sed -E 's/(lib[a-z]+\.[0-9]+)\.[0-9]+\.[0-9]+\.dylib/\1.dylib/') | |
| echo "Rewriting: $dylib_path -> @rpath/$stable_name" | |
| install_name_tool -change "$dylib_path" "@rpath/$stable_name" reels-darwin-arm64 | |
| done | |
| # Add search paths for common FFmpeg install locations | |
| install_name_tool -add_rpath /opt/homebrew/opt/ffmpeg-full/lib reels-darwin-arm64 | |
| install_name_tool -add_rpath /opt/homebrew/opt/ffmpeg/lib reels-darwin-arm64 | |
| install_name_tool -add_rpath /usr/local/lib reels-darwin-arm64 | |
| install_name_tool -add_rpath /opt/homebrew/lib reels-darwin-arm64 | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: reels-darwin-arm64 | |
| path: reels-darwin-arm64 | |
| release: | |
| needs: [build-linux, build-macos] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create source tarball | |
| run: | | |
| git archive --format=tar.gz --prefix=reels-${GITHUB_REF_NAME#v}/ HEAD > artifacts/reels-${GITHUB_REF_NAME#v}.tar.gz | |
| - name: Extract changelog | |
| id: changelog | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#v} | |
| # Extract the section for this version (between its heading and the next heading) | |
| BODY=$(awk "/^## \\[${VERSION}\\]/{found=1; next} /^## \\[/{if(found) exit} found{print}" CHANGELOG.md) | |
| # Fall back to auto-generated notes if no changelog entry exists | |
| if [ -z "$BODY" ]; then | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "found=true" >> $GITHUB_OUTPUT | |
| { | |
| echo "body<<EOF" | |
| echo "$BODY" | |
| echo "EOF" | |
| } >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| artifacts/reels-linux-amd64/reels-linux-amd64 | |
| artifacts/reels-darwin-arm64/reels-darwin-arm64 | |
| artifacts/reels-*.tar.gz | |
| body: ${{ steps.changelog.outputs.found == 'true' && steps.changelog.outputs.body || '' }} | |
| generate_release_notes: ${{ steps.changelog.outputs.found != 'true' }} |