Skip to content

Commit 58c09d1

Browse files
committed
feat: bump casks
1 parent 595a4fd commit 58c09d1

5 files changed

Lines changed: 200 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Brew Tap
2+
description: Homebrew Tap
3+
4+
runs:
5+
using: "composite"
6+
7+
steps:
8+
- name: Add Tap
9+
shell: bash -ieo pipefail {0}
10+
run: |
11+
brew tap KotaHv/homebrew-cask
12+
13+
- name: Install Homebrew's dependencies
14+
shell: bash -ieo pipefail {0}
15+
run: |
16+
brew install ripgrep sd gcc coreutils jq
17+
brew unlink coreutils && brew link coreutils
18+
brew install-bundler-gems --groups "audit,style"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# ========================
6+
# bump
7+
echo "> Running brew bump dry-run..."
8+
9+
items=$(brew livecheck --tap KotaHv/homebrew-cask --extract-plist --full-name --json || echo "[]")
10+
11+
for item in $(echo "$items" | jq -r '.[] | .cask'); do
12+
if [ "$item" == "null" ]; then
13+
continue
14+
fi
15+
16+
echo "---" # newline
17+
18+
item_obj=$(echo "$items" | jq --arg item "$item" '.[] | select(.cask == $item)')
19+
20+
is_cask=$(echo "$item_obj" | jq -r '.cask')
21+
22+
item_status=$(echo "$item_obj" | jq -r '.status')
23+
item_version_current=$(echo "$item_obj" | jq -r '.version.current')
24+
item_version_latest=$(echo "$item_obj" | jq -r '.version.latest')
25+
item_outdated=$(echo "$item_obj" | jq -r '.version.outdated')
26+
item_newer=$(echo "$item_obj" | jq -r '.version.newer_than_upstream')
27+
28+
if [ "$item_status" == "skipped" ]; then
29+
# skipped.
30+
echo -e "$item: \033[0;31m$(echo "$item_obj" | jq -r '.messages[0]')\033[0m"
31+
continue
32+
elif [ "$item_outdated" == "false" ]; then
33+
# up-to-date.
34+
echo -e "$item: \033[0;32mUp-to-date\033[0m"
35+
continue
36+
elif [ "$item_newer" == "true" ]; then
37+
# newer than upstream.
38+
echo -e "$item: \033[0;33mNewer than upstream\033[0m"
39+
continue
40+
fi
41+
42+
# bump
43+
echo "> Bumping $item from $item_version_current to $item_version_latest..."
44+
45+
if [ "$item_version_latest" == "null" ]; then
46+
echo "$item_obj"
47+
48+
if [ -n "$is_cask" ]; then
49+
cat "$(brew edit --cask "$item" --print-path)"
50+
fi
51+
52+
echo -e "\033[0;31m> Error: version.latest is null\033[0m"
53+
continue
54+
fi
55+
56+
# ========================
57+
# dry-run
58+
_BUMP_OPTIONS="--verbose"
59+
60+
if [ "$is_cask" != "null" ]; then
61+
# is_cask.
62+
63+
echo "* Running brew bump-cask-pr $item --version=$item_version_latest $_BUMP_OPTIONS..."
64+
brew bump-cask-pr "$item" --version="$item_version_latest" $_BUMP_OPTIONS
65+
# echo "* TDOO: brew bump-cask-pr $item --version=$item_version_latest $_BUMP_OPTIONS"
66+
fi
67+
68+
echo "> Done for $item"
69+
done
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Git Credentials
2+
description: Git Credentials
3+
4+
inputs:
5+
HOMEBREW_GITHUB_API_TOKEN:
6+
description: "Homebrew GitHub API Token"
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
12+
steps:
13+
- uses: oleksiyrudenko/gha-git-credentials@v2-latest
14+
with:
15+
global: true
16+
name: "KotaBot"
17+
email: "noreply@github.com"
18+
token: "${{ inputs.HOMEBREW_GITHUB_API_TOKEN }}"
19+
20+
- name: show git context
21+
shell: bash -ieo pipefail {0}
22+
run: |
23+
cat $HOME/.gitconfig
24+
cat $GITHUB_ENV

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/.github/workflows"
5+
schedule:
6+
interval: weekly

.github/workflows/schedule.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: schedule
2+
3+
on:
4+
# pull_request:
5+
# branches: [main]
6+
# push:
7+
# branches: [fix-*]
8+
schedule:
9+
# Every 12 hours
10+
# - cron: "20 */12 * * *"
11+
# Every day at 6am
12+
- cron: "0 6 * * *"
13+
# allow run manually
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.head_ref || github.ref_name }}
18+
19+
permissions: write-all
20+
21+
env:
22+
HOMEBREW_DEVELOPER: 1
23+
HOMEBREW_GITHUB_ACTIONS: 1
24+
HOMEBREW_NO_AUTO_UPDATE: 1
25+
HOMEBREW_NO_INSTALL_FROM_API: 1
26+
HOMEBREW_RELOCATABLE_INSTALL_NAMES: 1
27+
28+
jobs:
29+
tap-syntax:
30+
if: "!contains(github.event.head_commit.message, 'skip-build')"
31+
runs-on: ubuntu-22.04
32+
container:
33+
image: ghcr.io/homebrew/ubuntu22.04:master
34+
env:
35+
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
36+
steps:
37+
- name: Set up Homebrew
38+
id: set-up-homebrew
39+
uses: Homebrew/actions/setup-homebrew@master
40+
with:
41+
core: false
42+
cask: false
43+
test-bot: true
44+
45+
- run: brew test-bot --only-tap-syntax
46+
47+
bump-casks:
48+
name: Bump casks
49+
if: github.repository == 'KotaHv/homebrew-cask'
50+
runs-on: ${{ matrix.os }}
51+
52+
strategy:
53+
matrix:
54+
os: [macos-latest]
55+
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- name: Set up Homebrew
60+
id: set-up-homebrew
61+
uses: Homebrew/actions/setup-homebrew@master
62+
with:
63+
core: false
64+
cask: false
65+
test-bot: false
66+
67+
- name: Brew Tap
68+
uses: ./.github/actions/brew-tap
69+
70+
- name: Git Cred
71+
uses: ./.github/actions/git-cred
72+
with:
73+
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
74+
75+
- name: Bump
76+
env:
77+
HOMEBREW_DEVELOPER: "1"
78+
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
79+
shell: bash -ieo pipefail {0}
80+
run: |
81+
rsync -lrv --exclude=.git "$(pwd)" "$(brew --repository KotaHv/homebrew-cask)"
82+
cd "$(brew --repository KotaHv/homebrew-cask)"
83+
./.github/actions/bump-casks/script.sh

0 commit comments

Comments
 (0)