diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c9d881e..dfd8508 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: # Matrix test for all supported platforms and architectures integration-tests: - name: Test ${{ matrix.os }} (${{ matrix.arch }}) + name: ${{ matrix.os }} (${{ matrix.arch }}) tailscale-${{ matrix.version }} strategy: fail-fast: false matrix: @@ -20,31 +20,54 @@ jobs: - os: ubuntu-latest runner-os: Linux arch: amd64 + version: latest + + # Try unstable too + - os: ubuntu-latest + runner-os: Linux + arch: amd64 + version: unstable + + # Try a pinned version + - os: ubuntu-latest + runner-os: Linux + arch: amd64 + version: 1.82.0 # Linux tests (ARM64) - os: ubuntu-24.04-arm runner-os: Linux arch: arm64 + version: latest # Windows tests (AMD64) - os: windows-latest runner-os: Windows arch: amd64 + version: latest + + - os: windows-latest + runner-os: Windows + arch: amd64 + version: unstable # Windows tests (ARM64) - os: windows-11-arm runner-os: Windows arch: arm64 + version: latest # macOS intel - os: macos-13 runner-os: macOS arch: amd64 + version: latest # macOS ARM - os: macos-14 runner-os: macOS arch: arm64 + version: latest runs-on: ${{ matrix.os }} @@ -72,7 +95,7 @@ jobs: oauth-client-id: ${{ secrets.TS_AUTH_KEYS_OAUTH_CLIENT_ID }} oauth-client-secret: ${{ secrets.TS_AUTH_KEYS_OAUTH_CLIENT_SECRET }} tags: "tag:ci" - version: "1.82.0" + version: "${{ matrix.version }}" use-cache: false timeout: "5m" retry: 3 diff --git a/Makefile b/Makefile index 07b1a87..9dc7685 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ install: npm install # Build the TypeScript code -build: clean +build: clean format npm run build # Lint the TypeScript code diff --git a/dist/index.js b/dist/index.js index f5a0829..94ed941 100644 --- a/dist/index.js +++ b/dist/index.js @@ -41204,10 +41204,15 @@ async function run() { } // Get and validate inputs const config = await getInputs(); + if (runnerOS === "macOS" && + config.version === "unstable" && + config.useCache) { + throw new Error("Caching of unstable releases is not supported on macOS runners"); + } // Validate authentication validateAuth(config); // Resolve version - config.resolvedVersion = await resolveVersion(config.version); + config.resolvedVersion = await resolveVersion(config.version, runnerOS); core.info(`Resolved Tailscale version: ${config.resolvedVersion}`); // Set architecture config.arch = getTailscaleArch(runnerOS); @@ -41268,13 +41273,17 @@ function validateAuth(config) { throw new Error("OAuth identity empty, please provide either an auth key or OAuth secret and tags."); } } -async function resolveVersion(version) { - if (version === "latest") { +async function resolveVersion(version, runnerOS) { + if (runnerOS === "macOS" && version === "unstable") { + return "main"; + } + if (version === "latest" || version === "unstable") { + let path = version === "unstable" ? "unstable" : "stable"; const { stdout } = await exec.getExecOutput("curl", [ "-H", "user-agent:action-setup-tailscale", "-s", - "https://pkgs.tailscale.com/stable/?mode=json", + `https://pkgs.tailscale.com/${path}/?mode=json`, ]); const response = JSON.parse(stdout); return response.Version; @@ -41656,8 +41665,7 @@ function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } function generateCacheKey(config, runnerOS) { - // Don't cache if version is latest or if caching is disabled - if (config.resolvedVersion === "latest" || !config.useCache) { + if (!config.useCache) { return undefined; } return `action-setup-tailscale/${config.resolvedVersion}/${runnerOS}-${config.arch}`; diff --git a/src/main.ts b/src/main.ts index 10e9519..2996009 100644 --- a/src/main.ts +++ b/src/main.ts @@ -114,11 +114,21 @@ async function run(): Promise { // Get and validate inputs const config = await getInputs(); + if ( + runnerOS === "macOS" && + config.version === "unstable" && + config.useCache + ) { + throw new Error( + "Caching of unstable releases is not supported on macOS runners" + ); + } + // Validate authentication validateAuth(config); // Resolve version - config.resolvedVersion = await resolveVersion(config.version); + config.resolvedVersion = await resolveVersion(config.version, runnerOS); core.info(`Resolved Tailscale version: ${config.resolvedVersion}`); // Set architecture @@ -186,17 +196,26 @@ function validateAuth(config: TailscaleConfig): void { } } -async function resolveVersion(version: string): Promise { - if (version === "latest") { +async function resolveVersion( + version: string, + runnerOS: string +): Promise { + if (runnerOS === "macOS" && version === "unstable") { + return "main"; + } + + if (version === "latest" || version === "unstable") { + let path = version === "unstable" ? "unstable" : "stable"; const { stdout } = await exec.getExecOutput("curl", [ "-H", "user-agent:action-setup-tailscale", "-s", - "https://pkgs.tailscale.com/stable/?mode=json", + `https://pkgs.tailscale.com/${path}/?mode=json`, ]); const response = JSON.parse(stdout); return response.Version; } + return version; } @@ -665,8 +684,7 @@ function generateCacheKey( config: TailscaleConfig, runnerOS: string ): string | undefined { - // Don't cache if version is latest or if caching is disabled - if (config.resolvedVersion === "latest" || !config.useCache) { + if (!config.useCache) { return undefined; }