diff --git a/.github/workflows/brew-tarball.yml b/.github/workflows/brew-tarball.yml new file mode 100644 index 0000000..4cb5e4a --- /dev/null +++ b/.github/workflows/brew-tarball.yml @@ -0,0 +1,38 @@ +name: Generate Homebrew tarball and Release + +on: + push: + merge_group: + pull_request: + paths: + - ./Justfile + +jobs: + generate_and_push: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: ["arm64", "amd64"] + steps: + - uses: actions/checkout@v4 + - name: Setup Just + uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2 + + - name: Generate Homebrew tarball + id: generate_tarball + run: | + set -euox pipefail + just=$(which just) + OUTDIR=./brew-out + $just generate-homebrew-tarball $OUTDIR + echo "outdir=$(realpath $OUTDIR)" >> "$GITHUB_OUTPUT" + + - name: Upload to Job Artifacts + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4 + with: + name: brew-tarball + if-no-files-found: error + path: | + ${{ steps.generate_tarball.outputs.outdir }}/*.tar* + diff --git a/.gitignore b/.gitignore index e0fa512..b0af106 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ output/ mock/ -rpmbuild +rpmbuild/ +brew-out/ diff --git a/Justfile b/Justfile index 6cbdb19..fdd39bf 100644 --- a/Justfile +++ b/Justfile @@ -33,3 +33,23 @@ build $spec *MOCK_ARGS: --group-entry "mock:x:135:$(id -nu)" \ $mock_image \ $spec {{ MOCK_ARGS }} + +generate-homebrew-tarball $OUTDIR="./brew-out": + #!/usr/bin/env bash + + set -x + + mkdir -p $OUTDIR + + podman run --rm -it \ + -v "$OUTDIR:/outdir:Z" \ + cgr.dev/chainguard/wolfi-base:latest \ + /bin/sh -c " + set -o xtrace + apk add curl git zstd posix-libc-utils uutils + curl --retry 3 -Lo /tmp/brew-install https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh + chmod +x /tmp/brew-install + touch /.dockerenv + ln -s /bin/bash /usr/bin/bash + env --ignore-environment PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME=/home/linuxbrew NONINTERACTIVE=1 /usr/bin/bash /tmp/brew-install + tar -cvf /dev/stdout /home/linuxbrew | zstd -v -T0 -10 -f -o /outdir/brew.tar.zst"