mirror of
https://github.com/ublue-os/brew.git
synced 2026-11-03 21:49:43 -09:00
111 lines
4.1 KiB
YAML
111 lines
4.1 KiB
YAML
name: Generate Homebrew Tarball and Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
paths:
|
|
- ".github/workflows/brew-tarball.yml"
|
|
schedule:
|
|
- cron: "0 1 * * TUE" # Every Tuesday at 1am UTC
|
|
|
|
jobs:
|
|
create_release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: write
|
|
outputs:
|
|
tag_date: ${{ steps.date.outputs.tag_date }}
|
|
steps:
|
|
- name: Get current date
|
|
if: github.event_name != 'pull_request'
|
|
id: date
|
|
run: |
|
|
set -x
|
|
echo "date=$(date -u +%Y\-%m\-%d\ %H\:%M\:%S)" >> $GITHUB_OUTPUT
|
|
echo "tag_date=$(date -u +%Y\-%m\-%d-%H-%M-%S)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create Release
|
|
if: github.event_name != 'pull_request'
|
|
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2
|
|
with:
|
|
name: Homebrew Tarball (${{ steps.date.outputs.date }})
|
|
tag_name: "homebrew-${{ steps.date.outputs.tag_date }}"
|
|
body: |
|
|
This is a homebrew tarball generated for the [ublue-brew](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/ublue/brew/ublue-brew.spec) package.
|
|
It exists so that images can have a consistent tarball to base to install homebrew
|
|
make_latest: true
|
|
|
|
push_tarballs:
|
|
name: Generate Homebrew Tarball and Push to Release
|
|
runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
|
|
needs: create_release
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: write
|
|
strategy:
|
|
matrix:
|
|
platform: [arm64, amd64]
|
|
fail-fast: false
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
|
- name: Setup Just
|
|
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
|
|
|
|
- name: Generate Homebrew tarball
|
|
id: generate_tarball
|
|
run: |
|
|
set -euox pipefail
|
|
just=$(which just)
|
|
|
|
OUTDIR="./brew-out"
|
|
SHASUM_DIR="./brew-sum"
|
|
TARBALL_FILENAME="homebrew-$(arch).tar.zst"
|
|
|
|
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 gnutar grep
|
|
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
|
|
ls -s /usr/bin/grep /bin/grep
|
|
env --ignore-environment PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME=/home/linuxbrew NONINTERACTIVE=1 /usr/bin/bash /tmp/brew-install
|
|
tar --zstd -cvf /outdir/${TARBALL_FILENAME} /home/linuxbrew/.linuxbrew"
|
|
|
|
mkdir -p $SHASUM_DIR
|
|
for spice in 1 256 512 ; do
|
|
"sha${spice}sum" "$OUTDIR/$TARBALL_FILENAME" | tee "$SHASUM_DIR/homebrew-$(arch).sha${spice}"
|
|
done
|
|
|
|
echo "outdir=$(realpath $OUTDIR)" >> "$GITHUB_OUTPUT"
|
|
echo "tarball_file=$(realpath $OUTDIR)/$TARBALL_FILENAME" >> "$GITHUB_OUTPUT"
|
|
echo "shasum_dir=$(realpath $SHASUM_DIR)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload to Job Artifacts
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
with:
|
|
name: brew-tarball-${{ matrix.platform }}
|
|
if-no-files-found: error
|
|
path: |
|
|
${{ steps.generate_tarball.outputs.tarball_file }}
|
|
${{ steps.generate_tarball.outputs.shasum_dir }}/*
|
|
|
|
- name: Upload Release Artifact
|
|
if: github.event_name != 'pull_request'
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
TAG_DATE: ${{ needs.create_release.outputs.tag_date }}
|
|
TARBALL_FILE: ${{ steps.generate_tarball.outputs.tarball_file }}
|
|
SHASUM_DIR: ${{ steps.generate_tarball.outputs.shasum_dir }}
|
|
run: |
|
|
gh release upload --clobber \
|
|
"homebrew-${TAG_DATE}" \
|
|
"${TARBALL_FILE}" \
|
|
"${SHASUM_DIR}"/*
|