Skip to content

Commit

Permalink
ci: 👷 update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaquero committed Feb 1, 2025
1 parent 5c6e69a commit ffa5762
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ echo "> Running brew bump dry-run..."

items=$(brew livecheck --tap brewforge/chinese --extract-plist --full-name --json || echo "[]")

for item in $(echo "$items" | jq -r '.[] | .formula, .cask'); do
for item in $(echo "$items" | jq -r '.[] | .cask'); do
if [ "$item" == "null" ]; then
continue
fi

echo "---" # newline

item_obj=$(echo "$items" | jq --arg item "$item" '.[] | select(.formula == $item or .cask == $item)')
item_obj=$(echo "$items" | jq --arg item "$item" '.[] | select(.cask == $item)')

is_cask=$(echo "$item_obj" | jq -r '.cask')
is_formula=$(echo "$item_obj" | jq -r '.formula')

item_status=$(echo "$item_obj" | jq -r '.status')
item_version_current=$(echo "$item_obj" | jq -r '.version.current')
Expand All @@ -40,16 +39,14 @@ for item in $(echo "$items" | jq -r '.[] | .formula, .cask'); do
continue
fi

# bump.
# bump
echo "> Bumping $item from $item_version_current to $item_version_latest..."

if [ "$item_version_latest" == "null" ]; then
echo "$item_obj"

if [ -n "$is_cask" ]; then
cat "$(brew edit --cask "$item" --print-path)"
elif [ -n "$is_formula" ]; then
cat "$(brew edit "$item" --print-path)"
fi

echo -e "\033[0;31m> Error: version.latest is null\033[0m"
Expand All @@ -66,12 +63,6 @@ for item in $(echo "$items" | jq -r '.[] | .formula, .cask'); do
echo "* Running brew bump-cask-pr $item --version=$item_version_latest $_BUMP_OPTIONS..."
brew bump-cask-pr "$item" --version="$item_version_latest" $_BUMP_OPTIONS
# echo "* TDOO: brew bump-cask-pr $item --version=$item_version_latest $_BUMP_OPTIONS"
elif [ "$is_formula" != "null" ]; then
# is_formula.

echo "* Running brew bump-formula-pr $item --version=$item_version_latest $_BUMP_OPTIONS..."
brew bump-formula-pr "$item" --version="$item_version_latest" $_BUMP_OPTIONS
# echo -e "\033[0;33m* TDOO: brew bump-formula-pr $item --version=$item_version_latest $_BUMP_OPTIONS\033[0m"
fi

echo "> Done for $item"
Expand Down
69 changes: 69 additions & 0 deletions .github/actions/bump-formulae/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

set -e

# ========================
# bump
echo "> Running brew bump dry-run..."

items=$(brew livecheck --tap brewforge/chinese --extract-plist --full-name --json || echo "[]")

for item in $(echo "$items" | jq -r '.[] | .formula'); do
if [ "$item" == "null" ]; then
continue
fi

echo "---" # newline

item_obj=$(echo "$items" | jq --arg item "$item" '.[] | select(.formula == $item)')

is_formula=$(echo "$item_obj" | jq -r '.formula')

item_status=$(echo "$item_obj" | jq -r '.status')
item_version_current=$(echo "$item_obj" | jq -r '.version.current')
item_version_latest=$(echo "$item_obj" | jq -r '.version.latest')
item_outdated=$(echo "$item_obj" | jq -r '.version.outdated')
item_newer=$(echo "$item_obj" | jq -r '.version.newer_than_upstream')

if [ "$item_status" == "skipped" ]; then
# skipped.
echo -e "$item: \033[0;31m$(echo "$item_obj" | jq -r '.messages[0]')\033[0m"
continue
elif [ "$item_outdated" == "false" ]; then
# up-to-date.
echo -e "$item: \033[0;32mUp-to-date\033[0m"
continue
elif [ "$item_newer" == "true" ]; then
# newer than upstream.
echo -e "$item: \033[0;33mNewer than upstream\033[0m"
continue
fi

# bump.
echo "> Bumping $item from $item_version_current to $item_version_latest..."

if [ "$item_version_latest" == "null" ]; then
echo "$item_obj"

if [ -n "$is_formula" ]; then
cat "$(brew edit "$item" --print-path)"
fi

echo -e "\033[0;31m> Error: version.latest is null\033[0m"
continue
fi

# ========================
# dry-run
_BUMP_OPTIONS="--verbose"

if [ "$is_formula" != "null" ]; then
# is_formula.

