-
Notifications
You must be signed in to change notification settings - Fork 7
153 lines (136 loc) · 5.35 KB
/
Copy pathjitpack.yml
File metadata and controls
153 lines (136 loc) · 5.35 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: JitPack
# Required permissions for label management
permissions:
contents: read
pull-requests: write
on:
release:
types: [ published ]
push:
branches:
- master
- rel/*
- feat/*
pull_request:
types: [ labeled ]
workflow_dispatch:
jobs:
build:
name: Build Artifacts
runs-on: ubuntu-22.04
# Run on releases, pushes, workflow_dispatch, or PRs with the jitpack:build label
if: |
github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'jitpack:build')
steps:
- name: Checkout repository
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
- name: Determine Version Info
id: version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
echo "version_type=release" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" == "pull_request" ]; then
echo "version=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
echo "version_type=pull_request" >> $GITHUB_OUTPUT
else
echo "version=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "version_type=commit" >> $GITHUB_OUTPUT
fi
- name: Build Artifacts on JitPack
run: |
# Poll JitPack until it builds artifacts for this commit/release
url="https://jitpack.io/com/github/klaviyo/klaviyo-android-sdk/${{ steps.version.outputs.version }}/build.log"
output=""
max_runtime=900 # 15 minutes in seconds
interval=30 # Check every 30 seconds
elapsed_time=0
echo "Waiting for JitPack to build artifacts at $url"
echo
while [ $elapsed_time -lt $max_runtime ]; do
output=$(curl --silent "$url")
if [[ $output == *"BUILD FAILED"* ]]; then
echo "Build Failed!"
echo
echo "$output"
exit 1
elif [[ $output == *"BUILD SUCCESSFUL"* ]]; then
echo "Build Complete!"
echo
echo "$output"
# Verify all expected artifacts were published
expected_artifacts=("analytics" "core" "forms" "forms-core" "location" "location-core" "push-fcm")
missing=()
for artifact in "${expected_artifacts[@]}"; do
if ! echo "$output" | grep -q "Found artifact: com.klaviyo:${artifact}:"; then
missing+=("$artifact")
fi
done
if [ ${#missing[@]} -ne 0 ]; then
echo
echo "ERROR: Missing artifacts: ${missing[*]}"
exit 1
fi
echo
echo "Verified: All expected artifacts were published (${expected_artifacts[*]})"
exit 0
else
echo "At $elapsed_time, build appears to be in progress..."
echo
fi
sleep $interval
elapsed_time=$((elapsed_time + interval))
done
echo "Build Timeout, last status:"
echo "$url"
echo
echo "$output"
exit 2
- name: Send Slack notification on success
if: success()
uses: slackapi/slack-github-action@v2.1.1
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: "✅ JitPack Build Successful"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "✅ JitPack Artifacts Available for `${{ github.event.pull_request.head.ref || github.ref_name }}` `${{ steps.version.outputs.version }}`\n"
- type: "section"
text:
type: "mrkdwn"
text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
- name: Send Slack notification on failure
if: failure()
uses: slackapi/slack-github-action@v2.1.1
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: "🚨 JitPack Build Failed"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "🚨 JitPack Build Failed for `${{ github.event.pull_request.head.ref || github.ref_name }}` `${{ steps.version.outputs.version }}`\n"
- type: "section"
text:
type: "mrkdwn"
text: "*Workflow Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
- name: Update PR labels on success
if: success() && github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "jitpack:build"
- name: Update PR labels on failure
if: failure() && github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "jitpack:build"