Skip to content

Commit 1688fda

Browse files
committed
init
0 parents  commit 1688fda

17 files changed

+3664
-0
lines changed

.editorconfig

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
indent_size = 4
15+
indent_style = space
16+
trim_trailing_whitespace = false
17+
18+
[*.yml]
19+
indent_size = 2
20+
indent_style = space
21+
22+
[*.rb]
23+
indent_size = 2
24+
indent_style = space

.github/scripts/build.sh

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
tick=""
2+
3+
step_log() {
4+
message=$1
5+
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
6+
}
7+
8+
add_log() {
9+
mark=$1
10+
subject=$2
11+
message=$3
12+
if [ "$mark" = "$tick" ]; then
13+
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
14+
else
15+
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
16+
fi
17+
}
18+
19+
step_log "Housekeeping"
20+
unset HOMEBREW_DISABLE_LOAD_FORMULA
21+
brew update-reset "$(brew --repository)" >/dev/null 2>&1
22+
add_log "$tick" "Housekeeping" "Done"
23+
24+
if [ "$PHP_VERSION" != "[email protected]" ]; then
25+
step_log "Sourcing latest formulae"
26+
sh .github/scripts/update.sh new "$PHP_VERSION" >/dev/null 2>&1
27+
add_log "$tick" "Formulae" "Sourced"
28+
fi
29+
30+
step_log "Checking label"
31+
package="${PHP_VERSION//@/:}"
32+
new_version=$(brew info Formula/"$PHP_VERSION".rb | grep "$PHP_VERSION" | head -n 1 | cut -d' ' -f3)
33+
existing_version=$(curl --user "$HOMEBREW_BINTRAY_USER":"$HOMEBREW_BINTRAY_KEY" -s https://api.bintray.com/packages/"$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO"/"$package" | sed -e 's/^.*"latest_version":"\([^"]*\)".*$/\1/')
34+
echo "existing label: $existing_version"
35+
echo "new label: $new_version"
36+
if [ "$new_version" != "$existing_version" ] || [[ "$existing_version" =~ ^8.* ]]; then
37+
add_log "$tick" "PHP $new_version" "New label found or nightly build"
38+
39+
step_log "Adding tap $GITHUB_REPOSITORY"
40+
mkdir -p "$(brew --prefix)/Homebrew/Library/Taps/$HOMEBREW_BINTRAY_USER"
41+
ln -s "$PWD" "$(brew --prefix)/Homebrew/Library/Taps/$GITHUB_REPOSITORY"
42+
add_log "$tick" "$GITHUB_REPOSITORY" "Tap added to brewery"
43+
44+
step_log "Filling the Bottle"
45+
brew test-bot "$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO"/"$PHP_VERSION" --root-url=https://dl.bintray.com/"$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO" --skip-setup --skip-homebrew
46+
LC_ALL=C find . -type f -name '*.json' -exec sed -i '' s~homebrew/bottles-php~"$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO"~ {} +
47+
LC_ALL=C find . -type f -name '*.json' -exec sed -i '' s~bottles-php~php~ {} +
48+
LC_ALL=C find . -type f -name '*.json' -exec sed -i '' s~bottles~php~ {} +
49+
cat *.json
50+
add_log "$tick" "PHP $new_version" "Bottle filled"
51+
52+
step_log "Adding label"
53+
curl \
54+
--user "$HOMEBREW_BINTRAY_USER":"$HOMEBREW_BINTRAY_KEY" \
55+
--header "Content-Type: application/json" \
56+
--data " \
57+
{\"name\": \"$package\", \
58+
\"vcs_url\": \"$GITHUB_REPOSITORY\", \
59+
\"licenses\": [\"MIT\"], \
60+
\"public_download_numbers\": true, \
61+
\"public_stats\": true \
62+
}" \
63+
https://api.bintray.com/packages/"$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO" >/dev/null 2>&1 || true
64+
add_log "$tick" "$package" "Bottle labeled"
65+
66+
step_log "Stocking the new Bottle"
67+
git stash
68+
git pull -f https://"$HOMEBREW_BINTRAY_USER":"$GITHUB_TOKEN"@github.com/"$GITHUB_REPOSITORY".git HEAD:master
69+
git stash apply
70+
curl --user "$HOMEBREW_BINTRAY_USER":"$HOMEBREW_BINTRAY_KEY" -X DELETE https://api.bintray.com/packages/"$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO"/"$package"/versions/"$new_version" >/dev/null 2>&1 || true
71+
brew test-bot --ci-upload --tap="$GITHUB_REPOSITORY" --root-url=https://dl.bintray.com/"$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO" --bintray-org="$HOMEBREW_BINTRAY_USER"
72+
curl --user "$HOMEBREW_BINTRAY_USER":"$HOMEBREW_BINTRAY_KEY" -X POST https://api.bintray.com/content/"$HOMEBREW_BINTRAY_USER"/"$HOMEBREW_BINTRAY_REPO"/"$package"/"$new_version"/publish >/dev/null 2>&1 || true
73+
add_log "$tick" "PHP $new_version" "Bottle added to stock"
74+
75+
step_log "Updating inventory"
76+
git push -f https://"$HOMEBREW_BINTRAY_USER":"$GITHUB_TOKEN"@github.com/"$GITHUB_REPOSITORY".git HEAD:master --follow-tags
77+
add_log "$tick" "Inventory" "updated"
78+
else
79+
add_log "$tick" "PHP $new_version" "Bottle exists"
80+
fi

.github/scripts/update.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
brew_old_url_prefix='https://raw.githubusercontent.com/eXolnet/homebrew-deprecated/master/Formula'
2+
brew_new_url_prefix='https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula'
3+
4+
mkdir -p Formula
5+
if [ $1 = 'old' ]; then
6+
curl -o Formula/"$2".rb "$brew_old_url_prefix"/"$2".rb
7+
fi
8+
if [ $1 = 'new' ]; then
9+
curl -o Formula/"$2".rb "$brew_new_url_prefix"/"$2".rb
10+
fi

.github/workflows/update.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: 'Update and Build Formulae'
2+
on:
3+
repository_dispatch:
4+
push:
5+
paths:
6+
- '**.rb'
7+
- '**.yml'
8+
- '**.sh'
9+
schedule:
10+
- cron: '0 0 * * *'
11+
jobs:
12+
supported:
13+
runs-on: macOS-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php-version:
18+
- 'php'
19+
20+
21+
22+
steps:
23+
- uses: actions/checkout@v1
24+
- name: build
25+
run: sh ./.github/scripts/build.sh
26+
env:
27+
GIT_URL: https://github.com/shivammathur/homebrew-php.git
28+
GITHUB_REPOSITORY: ${{ github.repository }}
29+
GITHUB_NAME: "Shivam Mathur"
30+
HOMEBREW_BINTRAY_USER: shivammathur
31+
HOMEBREW_BINTRAY_REPO: php
32+
HOMEBREW_BINTRAY_EMAIL: ${{ secrets.email }}
33+
HOMEBREW_BINTRAY_KEY: ${{ secrets.bintray_key }}
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
PHP_VERSION: ${{ matrix.php-version }}
36+
GITHUB_ACTIONS: true
37+
continue-on-error: true
38+
deprecated:
39+
needs: supported
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
php-version:
45+
46+
47+
steps:
48+
- uses: actions/checkout@v1
49+
- name: Fetch
50+
run: sh .github/scripts/update.sh old ${{ matrix.php-version }}
51+
- name: Commit files
52+
run: |
53+
git config --local user.email "${{ secrets.email }}"
54+
git config --local user.name "Shivam Mathur"
55+
if [[ `git status --porcelain` ]]; then
56+
git stash
57+
git pull -f https://"$HOMEBREW_BINTRAY_USER":"$GITHUB_TOKEN"@github.com/"$GITHUB_REPOSITORY".git HEAD:master
58+
git stash apply
59+
git add ./Formula/${{ matrix.php-version }}.rb
60+
git commit -m "Fetch latest Formula for ${{ matrix.php-version }}"
61+
git push -f https://"$HOMEBREW_BINTRAY_USER":"$GITHUB_TOKEN"@github.com/"$GITHUB_REPOSITORY".git HEAD:master --follow-tags
62+
fi
63+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea

Aliases/[email protected]

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../Formula/php.rb

0 commit comments

Comments
 (0)