echo "* Running brew bump-formula-pr $item --version=$item_version_latest $_BUMP_OPTIONS..."
brew bump-formula-pr "$item" --version="$item_version_latest" $_BUMP_OPTIONS
# echo -e "\033[0;33m* TDOO: brew bump-formula-pr $item --version=$item_version_latest $_BUMP_OPTIONS\033[0m"
fi

echo "> Done for $item"
done
83 changes: 83 additions & 0 deletions .github/workflows/bump-intel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: bump-intel

on:
# pull_request:
# branches: [main]
# push:
# branches: [fix-*]
schedule:
# Every 12 hours
# - cron: "20 */12 * * *"
# Every day at 6am
- cron: "0 8 * * *"
# allow run manually
workflow_dispatch:

permissions: write-all

jobs:
bump-formulae:
name: Bump formulae
if: github.repository == 'brewforge/homebrew-chinese'
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-13]

steps:
- uses: actions/checkout@v3

- name: Homebrew env
uses: ./.github/actions/homebrew-env

- name: Brew Tap
uses: ./.github/actions/brew-tap

- name: Git Cred
uses: ./.github/actions/git-cred
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

- name: Bump
env:
HOMEBREW_DEVELOPER: "1"
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
shell: bash -ieo pipefail {0}
run: |
rsync -lrv --exclude=.git "$(pwd)" "$(brew --repository brewforge/chinese)"
cd "$(brew --repository brewforge/chinese)"
./.github/actions/bump-formulae/script.sh
bump-formulae-linux:
name: Bump formulae (Linuxbrew)
if: github.repository == 'brewforge/homebrew-chinese'
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-22.04]

steps:
- uses: actions/checkout@v3

- name: Linuxbrew env
uses: ./.github/actions/linuxbrew-env

- name: Brew Tap
uses: ./.github/actions/brew-tap

- name: Git Cred
uses: ./.github/actions/git-cred
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

- name: Bump
env:
HOMEBREW_DEVELOPER: "1"
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
shell: bash -ieo pipefail {0}
run: |
rsync -lrv --exclude=.git "$(pwd)" "$(brew --repository brewforge/chinese)"
cd "$(brew --repository brewforge/chinese)"
./.github/actions/bump-formulae/script.sh
116 changes: 116 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: bump

on:
# pull_request:
# branches: [main]
# push:
# branches: [fix-*]
schedule:
# Every 12 hours
# - cron: "20 */12 * * *"
# Every day at 6am
- cron: "0 6 * * *"
# allow run manually
workflow_dispatch:

permissions: write-all

jobs:
bump-casks:
name: Bump casks
if: github.repository == 'brewforge/homebrew-chinese'
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest]

steps:
- uses: actions/checkout@v3

- name: Homebrew env
uses: ./.github/actions/homebrew-env

- name: Brew Tap
uses: ./.github/actions/brew-tap

- name: Git Cred
uses: ./.github/actions/git-cred
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

- name: Bump
env:
HOMEBREW_DEVELOPER: "1"
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
shell: bash -ieo pipefail {0}
run: |
rsync -lrv --exclude=.git "$(pwd)" "$(brew --repository brewforge/chinese)"
cd "$(brew --repository brewforge/chinese)"
./.github/actions/bump-casks/script.sh
bump-formulae:
name: Bump formulae
if: github.repository == 'brewforge/homebrew-chinese'
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest]

steps:
- uses: actions/checkout@v3

- name: Homebrew env
uses: ./.github/actions/homebrew-env

- name: Brew Tap
uses: ./.github/actions/brew-tap

- name: Git Cred
uses: ./.github/actions/git-cred
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

- name: Bump
env:
HOMEBREW_DEVELOPER: "1"
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
shell: bash -ieo pipefail {0}
run: |
rsync -lrv --exclude=.git "$(pwd)" "$(brew --repository brewforge/chinese)"
cd "$(brew --repository brewforge/chinese)"
./.github/actions/bump-formulae/script.sh
bump-formulae-linux:
name: Bump formulae (Linuxbrew)
if: github.repository == 'brewforge/homebrew-chinese'
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3

- name: Linuxbrew env
uses: ./.github/actions/linuxbrew-env

- name: Brew Tap
uses: ./.github/actions/brew-tap

- name: Git Cred
uses: ./.github/actions/git-cred
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

- name: Bump
env:
HOMEBREW_DEVELOPER: "1"
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
shell: bash -ieo pipefail {0}
run: |
rsync -lrv --exclude=.git "$(pwd)" "$(brew --repository brewforge/chinese)"
cd "$(brew --repository brewforge/chinese)"
./.github/actions/bump-formulae/script.sh
75 changes: 0 additions & 75 deletions .github/workflows/schedule.yml

This file was deleted.

Loading

0 comments on commit ffa5762

Please sign in to comment.