Skip to content

Commit cfc8505

Browse files
committed
ci: upload dependency mapping json
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent ae7ac7c commit cfc8505

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

.github/workflows/release.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ jobs:
6666
path: ./src/lima/lima-and-qemu.macos*
6767
if-no-files-found: error
6868

69+
- name: Upload dependency mapping ARM64
70+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
71+
with:
72+
name: dep-version-mapping-aarch64
73+
path: ./src/lima/dep-version-mapping-aarch64.json
74+
if-no-files-found: error
75+
6976
- name: Make and release source code of dependencies
7077
run: make download-sources
7178
- name: Upload MacOS build
@@ -125,6 +132,13 @@ jobs:
125132
path: ./src/lima/lima-and-qemu.macos*
126133
if-no-files-found: error
127134

135+
- name: Upload dependency mapping x86_64
136+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
137+
with:
138+
name: dep-version-mapping-x86_64
139+
path: ./src/lima/dep-version-mapping-x86_64.json
140+
if-no-files-found: error
141+
128142
macos-arm64-ventura-build:
129143
runs-on: [self-hosted, macos, arm64, "13", release]
130144
timeout-minutes: 60
@@ -185,6 +199,43 @@ jobs:
185199
path: src/lima/limactl.ventura.x86_64.tar.gz
186200
if-no-files-found: error
187201

202+
upload-dependency-mappings:
203+
runs-on: ubuntu-latest
204+
timeout-minutes: 10
205+
needs:
206+
- macos-x86-build
207+
- macos-arm64-build
208+
209+
steps:
210+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
211+
with:
212+
fetch-depth: 1
213+
persist-credentials: false
214+
215+
- name: configure aws credentials
216+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
217+
with:
218+
role-to-assume: ${{ secrets.DEPENDENCY_MAPPING_BUCKET_ROLE }}
219+
role-session-name: dependency-mapping-upload-session
220+
aws-region: ${{ secrets.DEPENDENCY_MAPPING_BUCKET_REGION }}
221+
222+
- name: Download dependency mapping ARM64
223+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
224+
with:
225+
name: dep-version-mapping-aarch64
226+
path: build
227+
228+
- name: Download dependency mapping x86_64
229+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
230+
with:
231+
name: dep-version-mapping-x86_64
232+
path: build
233+
234+
- name: Upload dependency mappings to S3
235+
run: |
236+
aws s3 cp ./build/dep-version-mapping-aarch64.json s3://${{ secrets.DEPENDENCY_MAPPING_BUCKET_NAME }}/aarch64/dep-version-mapping.json
237+
aws s3 cp ./build/dep-version-mapping-x86_64.json s3://${{ secrets.DEPENDENCY_MAPPING_BUCKET_NAME }}/x86-64/dep-version-mapping.json
238+
188239
release:
189240
runs-on: ubuntu-latest
190241
timeout-minutes: 10

bin/lima-and-qemu.pl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,39 @@
173173
unlink("$repo_root/$dist.tar.gz");
174174
system("tar cvfz $repo_root/$dist.tar.gz -C /tmp/$dist $files");
175175

176+
# Extract package versions from Cellar and export to JSON
177+
my %package_versions;
178+
for my $file (keys %deps) {
179+
# Extract package info from Cellar path: /opt/homebrew/Cellar/package/version/...
180+
if ($file =~ m|/Cellar/([^/]+)/([^/]+)/|) {
181+
my ($package, $version) = ($1, $2);
182+
$package_versions{$package} = {
183+
"package" => $package,
184+
"version" => $version
185+
};
186+
}
187+
# Handle direct bin files (like limactl) that might not be in Cellar
188+
elsif ($file =~ m|^$install_dir/bin/([^/]+)$|) {
189+
my $binary_name = $1;
190+
# Try to get version from the binary itself
191+
my $version_output = qx($file --version 2>/dev/null | head -1);
192+
if ($version_output =~ /(\d+\.\d+\.\d+[^\s]*)/) {
193+
$package_versions{$binary_name} = {
194+
"package" => $binary_name,
195+
"version" => $1
196+
};
197+
}
198+
}
199+
}
200+
201+
# Export to JSON
202+
use JSON qw( encode_json );
203+
my $json_file = "$repo_root/dep-version-mapping-$arch.json";
204+
open(my $json_fh, ">", $json_file) or die "Can't write $json_file: $!";
205+
print $json_fh encode_json(\%package_versions);
206+
close($json_fh);
207+
print "Generated dependency mapping: $json_file\n";
208+
176209
exit;
177210

178211
# File references may involve multiple symlinks that need to be recorded as well, e.g.

0 commit comments

Comments
 (0)