Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:
}

function tsConstStringPattern(key) {
return new RegExp(`^(const ${escapeRegExp(key)} = ')([^']*)(';)$`, 'm');
return new RegExp(`^((?:export )?const ${escapeRegExp(key)} = ')([^']*)(';)$`, 'm');
}

const dependencyConfigs = {
Expand Down Expand Up @@ -259,14 +259,21 @@ jobs:
sourceUrl: 'https://github.com/docker/actions-toolkit/blob/main/.github/undock-releases.json',
async resolve() {
const tag = readLatestTag('.github/undock-releases.json');
const version = stripLeadingV(tag);
return {
titleValue: tag,
targets: [
{
path: 'dev.Dockerfile',
key: 'UNDOCK_VERSION',
value: stripLeadingV(tag),
value: version,
pattern: dockerfileArgPattern('UNDOCK_VERSION')
},
{
path: 'src/docker/assets.ts',
key: 'limaUndockVersion',
value: version,
pattern: tsConstStringPattern('limaUndockVersion')
}
]
};
Expand Down
24 changes: 24 additions & 0 deletions __tests__/docker/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

import {describe, expect, vi, test, beforeEach, afterEach, it} from 'vitest';
import fs from 'fs';
import handlebars from 'handlebars';
import os from 'os';
import path from 'path';
import * as rimraf from 'rimraf';

import {mockArch, mockPlatform} from '../.helpers/os.js';

import {limaYamlData, limaUndockVersion} from '../../src/docker/assets.js';
import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install.js';

const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-'));
Expand Down Expand Up @@ -128,3 +130,25 @@ aarch64:https://cloud-images.ubuntu.com/releases/23.10/release-20231011/ubuntu-2
]);
});
});

describe('limaYamlData', () => {
it('renders the pinned undock version in the release URL', () => {
const instance = handlebars.create();
instance.registerHelper('stringify', function (obj) {
return new instance.SafeString(JSON.stringify(obj));
});
const limaCfg = instance.compile(limaYamlData)({
customImages: [],
daemonConfig: {},
dockerSock: '/tmp/docker.sock',
gitCommit: 'master',
srcType: 'image',
srcArchiveVersion: '29.0.0',
srcArchiveChannel: 'stable',
srcImageTag: '29.0.0',
undockVersion: limaUndockVersion
});

expect(limaCfg).toContain(`url="https://github.com/crazy-max/undock/releases/download/v${limaUndockVersion}/undock_${limaUndockVersion}_linux_$arch.tar.gz"`);
});
});
4 changes: 3 additions & 1 deletion src/docker/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const limaYaml = (): string => {
return get('lima.yaml', limaYamlData);
};

export const limaUndockVersion = '0.14.0';

const get = (filename: string, data: string, mode?: string): string => {
const assetPath = Context.tmpName({
template: `docker-asset-XXXXXX-${filename}`,
Expand Down Expand Up @@ -283,7 +285,7 @@ provision:
x86_64) arch=amd64;;
aarch64) arch=arm64;;
esac
url="https://github.com/crazy-max/undock/releases/download/v0.12.0/undock_0.12.0_linux_$arch.tar.gz"
url="https://github.com/crazy-max/undock/releases/download/v{{undockVersion}}/undock_{{undockVersion}}_linux_$arch.tar.gz"

wget "$url" -O /tmp/undock.tar.gz
tar -C /usr/local/bin -xvf /tmp/undock.tar.gz
Expand Down
5 changes: 3 additions & 2 deletions src/docker/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {Regctl} from '../regclient/regctl.js';
import {Undock} from '../undock/undock.js';
import {Util} from '../util.js';

import {limaYamlData, dockerServiceLogsPs1, setupDockerWinPs1} from './assets.js';
import {limaYamlData, dockerServiceLogsPs1, setupDockerWinPs1, limaUndockVersion} from './assets.js';

import {GitHubRelease} from '../types/github/github.js';
import {Image} from '../types/oci/config.js';
Expand Down Expand Up @@ -295,7 +295,8 @@ export class Install {
srcType: src.type,
srcArchiveVersion: this._version, // Use the resolved version (e.g. latest -> 27.4.0)
srcArchiveChannel: srcArchive.channel,
srcImageTag: (src as InstallSourceImage).tag
srcImageTag: (src as InstallSourceImage).tag,
undockVersion: limaUndockVersion
});
core.info(`Writing lima config to ${path.join(limaDir, 'lima.yaml')}`);
fs.writeFileSync(path.join(limaDir, 'lima.yaml'), limaCfg);
Expand Down
Loading