Skip to content

Commit 39c4b99

Browse files
author
bitrise-bot
committed
Bitrise cache integration (patched from v2.329.0)
1 parent c76c599 commit 39c4b99

5 files changed

Lines changed: 198 additions & 186 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ name: Runner CD
33
on:
44
workflow_dispatch:
55
push:
6-
paths:
7-
- releaseVersion
6+
branches:
7+
- releases/v*
88

99
jobs:
1010
check:
1111
if: startsWith(github.ref, 'refs/heads/releases/') || github.ref == 'refs/heads/main'
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v5
14+
- uses: actions/checkout@v6
1515

1616
# Make sure ./releaseVersion match ./src/runnerversion
1717
# Query GitHub release ensure version is not used
1818
- name: Check version
19-
uses: actions/github-script@v8.0.0
19+
uses: actions/github-script@v8
2020
with:
2121
github-token: ${{secrets.GITHUB_TOKEN}}
2222
script: |
@@ -46,47 +46,22 @@ jobs:
4646
needs: check
4747
outputs:
4848
linux-x64-sha: ${{ steps.sha.outputs.linux-x64-sha256 }}
49-
linux-arm64-sha: ${{ steps.sha.outputs.linux-arm64-sha256 }}
50-
linux-arm-sha: ${{ steps.sha.outputs.linux-arm-sha256 }}
51-
win-x64-sha: ${{ steps.sha.outputs.win-x64-sha256 }}
52-
win-arm64-sha: ${{ steps.sha.outputs.win-arm64-sha256 }}
53-
osx-x64-sha: ${{ steps.sha.outputs.osx-x64-sha256 }}
5449
osx-arm64-sha: ${{ steps.sha.outputs.osx-arm64-sha256 }}
5550
strategy:
5651
matrix:
57-
runtime: [ linux-x64, linux-arm64, linux-arm, win-x64, osx-x64, osx-arm64, win-arm64 ]
52+
runtime: [ linux-x64, osx-arm64 ]
5853
include:
5954
- runtime: linux-x64
6055
os: ubuntu-latest
6156
devScript: ./dev.sh
6257

63-
- runtime: linux-arm64
64-
os: ubuntu-latest
65-
devScript: ./dev.sh
66-
67-
- runtime: linux-arm
68-
os: ubuntu-latest
69-
devScript: ./dev.sh
70-
71-
- runtime: osx-x64
72-
os: macOS-latest
73-
devScript: ./dev.sh
74-
7558
- runtime: osx-arm64
7659
os: macOS-latest
7760
devScript: ./dev.sh
7861

79-
- runtime: win-x64
80-
os: windows-latest
81-
devScript: ./dev
82-
83-
- runtime: win-arm64
84-
os: windows-latest
85-
devScript: ./dev
86-
8762
runs-on: ${{ matrix.os }}
8863
steps:
89-
- uses: actions/checkout@v5
64+
- uses: actions/checkout@v6
9065

9166
# Build runner layout
9267
- name: Build & Layout Release
@@ -118,7 +93,7 @@ jobs:
11893
# Upload runner package tar.gz/zip as artifact.
11994
- name: Publish Artifact
12095
if: github.event_name != 'pull_request'
121-
uses: actions/upload-artifact@v4
96+
uses: actions/upload-artifact@v6
12297
with:
12398
name: runner-packages-${{ matrix.runtime }}
12499
path: |
@@ -129,76 +104,41 @@ jobs:
129104
runs-on: ubuntu-latest
130105
steps:
131106

132-
- uses: actions/checkout@v5
107+
- uses: actions/checkout@v6
133108

134109
# Download runner package tar.gz/zip produced by 'build' job
135-
- name: Download Artifact (win-x64)
136-
uses: actions/download-artifact@v5
137-
with:
138-
name: runner-packages-win-x64
139-
path: ./
140-
- name: Download Artifact (win-arm64)
141-
uses: actions/download-artifact@v5
142-
with:
143-
name: runner-packages-win-arm64
144-
path: ./
145-
- name: Download Artifact (osx-x64)
146-
uses: actions/download-artifact@v5
147-
with:
148-
name: runner-packages-osx-x64
149-
path: ./
150-
- name: Download Artifact (osx-arm64)
151-
uses: actions/download-artifact@v5
152-
with:
153-
name: runner-packages-osx-arm64
154-
path: ./
155110
- name: Download Artifact (linux-x64)
156-
uses: actions/download-artifact@v5
111+
uses: actions/download-artifact@v7
157112
with:
158113
name: runner-packages-linux-x64
159114
path: ./
160-
- name: Download Artifact (linux-arm)
161-
uses: actions/download-artifact@v5
162-
with:
163-
name: runner-packages-linux-arm
164-
path: ./
165-
- name: Download Artifact (linux-arm64)
166-
uses: actions/download-artifact@v5
115+
- name: Download Artifact (osx-arm64)
116+
uses: actions/download-artifact@v7
167117
with:
168-
name: runner-packages-linux-arm64
118+
name: runner-packages-osx-arm64
169119
path: ./
170120

