-
Notifications
You must be signed in to change notification settings - Fork 120
78 lines (76 loc) · 3.67 KB
/
upload-bottles.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Upload bottles
on:
push:
branches: [develop]
jobs:
upload-bottles:
runs-on: ubuntu-22.04
env:
HOMEBREW_FORCE_HOMEBREW_ON_LINUX: 1
HOMEBREW_GITHUB_PACKAGES_USER: LinuxbrewTestBot
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.HOMEBREW_GITHUB_PACKAGES_TOKEN}}
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- uses: actions/checkout@master
with:
fetch-depth: 100
- name: Update Homebrew
run: |
echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew update
- name: Upload bottles
shell: bash
env:
COMMIT_MESSAGE: ${{github.event.head_commit.message}}
run: |
#!/bin/bash
set -eu
echo sha1='${{github.event.head_commit.id}}'
echo "$COMMIT_MESSAGE"
# pr="$(echo "$COMMIT_MESSAGE" | sed 's/^.*#\([0-9]*\).*/\1/;q')"
pr="${COMMIT_MESSAGE##*#}"
pr="${pr%%[^0-9]*}"
mkdir -p "$(dirname "$(brew --repo ${{github.repository}})")"
cp -a "$GITHUB_WORKSPACE" "$(brew --repo ${{github.repository}})"
rm -rf -- .git *
git -C "$(brew --repo ${{github.repository}})" fetch origin "pull/$pr/head:pr-head"
sha1="$(git -C "$(brew --repo ${{github.repository}})" rev-parse pr-head)"
echo pr="$pr" sha1="$sha1"
if [[ -n "$(curl -fs -H 'Accept: application/vnd.github.antiope-preview+json' "https://api.github.com/repos/${{github.repository}}/pulls/$pr" \
| jq '.labels[] | select(.name == "ci-skip-upload")')" ]]; then
echo Skipping upload...
else
run_id="$(curl -fs -H 'Accept: application/vnd.github.antiope-preview+json' https://api.github.com/repos/${{github.repository}}/actions/workflows/build-bottles.yml/runs \
| jq ".workflow_runs[] | select(.head_sha == \"$sha1\").id")"
# artifacts[-1] is "all-bottles"
artifact_id="$(curl -fs -H 'Accept: application/vnd.github.antiope-preview+json' "https://api.github.com/repos/${{github.repository}}/actions/runs/$run_id/artifacts" \
| jq '.artifacts[-1].id')"
echo run_id="$run_id" artifact_id="$artifact_id"
curl -fL -o bottles.zip "https://${{secrets.HOMEBREW_GITHUB_API_TOKEN}}@api.github.com/repos/${{github.repository}}/actions/artifacts/$artifact_id/zip"
file bottles.zip
unzip bottles.zip
git -C "$(brew --repo ${{github.repository}})" status
git config --global user.name "Brewsci"
git config --global user.email "[email protected]"
which -a skopeo
skopeo --version
brew pr-upload --root-url=https://ghcr.io/v2/brewsci/bio
fi
cd "$(brew --repo ${{github.repository}})"
git branch -f "pr$pr"
git fetch origin master
git checkout master
git reset --hard origin/master
git merge -m "Merge pull request #$pr" "pr$pr"
git status
if ! git push "https://LinuxbrewTestBot:${{secrets.HOMEBREW_GITHUB_API_TOKEN}}@github.com/${{github.repository}}" master:develop master; then
git push --force origin "pr$pr"
mkdir ~/bin
curl -fsL https://github.com/github/hub/releases/download/v2.14.1/hub-linux-amd64-2.14.1.tgz \
| tar xzO hub-linux-amd64-2.14.1/bin/hub >~/bin/hub
chmod +x ~/bin/hub
git reset --hard origin/master
GITHUB_TOKEN='${{secrets.HOMEBREW_GITHUB_API_TOKEN}}' ~/bin/hub pull-request -l bottles -b master -h "pr$pr" -m "Bottles for PR $pr" --no-edit
fi