mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-31 15:50:33 +00:00 
			
		
		
		
	Compare commits
	
		
			8 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 3041bf56c9 | ||
|   | 41dfa10bad | ||
|   | 941977282c | ||
|   | d60b41a563 | ||
|   | e09f57f6a9 | ||
|   | df1a11710e | ||
|   | 49582f6476 | ||
|   | b26d40294f | 
							
								
								
									
										20
									
								
								.github/workflows/publish-immutable-actions.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								.github/workflows/publish-immutable-actions.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | name: 'Publish Immutable Action Version' | ||||||
|  |  | ||||||
|  | on: | ||||||
|  |   release: | ||||||
|  |     types: [published] | ||||||
|  |  | ||||||
|  | jobs: | ||||||
|  |   publish: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     permissions: | ||||||
|  |       contents: read | ||||||
|  |       id-token: write | ||||||
|  |       packages: write | ||||||
|  |  | ||||||
|  |     steps: | ||||||
|  |       - name: Checking out | ||||||
|  |         uses: actions/checkout@v4 | ||||||
|  |       - name: Publish | ||||||
|  |         id: publish | ||||||
|  |         uses: actions/publish-immutable-action@0.0.3 | ||||||
| @@ -22,7 +22,7 @@ jobs: | |||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|     steps: |     steps: | ||||||
|       - name: Update the ${{ env.TAG_NAME }} tag |       - name: Update the ${{ env.TAG_NAME }} tag | ||||||
|         uses: actions/publish-action@v0.2.2 |         uses: actions/publish-action@v0.3.0 | ||||||
|         with: |         with: | ||||||
|           source-tag: ${{ env.TAG_NAME }} |           source-tag: ${{ env.TAG_NAME }} | ||||||
|           slack-webhook: ${{ secrets.SLACK_WEBHOOK }} |           slack-webhook: ${{ secrets.SLACK_WEBHOOK }} | ||||||
|   | |||||||
							
								
								
									
										51
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							| @@ -18,7 +18,7 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, windows-latest, macos-latest] |         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Setup Go Stable |       - name: Setup Go Stable | ||||||
| @@ -33,7 +33,7 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, windows-latest, macos-latest] |         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Setup Go oldStable |       - name: Setup Go oldStable | ||||||
| @@ -48,12 +48,14 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, windows-latest, macos-latest] |         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||||
|         version: [stable, oldstable] |         version: [stable, oldstable] | ||||||
|         architecture: [x64, x32] |         architecture: [x64, x32] | ||||||
|         exclude: |         exclude: | ||||||
|           - os: macos-latest |           - os: macos-latest | ||||||
|             architecture: x32 |             architecture: x32 | ||||||
|  |           - os: macos-13 | ||||||
|  |             architecture: x32 | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} |       - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} | ||||||
| @@ -70,8 +72,14 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [macos-latest, windows-latest, ubuntu-latest] |         os: [macos-latest, windows-latest, ubuntu-latest, macos-13] | ||||||
|         go: [1.20.14, 1.21.10, 1.22.3] |         go: [1.21.13, 1.22.8, 1.23.2] | ||||||
|  |         include: | ||||||
|  |           - os: windows-latest | ||||||
|  |             go: 1.20.14 | ||||||
|  |         exclude: | ||||||
|  |           - os: windows-latest | ||||||
|  |             go: 1.23.2 | ||||||
|     steps: |     steps: | ||||||
|       - name: Checkout |       - name: Checkout | ||||||
|         uses: actions/checkout@v4 |         uses: actions/checkout@v4 | ||||||
| @@ -90,8 +98,8 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, windows-latest, macos-latest] |         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||||
|         go-version: [1.20.14, 1.21] |         go-version: ['1.20', '1.21', '1.22', '1.23'] | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Setup Go and check latest |       - name: Setup Go and check latest | ||||||
| @@ -107,7 +115,7 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, windows-latest, macos-latest] |         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Setup Go and check latest |       - name: Setup Go and check latest | ||||||
| @@ -123,7 +131,7 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, windows-latest, macos-latest] |         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Setup Go and check latest |       - name: Setup Go and check latest | ||||||
| @@ -135,13 +143,12 @@ jobs: | |||||||
|         shell: bash |         shell: bash | ||||||
|  |  | ||||||
|   setup-versions-from-manifest: |   setup-versions-from-manifest: | ||||||
|     name: Setup ${{ matrix.go }} ${{ matrix.os }} |  | ||||||
|     runs-on: ${{ matrix.os }} |     runs-on: ${{ matrix.os }} | ||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [macos-latest, windows-latest, ubuntu-latest] |         os: [macos-latest, windows-latest, ubuntu-latest, macos-13] | ||||||
|         go: [1.20.14, 1.21.10, 1.22.3] |         go: [1.20.14, 1.21.10, 1.22.8, 1.23.2] | ||||||
|     steps: |     steps: | ||||||
|       - name: Checkout |       - name: Checkout | ||||||
|         uses: actions/checkout@v4 |         uses: actions/checkout@v4 | ||||||
| @@ -156,13 +163,12 @@ jobs: | |||||||
|         shell: bash |         shell: bash | ||||||
|  |  | ||||||
|   setup-versions-from-dist: |   setup-versions-from-dist: | ||||||
|     name: Setup ${{ matrix.go }} ${{ matrix.os }} |  | ||||||
|     runs-on: ${{ matrix.os }} |     runs-on: ${{ matrix.os }} | ||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [macos-latest, windows-latest, ubuntu-latest] |         os: [windows-latest, ubuntu-latest, macos-13] | ||||||
|         go: [1.20.14, 1.21] |         go: [1.11.12] | ||||||
|     steps: |     steps: | ||||||
|       - name: Checkout |       - name: Checkout | ||||||
|         uses: actions/checkout@v4 |         uses: actions/checkout@v4 | ||||||
| @@ -181,14 +187,23 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         os: [ubuntu-latest, windows-latest, macos-latest] |         os: [ubuntu-latest, windows-latest, macos-latest, macos-13] | ||||||
|         go-version: [1.20.14, 1.21] |         go-version: [1.20.14, 1.21, 1.22, 1.23] | ||||||
|  |         include: | ||||||
|  |           - os: macos-latest | ||||||
|  |             architecture: arm64 | ||||||
|  |           - os: ubuntu-latest | ||||||
|  |             architecture: x64 | ||||||
|  |           - os: windows-latest | ||||||
|  |             architecture: x64 | ||||||
|  |           - os: macos-13 | ||||||
|  |             architecture: x64 | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Setup Go and check latest |       - name: Setup Go and check latest | ||||||
|         uses: ./ |         uses: ./ | ||||||
|         with: |         with: | ||||||
|           go-version: ${{ matrix.go-version }} |           go-version: ${{ matrix.go-version }} | ||||||
|           architecture: x64 |           architecture: ${{ matrix.architecture }} | ||||||
|       - name: Verify Go |       - name: Verify Go | ||||||
|         run: go version |         run: go version | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								README.md
									
									
									
									
									
								
							| @@ -242,18 +242,14 @@ documentation. | |||||||