171121
# Create ReleaseNote file
172122
- name: Create ReleaseNote
173123
id: releaseNote
174-
uses: actions/github-script@v8.0.0
124+
uses: actions/github-script@v8
175125
with:
176126
github-token: ${{secrets.GITHUB_TOKEN}}
177127
script: |
178128
const fs = require('fs');
179129
const runnerVersion = fs.readFileSync('${{ github.workspace }}/src/runnerversion', 'utf8').replace(/\n$/g, '')
180130
var releaseNote = fs.readFileSync('${{ github.workspace }}/releaseNote.md', 'utf8').replace(/<RUNNER_VERSION>/g, runnerVersion)
181-
releaseNote = releaseNote.replace(/<WIN_X64_SHA>/g, '${{needs.build.outputs.win-x64-sha}}')
182-
releaseNote = releaseNote.replace(/<WIN_ARM64_SHA>/g, '${{needs.build.outputs.win-arm64-sha}}')
183-
releaseNote = releaseNote.replace(/<OSX_X64_SHA>/g, '${{needs.build.outputs.osx-x64-sha}}')
184131
releaseNote = releaseNote.replace(/<OSX_ARM64_SHA>/g, '${{needs.build.outputs.osx-arm64-sha}}')
185132
releaseNote = releaseNote.replace(/<LINUX_X64_SHA>/g, '${{needs.build.outputs.linux-x64-sha}}')
186-
releaseNote = releaseNote.replace(/<LINUX_ARM_SHA>/g, '${{needs.build.outputs.linux-arm-sha}}')
187-
releaseNote = releaseNote.replace(/<LINUX_ARM64_SHA>/g, '${{needs.build.outputs.linux-arm64-sha}}')
188133
console.log(releaseNote)
189134
core.setOutput('version', runnerVersion);
190135
core.setOutput('note', releaseNote);
191136
192137
- name: Validate Packages HASH
193138
run: |
194139
ls -l
195-
echo "${{needs.build.outputs.win-x64-sha}} actions-runner-win-x64-${{ steps.releaseNote.outputs.version }}.zip" | shasum -a 256 -c
196-
echo "${{needs.build.outputs.win-arm64-sha}} actions-runner-win-arm64-${{ steps.releaseNote.outputs.version }}.zip" | shasum -a 256 -c
197-
echo "${{needs.build.outputs.osx-x64-sha}} actions-runner-osx-x64-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c
198-
echo "${{needs.build.outputs.osx-arm64-sha}} actions-runner-osx-arm64-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c
199140
echo "${{needs.build.outputs.linux-x64-sha}} actions-runner-linux-x64-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c
200-
echo "${{needs.build.outputs.linux-arm-sha}} actions-runner-linux-arm-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c
201-
echo "${{needs.build.outputs.linux-arm64-sha}} actions-runner-linux-arm64-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c
141+
echo "${{needs.build.outputs.osx-arm64-sha}} actions-runner-osx-arm64-${{ steps.releaseNote.outputs.version }}.tar.gz" | shasum -a 256 -c
202142
203143
# Create GitHub release
204144
- uses: actions/create-release@master
@@ -207,32 +147,12 @@ jobs:
207147
env:
208148
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
209149
with:
210-
tag_name: "v${{ steps.releaseNote.outputs.version }}"
150+
tag_name: "v${{ steps.releaseNote.outputs.version }}-bitrise"
211151
release_name: "v${{ steps.releaseNote.outputs.version }}"
212152
body: |
213153
${{ steps.releaseNote.outputs.note }}
214154
215155
# Upload release assets (full runner packages)
216-
- name: Upload Release Asset (win-x64)
217-
uses: actions/upload-release-asset@v1.0.2
218-
env:
219-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
220-
with:
221-
upload_url: ${{ steps.createRelease.outputs.upload_url }}
222-
asset_path: ${{ github.workspace }}/actions-runner-win-x64-${{ steps.releaseNote.outputs.version }}.zip
223-
asset_name: actions-runner-win-x64-${{ steps.releaseNote.outputs.version }}.zip
224-
asset_content_type: application/octet-stream
225-
226-
- name: Upload Release Asset (win-arm64)
227-
uses: actions/upload-release-asset@v1.0.2
228-
env:
229-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
230-
with:
231-
upload_url: ${{ steps.createRelease.outputs.upload_url }}
232-
asset_path: ${{ github.workspace }}/actions-runner-win-arm64-${{ steps.releaseNote.outputs.version }}.zip
233-
asset_name: actions-runner-win-arm64-${{ steps.releaseNote.outputs.version }}.zip
234-
asset_content_type: application/octet-stream
235-
236156
- name: Upload Release Asset (linux-x64)
237157
uses: actions/upload-release-asset@v1.0.2
238158
env:
@@ -243,16 +163,6 @@ jobs:
243163
asset_name: actions-runner-linux-x64-${{ steps.releaseNote.outputs.version }}.tar.gz
244164
asset_content_type: application/octet-stream
245165

