forked from actions/runner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitrise.yml
More file actions
226 lines (180 loc) · 7.58 KB
/
bitrise.yml
File metadata and controls
226 lines (180 loc) · 7.58 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
---
format_version: '25'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
pipelines:
release:
triggers:
push:
- branch: releases/v*-bitrise
stages:
- build: {}
- upload-and-deploy: {}
stages:
build:
workflows:
- build-linux: {}
- build-macos: {}
upload-and-deploy:
workflows:
- upload-release-assets: {}
workflows:
build-linux:
steps:
- git-clone@8: {}
- script@1:
title: Build & Package runner (linux-x64)
inputs:
- content: |
#!/usr/bin/env bash
set -euo pipefail
cd "${BITRISE_SOURCE_DIR}/src"
./dev.sh layout Release linux-x64
./dev.sh package Release linux-x64
RUNNER_VERSION=$(cat runnerversion)
PACKAGE_PATH="${BITRISE_SOURCE_DIR}/_package/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz"
echo "Built package: ${PACKAGE_PATH}"
ls -lh "${PACKAGE_PATH}"
envman add --key LINUX_PACKAGE_PATH --value "${PACKAGE_PATH}"
- deploy-to-bitrise-io@2:
inputs:
- pipeline_intermediate_files: "$LINUX_PACKAGE_PATH:BITRISE_LINUX_PACKAGE_PATH"
build-macos:
steps:
- git-clone@8: {}
- script@1:
title: Build & Package runner (osx-arm64)
inputs:
- content: |
#!/usr/bin/env bash
set -euo pipefail
cd "${BITRISE_SOURCE_DIR}/src"
./dev.sh layout Release osx-arm64
./dev.sh package Release osx-arm64
RUNNER_VERSION=$(cat runnerversion)
PACKAGE_PATH="${BITRISE_SOURCE_DIR}/_package/actions-runner-osx-arm64-${RUNNER_VERSION}.tar.gz"
echo "Built package: ${PACKAGE_PATH}"
ls -lh "${PACKAGE_PATH}"
envman add --key MACOS_PACKAGE_PATH --value "${PACKAGE_PATH}"
- deploy-to-bitrise-io@2:
inputs:
- pipeline_intermediate_files: "$MACOS_PACKAGE_PATH:BITRISE_MACOS_PACKAGE_PATH"
meta:
bitrise.io:
stack: osx-xcode-26.2.x
machine_type_id: g2.mac.large
upload-release-assets:
steps:
- git-clone@8: {}
- pull-intermediate-files@1:
inputs:
- artifact_sources: ".*"
- script@1:
title: Prepare release assets
inputs:
- content: |
#!/usr/bin/env bash
set -euo pipefail
RELEASE_ASSETS_DIR="${BITRISE_SOURCE_DIR}/release-assets"
mkdir -p "${RELEASE_ASSETS_DIR}"
cp "${BITRISE_LINUX_PACKAGE_PATH}" "${RELEASE_ASSETS_DIR}/"
cp "${BITRISE_MACOS_PACKAGE_PATH}" "${RELEASE_ASSETS_DIR}/"
echo "Release assets:"
ls -lh "${RELEASE_ASSETS_DIR}"
RELEASE_TAG="v$(cat "${BITRISE_SOURCE_DIR}/src/runnerversion")"
envman add --key RELEASE_ASSETS_DIR --value "${RELEASE_ASSETS_DIR}"
envman add --key RELEASE_TAG --value "${RELEASE_TAG}"
- script@1:
title: Upload assets to R2
inputs:
- content: |
#!/usr/bin/env bash
set -euo pipefail
echo "--- Configuring AWS CLI for R2"
export AWS_ACCESS_KEY_ID="${R2_ACCESS_KEY_ID}"
export AWS_SECRET_ACCESS_KEY="${R2_SECRET_ACCESS_KEY}"
export AWS_DEFAULT_REGION="auto"
echo "--- Uploading assets to s3://${R2_BUCKET}/"
for file in "${RELEASE_ASSETS_DIR}"/*; do
FILENAME=$(basename "${file}")
echo "Uploading: ${FILENAME}"
aws s3 cp "${file}" "s3://${R2_BUCKET}/${FILENAME}" \
--endpoint-url "${R2_ENDPOINT}"
done
echo "--- Upload complete. Verifying:"
aws s3 ls "s3://${R2_BUCKET}/" \
--endpoint-url "${R2_ENDPOINT}"
- script@1:
title: Upload assets to GCS
inputs:
- content: |
#!/usr/bin/env bash
set -euo pipefail
echo "--- Authenticating with GCP"
echo "${GCS_SERVICE_ACCOUNT_JSON}" | base64 -d > /tmp/gcs-key.json
gcloud auth activate-service-account --key-file=/tmp/gcs-key.json
echo "--- Uploading assets to gs://${GCS_BUCKET}/"
gsutil -m cp "${RELEASE_ASSETS_DIR}"/* "gs://${GCS_BUCKET}/"
echo "--- Upload complete. Verifying:"
gsutil ls -l "gs://${GCS_BUCKET}/"
rm -f /tmp/gcs-key.json
- script@1:
title: Update runner version in instance-management-deployments
inputs:
- content: |
#!/usr/bin/env bash
set -euo pipefail
VERSION="${RELEASE_TAG}"
VERSION_NUM="${VERSION#v}"
VERSIONS_REL_PATH="instance-manager-pool-controller/files/github_runner_versions.yaml"
REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/bitrise-io/instance-management-deployments.git"
echo "--- Computing SHA256 hashes for version ${VERSION}"
OSX_ARM64_HASH=$(sha256sum "${RELEASE_ASSETS_DIR}/actions-runner-osx-arm64-${VERSION_NUM}.tar.gz" | awk '{print $1}')
LINUX_X64_HASH=$(sha256sum "${RELEASE_ASSETS_DIR}/actions-runner-linux-x64-${VERSION_NUM}.tar.gz" | awk '{print $1}')
echo "osx-arm64: ${OSX_ARM64_HASH}"
echo "linux-x64: ${LINUX_X64_HASH}"
update_versions_file() {
local file="$1"
yq -i ".versions.\"${VERSION}\".\"osx-arm64\" = \"${OSX_ARM64_HASH}\"" "${file}"
yq -i ".versions.\"${VERSION}\".\"linux-x64\" = \"${LINUX_X64_HASH}\"" "${file}"
yq -i ".default_version = \"${VERSION}\"" "${file}"
}
echo "--- Cloning instance-management-deployments"
REPO_DIR=$(mktemp -d)
trap 'rm -rf "${REPO_DIR}"' EXIT
git clone --no-single-branch "${REPO_URL}" "${REPO_DIR}"
cd "${REPO_DIR}"
git config user.name "bitrise-infrabot"
git config user.email "bitrise-infrabot@bitrise.io"
echo "--- Updating staging branch"
git checkout staging
update_versions_file "${VERSIONS_REL_PATH}"
echo "--- Updated file content:"
cat "${VERSIONS_REL_PATH}"
git add "${VERSIONS_REL_PATH}"
git commit -m "Add GitHub runner ${VERSION}"
git push origin staging
echo "--- Creating PR for production"
PROD_BRANCH="github-runner-${VERSION}"
git checkout -b "${PROD_BRANCH}" origin/production
update_versions_file "${VERSIONS_REL_PATH}"
git add "${VERSIONS_REL_PATH}"
git commit -m "Add GitHub runner ${VERSION}"
git push origin "${PROD_BRANCH}"
PR_RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/bitrise-io/instance-management-deployments/pulls" \
-d "{\"title\":\"Update GitHub runner to ${VERSION}\",\"head\":\"${PROD_BRANCH}\",\"base\":\"production\",\"body\":\"Automated PR to update GitHub runner to ${VERSION}.\\n\\nChanges:\\n- Added version hashes for ${VERSION}\\n- Updated default_version to ${VERSION}\"}")
PR_URL=$(echo "${PR_RESPONSE}" | jq -r '.html_url // empty')
if [ -n "${PR_URL}" ]; then
echo "PR created: ${PR_URL}"
else
echo "Failed to create PR. Response:"
echo "${PR_RESPONSE}" | jq .
exit 1
fi
meta:
bitrise.io:
stack: ubuntu-noble-24.04-bitrise-2025-base
machine_type_id: g2.linux.x-large