|  |  | ||||||
| ## Using `setup-go` on GHES | ## Using `setup-go` on GHES | ||||||
|  |  | ||||||
| `setup-go` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Go | `setup-go` comes pre-installed on the appliance with GHES if Actions is enabled. | ||||||
| distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) | When dynamically downloading Go distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) on github.com (outside of the appliance). | ||||||
| on github.com (outside of the appliance). These calls to `actions/go-versions` are made via unauthenticated requests, |  | ||||||
| which are limited |  | ||||||
| to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If |  | ||||||
| more requests are made within the time frame, then you will start to see rate-limit errors during downloading that looks |  | ||||||
| like: `##[error]API rate limit exceeded for...`. After that error the action will try to download versions directly |  | ||||||
| from https://storage.googleapis.com/golang, but it also can have rate limit so it's better to put token. |  | ||||||
|  |  | ||||||
| To get a higher rate limit, you | These calls to `actions/go-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). | ||||||
| can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` | If more requests are made within the time frame, then the action leverages the `raw API` to retrieve the version-manifest. This approach does not impose a rate limit and hence facilitates unrestricted consumption. This is particularly beneficial for GHES runners, which often share the same IP, to avoid the quick exhaustion of the unauthenticated rate limit. | ||||||
| input for the action: | If that fails as well the action will try to download versions directly from https://storage.googleapis.com/golang. | ||||||
|  |  | ||||||
|  | If that fails as well you can get a higher rate limit with [generating a personal access token on github.com](https://github.com/settings/tokens/new) and passing it as the `token` input to the action: | ||||||
|  |  | ||||||
| ```yaml | ```yaml | ||||||
| uses: actions/setup-go@v5 | uses: actions/setup-go@v5 | ||||||
| @@ -262,8 +258,7 @@ with: | |||||||
|   go-version: '1.18' |   go-version: '1.18' | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the | If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the runner's tool cache. | ||||||
| runner's tool cache. |  | ||||||
| See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" | See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" | ||||||
| for more information. | for more information. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -209,3 +209,41 @@ describe('isCacheFeatureAvailable', () => { | |||||||
|     expect(warningSpy).toHaveBeenCalledWith(warningMessage); |     expect(warningSpy).toHaveBeenCalledWith(warningMessage); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | describe('isGhes', () => { | ||||||
|  |   const pristineEnv = process.env; | ||||||
|  |  | ||||||
|  |   beforeEach(() => { | ||||||
|  |     jest.resetModules(); | ||||||
|  |     process.env = {...pristineEnv}; | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   afterAll(() => { | ||||||
|  |     process.env = pristineEnv; | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => { | ||||||
|  |     delete process.env['GITHUB_SERVER_URL']; | ||||||
|  |     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => { | ||||||
|  |     process.env['GITHUB_SERVER_URL'] = 'https://github.com'; | ||||||
|  |     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => { | ||||||
|  |     process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com'; | ||||||
|  |     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => { | ||||||
|  |     process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost'; | ||||||
|  |     expect(cacheUtils.isGhes()).toBeFalsy(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => { | ||||||
|  |     process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com'; | ||||||
|  |     expect(cacheUtils.isGhes()).toBeTruthy(); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ import osm, {type} from 'os'; | |||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import * as main from '../src/main'; | import * as main from '../src/main'; | ||||||
| import * as im from '../src/installer'; | import * as im from '../src/installer'; | ||||||
|  | import * as httpm from '@actions/http-client'; | ||||||
|  |  | ||||||
| import goJsonData from './data/golang-dl.json'; | import goJsonData from './data/golang-dl.json'; | ||||||
| import matchers from '../matchers.json'; | import matchers from '../matchers.json'; | ||||||
| @@ -46,6 +47,7 @@ describe('setup-go', () => { | |||||||
|   let execSpy: jest.SpyInstance; |   let execSpy: jest.SpyInstance; | ||||||
|   let getManifestSpy: jest.SpyInstance; |   let getManifestSpy: jest.SpyInstance; | ||||||
|   let getAllVersionsSpy: jest.SpyInstance; |   let getAllVersionsSpy: jest.SpyInstance; | ||||||
|  |   let httpmGetJsonSpy: jest.SpyInstance; | ||||||
|  |  | ||||||
|   beforeAll(async () => { |   beforeAll(async () => { | ||||||
|     process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible) |     process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible) | ||||||
| @@ -90,6 +92,9 @@ describe('setup-go', () => { | |||||||
|     getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); |     getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); | ||||||
|     getAllVersionsSpy = jest.spyOn(im, 'getManifest'); |     getAllVersionsSpy = jest.spyOn(im, 'getManifest'); | ||||||
|  |  | ||||||
|  |     // httm | ||||||
|  |     httpmGetJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson'); | ||||||
|  |  | ||||||
|     // io |     // io | ||||||
|     whichSpy = jest.spyOn(io, 'which'); |     whichSpy = jest.spyOn(io, 'which'); | ||||||
|     existsSpy = jest.spyOn(fs, 'existsSync'); |     existsSpy = jest.spyOn(fs, 'existsSync'); | ||||||
| @@ -151,6 +156,21 @@ describe('setup-go', () => { | |||||||
|     ); |     ); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|  |   it('should return manifest from repo', async () => { | ||||||
|  |     const manifest = await im.getManifest(undefined); | ||||||
|  |     expect(manifest).toEqual(goTestManifest); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('should return manifest from raw URL if repo fetch fails', async () => { | ||||||
|  |     getManifestSpy.mockRejectedValue(new Error('Fetch failed')); | ||||||
|  |     httpmGetJsonSpy.mockResolvedValue({ | ||||||
|  |       result: goTestManifest | ||||||
|  |     }); | ||||||
|  |     const manifest = await im.getManifest(undefined); | ||||||
|  |     expect(httpmGetJsonSpy).toHaveBeenCalled(); | ||||||
|  |     expect(manifest).toEqual(goTestManifest); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|   it('can find 1.9 from manifest on linux', async () => { |   it('can find 1.9 from manifest on linux', async () => { | ||||||
|     os.platform = 'linux'; |     os.platform = 'linux'; | ||||||
|     os.arch = 'x64'; |     os.arch = 'x64'; | ||||||
| @@ -790,6 +810,9 @@ describe('setup-go', () => { | |||||||
|       getManifestSpy.mockImplementation(() => { |       getManifestSpy.mockImplementation(() => { | ||||||
|         throw new Error('Unable to download manifest'); |         throw new Error('Unable to download manifest'); | ||||||
|       }); |       }); | ||||||
|  |       httpmGetJsonSpy.mockRejectedValue( | ||||||
|  |         new Error('Unable to download manifest from raw URL') | ||||||
|  |       ); | ||||||
|       getAllVersionsSpy.mockImplementationOnce(() => undefined); |       getAllVersionsSpy.mockImplementationOnce(() => undefined); | ||||||
|  |  | ||||||
|       dlSpy.mockImplementation(async () => '/some/temp/path'); |       dlSpy.mockImplementation(async () => '/some/temp/path'); | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -81175,7 +81175,11 @@ const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, | |||||||
| exports.getCacheDirectoryPath = getCacheDirectoryPath; | exports.getCacheDirectoryPath = getCacheDirectoryPath; | ||||||
| function isGhes() { | function isGhes() { | ||||||
|     const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); |     const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); | ||||||
|     return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; |     const hostname = ghUrl.hostname.trimEnd().toUpperCase(); | ||||||
|  |     const isGitHubHost = hostname === 'GITHUB.COM'; | ||||||
|  |     const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); | ||||||
|  |     const isLocalHost = hostname.endsWith('.LOCALHOST'); | ||||||
|  |     return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; | ||||||
| } | } | ||||||
| exports.isGhes = isGhes; | exports.isGhes = isGhes; | ||||||
| function isCacheFeatureAvailable() { | function isCacheFeatureAvailable() { | ||||||
|   | |||||||
							
								
								
									
										39
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -88045,6 +88045,7 @@ const cache_utils_1 = __nccwpck_require__(1678); | |||||||
| const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { | const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { | ||||||
|     const packageManagerInfo = yield (0, cache_utils_1.getPackageManagerInfo)(packageManager); |     const packageManagerInfo = yield (0, cache_utils_1.getPackageManagerInfo)(packageManager); | ||||||
|     const platform = process.env.RUNNER_OS; |     const platform = process.env.RUNNER_OS; | ||||||
|  |     const arch = process.arch; | ||||||
|     const cachePaths = yield (0, cache_utils_1.getCacheDirectoryPath)(packageManagerInfo); |     const cachePaths = yield (0, cache_utils_1.getCacheDirectoryPath)(packageManagerInfo); | ||||||
|     const dependencyFilePath = cacheDependencyPath |     const dependencyFilePath = cacheDependencyPath | ||||||
|         ? cacheDependencyPath |         ? cacheDependencyPath | ||||||
| @@ -88054,7 +88055,7 @@ const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awa | |||||||
|         throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); |         throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); | ||||||
|     } |     } | ||||||
|     const linuxVersion = process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; |     const linuxVersion = process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; | ||||||
|     const primaryKey = `setup-go-${platform}-${linuxVersion}go-${versionSpec}-${fileHash}`; |     const primaryKey = `setup-go-${platform}-${arch}-${linuxVersion}go-${versionSpec}-${fileHash}`; | ||||||
|     core.debug(`primary key is ${primaryKey}`); |     core.debug(`primary key is ${primaryKey}`); | ||||||
|     core.saveState(constants_1.State.CachePrimaryKey, primaryKey); |     core.saveState(constants_1.State.CachePrimaryKey, primaryKey); | ||||||
|     const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); |     const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); | ||||||
| @@ -88164,7 +88165,11 @@ const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, | |||||||
| exports.getCacheDirectoryPath = getCacheDirectoryPath; | exports.getCacheDirectoryPath = getCacheDirectoryPath; | ||||||
| function isGhes() { | function isGhes() { | ||||||
|     const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); |     const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); | ||||||
|     return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; |     const hostname = ghUrl.hostname.trimEnd().toUpperCase(); | ||||||
|  |     const isGitHubHost = hostname === 'GITHUB.COM'; | ||||||
|  |     const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); | ||||||
|  |     const isLocalHost = hostname.endsWith('.LOCALHOST'); | ||||||
|  |     return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; | ||||||
| } | } | ||||||
| exports.isGhes = isGhes; | exports.isGhes = isGhes; | ||||||
| function isCacheFeatureAvailable() { | function isCacheFeatureAvailable() { | ||||||
| @@ -88254,6 +88259,10 @@ const sys = __importStar(__nccwpck_require__(5632)); | |||||||
| const fs_1 = __importDefault(__nccwpck_require__(7147)); | const fs_1 = __importDefault(__nccwpck_require__(7147)); | ||||||
| const os_1 = __importDefault(__nccwpck_require__(2037)); | const os_1 = __importDefault(__nccwpck_require__(2037)); | ||||||
| const utils_1 = __nccwpck_require__(1314); | const utils_1 = __nccwpck_require__(1314); | ||||||
|  | const MANIFEST_REPO_OWNER = 'actions'; | ||||||
|  | const MANIFEST_REPO_NAME = 'go-versions'; | ||||||
|  | const MANIFEST_REPO_BRANCH = 'main'; | ||||||
|  | const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; | ||||||
| function getGo(versionSpec_1, checkLatest_1, auth_1) { | function getGo(versionSpec_1, checkLatest_1, auth_1) { | ||||||
|     return __awaiter(this, arguments, void 0, function* (versionSpec, checkLatest, auth, arch = os_1.default.arch()) { |     return __awaiter(this, arguments, void 0, function* (versionSpec, checkLatest, auth, arch = os_1.default.arch()) { | ||||||
|         var _a; |         var _a; | ||||||
| @@ -88428,10 +88437,34 @@ function extractGoArchive(archivePath) { | |||||||
| exports.extractGoArchive = extractGoArchive; | exports.extractGoArchive = extractGoArchive; | ||||||
| function getManifest(auth) { | function getManifest(auth) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); |         try { | ||||||
|  |             return yield getManifestFromRepo(auth); | ||||||
|  |         } | ||||||
|  |         catch (err) { | ||||||
|  |             core.debug('Fetching the manifest via the API failed.'); | ||||||
|  |             if (err instanceof Error) { | ||||||
|  |                 core.debug(err.message); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return yield getManifestFromURL(); | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| exports.getManifest = getManifest; | exports.getManifest = getManifest; | ||||||
|  | function getManifestFromRepo(auth) { | ||||||
|  |     core.debug(`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`); | ||||||
|  |     return tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, auth, MANIFEST_REPO_BRANCH); | ||||||
|  | } | ||||||
|  | function getManifestFromURL() { | ||||||
|  |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|  |         core.debug('Falling back to fetching the manifest using raw URL.'); | ||||||
|  |         const http = new httpm.HttpClient('tool-cache'); | ||||||
|  |         const response = yield http.getJson(MANIFEST_URL); | ||||||
|  |         if (!response.result) { | ||||||
|  |             throw new Error(`Unable to get manifest from ${MANIFEST_URL}`); | ||||||
|  |         } | ||||||
|  |         return response.result; | ||||||
|  |     }); | ||||||
|  | } | ||||||
| function getInfoFromManifest(versionSpec_1, stable_1, auth_1) { | function getInfoFromManifest(versionSpec_1, stable_1, auth_1) { | ||||||
|     return __awaiter(this, arguments, void 0, function* (versionSpec, stable, auth, arch = os_1.default.arch(), manifest) { |     return __awaiter(this, arguments, void 0, function* (versionSpec, stable, auth, arch = os_1.default.arch(), manifest) { | ||||||
|         let info = null; |         let info = null; | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										15
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -2504,10 +2504,11 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/cross-spawn": { |     "node_modules/cross-spawn": { | ||||||
|       "version": "7.0.3", |       "version": "7.0.6", | ||||||
|       "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", |       "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", | ||||||
|       "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", |       "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|  |       "license": "MIT", | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "path-key": "^3.1.0", |         "path-key": "^3.1.0", | ||||||
|         "shebang-command": "^2.0.0", |         "shebang-command": "^2.0.0", | ||||||
| @@ -4559,12 +4560,12 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/micromatch": { |     "node_modules/micromatch": { | ||||||
|       "version": "4.0.5", |       "version": "4.0.8", | ||||||
|       "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", |       "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", | ||||||
|       "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", |       "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "braces": "^3.0.2", |         "braces": "^3.0.3", | ||||||
|         "picomatch": "^2.3.1" |         "picomatch": "^2.3.1" | ||||||
|       }, |       }, | ||||||
|       "engines": { |       "engines": { | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ export const restoreCache = async ( | |||||||
| ) => { | ) => { | ||||||
|   const packageManagerInfo = await getPackageManagerInfo(packageManager); |   const packageManagerInfo = await getPackageManagerInfo(packageManager); | ||||||
|   const platform = process.env.RUNNER_OS; |   const platform = process.env.RUNNER_OS; | ||||||
|  |   const arch = process.arch; | ||||||
|  |  | ||||||
|   const cachePaths = await getCacheDirectoryPath(packageManagerInfo); |   const cachePaths = await getCacheDirectoryPath(packageManagerInfo); | ||||||
|  |  | ||||||
| @@ -31,7 +32,7 @@ export const restoreCache = async ( | |||||||
|  |  | ||||||
|   const linuxVersion = |   const linuxVersion = | ||||||
|     process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; |     process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; | ||||||
|   const primaryKey = `setup-go-${platform}-${linuxVersion}go-${versionSpec}-${fileHash}`; |   const primaryKey = `setup-go-${platform}-${arch}-${linuxVersion}go-${versionSpec}-${fileHash}`; | ||||||
|   core.debug(`primary key is ${primaryKey}`); |   core.debug(`primary key is ${primaryKey}`); | ||||||
|  |  | ||||||
|   core.saveState(State.CachePrimaryKey, primaryKey); |   core.saveState(State.CachePrimaryKey, primaryKey); | ||||||
|   | |||||||
| @@ -63,7 +63,13 @@ export function isGhes(): boolean { | |||||||
|   const ghUrl = new URL( |   const ghUrl = new URL( | ||||||
|     process.env['GITHUB_SERVER_URL'] || 'https://github.com' |     process.env['GITHUB_SERVER_URL'] || 'https://github.com' | ||||||
|   ); |   ); | ||||||
|   return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; |  | ||||||
|  |   const hostname = ghUrl.hostname.trimEnd().toUpperCase(); | ||||||
|  |   const isGitHubHost = hostname === 'GITHUB.COM'; | ||||||
|  |   const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); | ||||||
|  |   const isLocalHost = hostname.endsWith('.LOCALHOST'); | ||||||
|  |  | ||||||
|  |   return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; | ||||||
| } | } | ||||||
|  |  | ||||||
| export function isCacheFeatureAvailable(): boolean { | export function isCacheFeatureAvailable(): boolean { | ||||||
|   | |||||||
| @@ -8,6 +8,11 @@ import fs from 'fs'; | |||||||
| import os from 'os'; | import os from 'os'; | ||||||
| import {StableReleaseAlias} from './utils'; | import {StableReleaseAlias} from './utils'; | ||||||
|  |  | ||||||
|  | const MANIFEST_REPO_OWNER = 'actions'; | ||||||
|  | const MANIFEST_REPO_NAME = 'go-versions'; | ||||||
|  | const MANIFEST_REPO_BRANCH = 'main'; | ||||||
|  | const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; | ||||||
|  |  | ||||||
| type InstallationType = 'dist' | 'manifest'; | type InstallationType = 'dist' | 'manifest'; | ||||||
|  |  | ||||||
| export interface IGoVersionFile { | export interface IGoVersionFile { | ||||||
| @@ -274,8 +279,43 @@ export async function extractGoArchive(archivePath: string): Promise<string> { | |||||||
|   return extPath; |   return extPath; | ||||||
| } | } | ||||||
|  |  | ||||||
| export async function getManifest(auth: string | undefined) { | export async function getManifest( | ||||||
|   return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); |   auth: string | undefined | ||||||
|  | ): Promise<tc.IToolRelease[]> { | ||||||
|  |   try { | ||||||
|  |     return await getManifestFromRepo(auth); | ||||||
|  |   } catch (err) { | ||||||
|  |     core.debug('Fetching the manifest via the API failed.'); | ||||||
|  |     if (err instanceof Error) { | ||||||
|  |       core.debug(err.message); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return await getManifestFromURL(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function getManifestFromRepo( | ||||||
|  |   auth: string | undefined | ||||||
|  | ): Promise<tc.IToolRelease[]> { | ||||||
|  |   core.debug( | ||||||
|  |     `Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}` | ||||||
|  |   ); | ||||||
|  |   return tc.getManifestFromRepo( | ||||||
|  |     MANIFEST_REPO_OWNER, | ||||||
|  |     MANIFEST_REPO_NAME, | ||||||
|  |     auth, | ||||||
|  |     MANIFEST_REPO_BRANCH | ||||||
|  |   ); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | async function getManifestFromURL(): Promise<tc.IToolRelease[]> { | ||||||
|  |   core.debug('Falling back to fetching the manifest using raw URL.'); | ||||||
|  |  | ||||||
|  |   const http: httpm.HttpClient = new httpm.HttpClient('tool-cache'); | ||||||
|  |   const response = await http.getJson<tc.IToolRelease[]>(MANIFEST_URL); | ||||||
|  |   if (!response.result) { | ||||||
|  |     throw new Error(`Unable to get manifest from ${MANIFEST_URL}`); | ||||||
|  |   } | ||||||
|  |   return response.result; | ||||||
| } | } | ||||||
|  |  | ||||||
| export async function getInfoFromManifest( | export async function getInfoFromManifest( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user