246-
- name: Upload Release Asset (osx-x64)
247-
uses: actions/upload-release-asset@v1.0.2
248-
env:
249-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250-
with:
251-
upload_url: ${{ steps.createRelease.outputs.upload_url }}
252-
asset_path: ${{ github.workspace }}/actions-runner-osx-x64-${{ steps.releaseNote.outputs.version }}.tar.gz
253-
asset_name: actions-runner-osx-x64-${{ steps.releaseNote.outputs.version }}.tar.gz
254-
asset_content_type: application/octet-stream
255-
256166
- name: Upload Release Asset (osx-arm64)
257167
uses: actions/upload-release-asset@v1.0.2
258168
env:
@@ -262,84 +172,3 @@ jobs:
262172
asset_path: ${{ github.workspace }}/actions-runner-osx-arm64-${{ steps.releaseNote.outputs.version }}.tar.gz
263173
asset_name: actions-runner-osx-arm64-${{ steps.releaseNote.outputs.version }}.tar.gz
264174
asset_content_type: application/octet-stream
265-
266-
- name: Upload Release Asset (linux-arm)
267-
uses: actions/upload-release-asset@v1.0.2
268-
env:
269-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
270-
with:
271-
upload_url: ${{ steps.createRelease.outputs.upload_url }}
272-
asset_path: ${{ github.workspace }}/actions-runner-linux-arm-${{ steps.releaseNote.outputs.version }}.tar.gz
273-
asset_name: actions-runner-linux-arm-${{ steps.releaseNote.outputs.version }}.tar.gz
274-
asset_content_type: application/octet-stream
275-
276-
- name: Upload Release Asset (linux-arm64)
277-
uses: actions/upload-release-asset@v1.0.2
278-
env:
279-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
280-
with:
281-
upload_url: ${{ steps.createRelease.outputs.upload_url }}
282-
asset_path: ${{ github.workspace }}/actions-runner-linux-arm64-${{ steps.releaseNote.outputs.version }}.tar.gz
283-
asset_name: actions-runner-linux-arm64-${{ steps.releaseNote.outputs.version }}.tar.gz
284-
asset_content_type: application/octet-stream
285-
286-
publish-image:
287-
needs: release
288-
runs-on: ubuntu-latest
289-
permissions:
290-
contents: read
291-
packages: write
292-
id-token: write
293-
attestations: write
294-
env:
295-
REGISTRY: ghcr.io
296-
IMAGE_NAME: ${{ github.repository_owner }}/actions-runner
297-
steps:
298-
- name: Checkout repository
299-
uses: actions/checkout@v5
300-
301-
- name: Compute image version
302-
id: image
303-
uses: actions/github-script@v8.0.0
304-
with:
305-
script: |
306-
const fs = require('fs');
307-
const runnerVersion = fs.readFileSync('${{ github.workspace }}/releaseVersion', 'utf8').replace(/\n$/g, '')
308-
console.log(`Using runner version ${runnerVersion}`)
309-
core.setOutput('version', runnerVersion);
310-
311-
- name: Setup Docker buildx
312-
uses: docker/setup-buildx-action@v3
313-
314-
- name: Log into registry ${{ env.REGISTRY }}
315-
uses: docker/login-action@v3
316-
with:
317-
registry: ${{ env.REGISTRY }}
318-
username: ${{ github.actor }}
319-
password: ${{ secrets.GITHUB_TOKEN }}
320-
321-
- name: Build and push Docker image
322-
id: build-and-push
323-
uses: docker/build-push-action@v6
324-
with:
325-
context: ./images
326-
platforms: |
327-
linux/amd64
328-
linux/arm64
329-
tags: |
330-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }}
331-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
332-
build-args: |
333-
RUNNER_VERSION=${{ steps.image.outputs.version }}
334-
push: true
335-
labels: |
336-
org.opencontainers.image.source=${{github.server_url}}/${{github.repository}}
337-
org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}
338-
org.opencontainers.image.licenses=MIT
339-
340-
- name: Generate attestation
341-
uses: actions/attest-build-provenance@v3
342-
with:
343-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
344-
subject-digest: ${{ steps.build-and-push.outputs.digest }}
345-
push-to-registry: true
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace GitHub.Runner.Worker.Handlers
5+
{
6+
/// <summary>
7+
/// Helper to override ACTIONS_CACHE_URL and ACTIONS_RESULTS_URL environment variables
8+
/// with values from the actual process environment (e.g. set by the cache proxy),
9+
/// while preserving the original values for downstream use.
10+
/// </summary>
11+
public static class CacheEnvironmentHelper
12+
{
13+
/// <summary>
14+
/// Saves the current values of ACTIONS_CACHE_URL and ACTIONS_RESULTS_URL into
15+
/// ACTIONS_CACHE_URL_ORIGINAL and ACTIONS_RESULTS_URL_ORIGINAL, then overrides
16+
/// them with values from the actual process environment variables.
17+
/// Also sets ACTIONS_CACHE_SERVICE_V2 to "true".
18+
/// </summary>
19+
public static void OverrideCacheEnvironment(Dictionary<string, string> environment)
20+
{
21+
// Save original values so the cache proxy (or other consumers) can reach the real backend
22+
if (environment.TryGetValue("ACTIONS_CACHE_URL", out var originalCacheUrl))
23+
{
24+
environment["ACTIONS_CACHE_URL_ORIGINAL"] = originalCacheUrl;
25+
}
26+
27+
if (environment.TryGetValue("ACTIONS_RESULTS_URL", out var originalResultsUrl))
28+
{
29+
environment["ACTIONS_RESULTS_URL_ORIGINAL"] = originalResultsUrl;
30+
}
31+
32+
// Override with values from the process environment (set by the cache proxy)
33+
var envCacheUrl = System.Environment.GetEnvironmentVariable("ACTIONS_CACHE_URL");
34+
if (!string.IsNullOrEmpty(envCacheUrl))
35+
{
36+
environment["ACTIONS_CACHE_URL"] = envCacheUrl;
37+
}
38+
39+
var envResultsUrl = System.Environment.GetEnvironmentVariable("ACTIONS_RESULTS_URL");
40+
if (!string.IsNullOrEmpty(envResultsUrl))
41+
{
42+
environment["ACTIONS_RESULTS_URL"] = envResultsUrl;
43+
}
44+
45+
// Enable cache service v2
46+
environment["ACTIONS_CACHE_SERVICE_V2"] = "true";
47+
}
48+
}
49+
}

src/Runner.Worker/Handlers/ContainerActionHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ public async Task RunAsync(ActionRunStage stage)
245245
Environment["ACTIONS_RESULTS_URL"] = resultsUrl;
246246
}
247247

248+
// Apply Cache URL overrides
249+
CacheEnvironmentHelper.OverrideCacheEnvironment(Environment);
250+
248251
foreach (var variable in this.Environment)
249252
{
250253
container.ContainerEnvironmentVariables[variable.Key] = container.TranslateToContainerPath(variable.Value);

src/Runner.Worker/Handlers/NodeScriptActionHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public async Task RunAsync(ActionRunStage stage)
7777
Environment["ACTIONS_CACHE_SERVICE_V2"] = bool.TrueString;
7878
}
7979

80+
// Apply Cache URL overrides
81+
CacheEnvironmentHelper.OverrideCacheEnvironment(Environment);
82+
8083
// Resolve the target script.
8184
string target = null;
8285
if (stage == ActionRunStage.Main)

0 commit comments

Comments
 (0)