├── .gitattributes ├── .github └── workflows │ └── build-and-test.yml ├── .gitignore ├── LICENSE ├── README.md ├── __tests__ └── run.test.ts ├── action.cue ├── action.yml ├── action_tool.cue ├── ci_tool.cue ├── cue.mod ├── module.cue └── pkg │ └── json.schemastore.org │ └── github │ ├── github-action.cue │ └── github-workflow.cue ├── dist ├── LICENSE └── index.js ├── jest.config.js ├── package-lock.json ├── package.json ├── src └── run.ts ├── tsconfig.json └── workflows.cue /.gitattributes: -------------------------------------------------------------------------------- 1 | /.github/workflows/*.yml linguist-generated 2 | /cue.mod/pkg/**/* linguist-generated 3 | /action.yml linguist-generated 4 | -------------------------------------------------------------------------------- /.github/workflows/build-and-test.yml: -------------------------------------------------------------------------------- 1 | # Generated by cue cmd genworkflows; do not edit 2 | 3 | name: build and test 4 | "on": 5 | pull_request: 6 | types: 7 | - opened 8 | - synchronize 9 | push: 10 | branches: 11 | - main 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | - name: Use node.js 20.x 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version: 20 22 | - name: Use CUE 23 | uses: ./ 24 | with: 25 | version: v0.7.1 26 | - name: Check CUE version 27 | run: cue version 28 | - name: Run tests 29 | run: | 30 | npm ci 31 | - name: Build 32 | run: npm run dist 33 | - name: Re-vendor GitHub schemas 34 | run: cue cmd vendorgithubschema 35 | - name: Re-gen GitHub Action schema 36 | run: cue cmd genaction 37 | - name: Re-gen GitHub Actions workflows 38 | run: cue cmd genworkflows 39 | - name: Check commit clean 40 | run: test -z "$(git status --porcelain)" || (git status; git diff; false) 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /lib 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `setup-cue` 2 | 3 | ***Install a specific [CUE](https://cuelang.org) CLI version on your GitHub 4 | Actions runner*** 5 | 6 | Use this action in your GitHub Actions workflow to install a specific version of 7 | [CUE](https://cuelang.org) on your runner. The input `version` is a 8 | [version](https://go.dev/ref/mod#versions) string like `v0.6.0`, or 9 | `v0.6.0-beta.1`. You can also use the version query `latest` (default) to use 10 | the latest release of `cue`. Releases and pre-releases of `cue` are listed 11 | [here](https://github.com/cue-lang/cue/releases). 12 | 13 | ``` 14 | - uses: cue-lang/setup-cue@v1.0.0 15 | with: 16 | version: '' # default is latest 17 | id: install 18 | ``` 19 | 20 | The input and output schemas are best described using CUE itself: 21 | 22 | ```cue 23 | #inputs: { 24 | // Version of CUE 25 | version: *"latest" | string 26 | } 27 | 28 | #outputs: { 29 | // Path to the cached CUE binary 30 | "cuectl-path": string 31 | } 32 | ``` 33 | 34 | Please refer to [`action.yml`](action.yml) for more details. 35 | 36 | The cached `cue` binary path is prepended to the `PATH` environment variable and 37 | can be executed directly in later workflow steps. It is also stored in the 38 | `cuectl-path` output variable. 39 | 40 | ## Issues/Discussions 41 | 42 | Please use the [main CUE repository](https://github.com/cue-lang/cue/issues) to 43 | raise issues or start discussions about the `setup-cue` action. 44 | 45 | ## Contributing 46 | 47 | This project follows the [CUE Contribution 48 | Guide](https://github.com/cue-lang/cue/blob/master/CONTRIBUTING.md). 49 | 50 | ## Thanks 51 | 52 | An initial version of this project was graciously donated to the CUE project by 53 | [Christian Bargmann](https://github.com/cbrgm) and the folks from [MOIA 54 | GmbH](https://github.com/moia-oss). 55 | -------------------------------------------------------------------------------- /__tests__/run.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The CUE Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import * as run from '../src/run' 16 | import * as os from 'os'; 17 | import * as toolCache from '@actions/tool-cache'; 18 | import * as fs from 'fs'; 19 | import * as path from 'path'; 20 | import * as core from '@actions/core'; 21 | import * as util from 'util'; 22 | 23 | describe('Testing all functions in run file.', () => { 24 | test('run() must download specified cuectl version and set output', async () => { 25 | jest.spyOn(core, 'getInput').mockReturnValue('v0.4.0'); 26 | jest.spyOn(toolCache, 'find').mockReturnValue('pathToCachedTool'); 27 | jest.spyOn(os, 'type').mockReturnValue('Linux'); 28 | jest.spyOn(fs, 'chmodSync').mockImplementation(); 29 | jest.spyOn(core, 'addPath').mockImplementation(); 30 | jest.spyOn(console, 'log').mockImplementation(); 31 | jest.spyOn(core, 'setOutput').mockImplementation(); 32 | 33 | expect(await run.run()).toBeUndefined(); 34 | expect(core.getInput).toBeCalledWith('version', { 'required': true }); 35 | expect(core.addPath).toBeCalledWith('pathToCachedTool'); 36 | expect(core.setOutput).toBeCalledWith('cuectl-path', path.join('pathToCachedTool', 'cue')); 37 | }); 38 | 39 | test('getExecutableExtension() must return .exe file extension when os equals Windows', () => { 40 | jest.spyOn(os, 'type').mockReturnValue('Windows_NT'); 41 | 42 | expect(run.getExecutableExtension()).toBe('.exe'); 43 | expect(os.type).toBeCalled(); 44 | }); 45 | 46 | test('getExecutableExtension() must return an empty string for non-windows OS', () => { 47 | jest.spyOn(os, 'type').mockReturnValue('Darwin'); 48 | 49 | expect(run.getExecutableExtension()).toBe(''); 50 | expect(os.type).toBeCalled(); 51 | }); 52 | 53 | test.each([ 54 | ['arm', 'arm'], 55 | ['arm64', 'arm64'], 56 | ['x64', 'amd64'] 57 | ])("getCuectlArch() must return on %s os architecture %s cuectl architecture", (osArch, cuectlVersion) => { 58 | jest.spyOn(os, 'arch').mockReturnValue(osArch); 59 | 60 | expect(run.getCuectlOSArchitecture()).toBe(cuectlVersion); 61 | expect(os.arch).toBeCalled(); 62 | }); 63 | 64 | test.each([ 65 | ['arm64'], 66 | ['amd64'] 67 | ])('getCuectlDownloadURL() must return the URL to download %s cuectl for Linux based systems', (arch) => { 68 | jest.spyOn(os, 'type').mockReturnValue('Linux'); 69 | const cuectlLinuxUrl = util.format('https://github.com/cue-lang/cue/releases/download/v0.4.0/cue_v0.4.0_linux_%s.tar.gz', arch); 70 | 71 | expect(run.getCuectlDownloadURL('v0.4.0', arch)).toBe(cuectlLinuxUrl); 72 | expect(os.type).toBeCalled(); 73 | }); 74 | 75 | test.each([ 76 | ['arm64'], 77 | ['amd64'] 78 | ])('getCuectlDownloadURL() must return the URL to download %s cuectl for MacOS based systems', (arch) => { 79 | jest.spyOn(os, 'type').mockReturnValue('Darwin'); 80 | const cuectlDarwinUrl = util.format('https://github.com/cue-lang/cue/releases/download/v0.4.0/cue_v0.4.0_darwin_%s.tar.gz', arch); 81 | 82 | expect(run.getCuectlDownloadURL('v0.4.0', arch)).toBe(cuectlDarwinUrl); 83 | expect(os.type).toBeCalled(); 84 | }); 85 | 86 | test.each([ 87 | ['amd64'] 88 | ])('getCuectlDownloadURL() must return the URL to download %s cuectl for Windows based systems', (arch) => { 89 | jest.spyOn(os, 'type').mockReturnValue('Windows_NT'); 90 | const cuectlWindowsUrl = util.format('https://github.com/cue-lang/cue/releases/download/v0.4.0/cue_v0.4.0_windows_%s.zip', arch); 91 | 92 | expect(run.getCuectlDownloadURL('v0.4.0', arch)).toBe(cuectlWindowsUrl); 93 | expect(os.type).toBeCalled(); 94 | }); 95 | 96 | test('downloadCuectl() must download cuectl tarball, add it to github actions tool cache and return the path to extracted dir', async () => { 97 | jest.spyOn(toolCache, 'find').mockReturnValue(''); 98 | jest.spyOn(toolCache, 'downloadTool').mockReturnValue(Promise.resolve('cuectlDownloadPath')); 99 | jest.spyOn(toolCache, 'extractTar').mockReturnValue(Promise.resolve('cuectlExtractedFolder')); 100 | 101 | jest.spyOn(toolCache, 'cacheDir').mockReturnValue(Promise.resolve('pathToCachedTool')); 102 | jest.spyOn(os, 'type').mockReturnValue('Linux'); 103 | jest.spyOn(fs, 'chmodSync').mockImplementation(() => {}); 104 | 105 | expect(await run.downloadCuectl('v0.4.0')).toBe(path.join('pathToCachedTool', 'cue')); 106 | expect(toolCache.find).toBeCalledWith('cue', 'v0.4.0'); 107 | expect(toolCache.downloadTool).toBeCalled(); 108 | expect(toolCache.cacheDir).toBeCalled(); 109 | expect(os.type).toBeCalled(); 110 | expect(fs.chmodSync).toBeCalledWith(path.join('pathToCachedTool', 'cue'), '777'); 111 | }); 112 | 113 | test('downloadCuectl() must download cuectl zip archive, add it to github actions tool cache and return the path to extracted dir', async () => { 114 | jest.spyOn(toolCache, 'find').mockReturnValue(''); 115 | jest.spyOn(toolCache, 'downloadTool').mockReturnValue(Promise.resolve('cuectlDownloadPath')); 116 | jest.spyOn(toolCache, 'extractZip').mockReturnValue(Promise.resolve('cuectlExtractedFolder')); 117 | 118 | jest.spyOn(toolCache, 'cacheDir').mockReturnValue(Promise.resolve('pathToCachedTool')); 119 | jest.spyOn(os, 'type').mockReturnValue('Windows_NT'); 120 | jest.spyOn(fs, 'chmodSync').mockImplementation(() => {}); 121 | 122 | expect(await run.downloadCuectl('v0.4.0')).toBe(path.join('pathToCachedTool', 'cue.exe')); 123 | expect(toolCache.find).toBeCalledWith('cue', 'v0.4.0'); 124 | expect(toolCache.downloadTool).toBeCalled(); 125 | expect(toolCache.cacheDir).toBeCalled(); 126 | expect(os.type).toBeCalled(); 127 | expect(fs.chmodSync).toBeCalledWith(path.join('pathToCachedTool', 'cue.exe'), '777'); 128 | }); 129 | 130 | test('getLatestCuectlVersion() must download latest version file, read version and return it', async () => { 131 | jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool'); 132 | const response = '{"Version":"v0.5.0","Time":"2023-04-12T11:01:31Z","Origin":{"VCS":"git","URL":"https://review.gerrithub.io/cue-lang/cue","Ref":"refs/tags/v0.5.0","Hash":"d780488159bd082f9f9d027ab42dd4d9b5d95d5e"}}'; 133 | jest.spyOn(fs, 'readFileSync').mockReturnValue(response); 134 | 135 | expect(await run.getLatestCuectlVersion()).toBe('v0.5.0'); 136 | expect(toolCache.downloadTool).toBeCalled(); 137 | expect(fs.readFileSync).toBeCalledWith('pathToTool', 'utf8'); 138 | }); 139 | }) 140 | -------------------------------------------------------------------------------- /action.cue: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import "json.schemastore.org/github" 4 | 5 | action: github.#Action & { 6 | name: "Setup CUE environment" 7 | description: "Setup a CUE environment and add it to the PATH." 8 | inputs: version: { 9 | description: #"The CUE version to setup. Must be a valid version string like "v0.6.0", or "latest""# 10 | required: true 11 | default: "latest" 12 | } 13 | outputs: "cue-path": description: "Path to the cached CUE binary" 14 | branding: { 15 | icon: "terminal" 16 | color: "blue" 17 | } 18 | runs: { 19 | using: "node20" 20 | main: "dist/index.js" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | # Generated by cue cmd genaction; do not edit 2 | 3 | name: Setup CUE environment 4 | description: Setup a CUE environment and add it to the PATH. 5 | inputs: 6 | version: 7 | description: The CUE version to setup. Must be a valid version string like "v0.6.0", or "latest" 8 | required: true 9 | default: latest 10 | outputs: 11 | cue-path: 12 | description: Path to the cached CUE binary 13 | runs: 14 | using: node20 15 | main: dist/index.js 16 | branding: 17 | color: blue 18 | icon: terminal 19 | -------------------------------------------------------------------------------- /action_tool.cue: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "encoding/yaml" 5 | "tool/file" 6 | ) 7 | 8 | // genaction exports the action configuration to action.yml 9 | // 10 | // When the as-yet-unpublished embeding example is implemented, 11 | // this command will become superfluous and could be replaced 12 | // by a cue export call. 13 | command: genaction: file.Create & { 14 | filename: "action.yml" 15 | contents: """ 16 | # Generated by cue cmd genaction; do not edit 17 | 18 | \(yaml.Marshal(action)) 19 | """ 20 | } 21 | -------------------------------------------------------------------------------- /ci_tool.cue: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import ( 4 | "encoding/yaml" 5 | "strings" 6 | "path" 7 | "tool/http" 8 | "tool/file" 9 | "tool/exec" 10 | ) 11 | 12 | _goos: *"unix" | string @tag(os,var=os) 13 | 14 | #repoRoot: exec.Run & { 15 | cmd: "git rev-parse --show-toplevel" 16 | stdout: string 17 | } 18 | 19 | // vendorgithubschema "vendors" 'cue import'-ed versions of the GitHub 20 | // action and workflow schemas into cue.mod/pkg 21 | // 22 | // Under the proposal for CUE packagemanagement, this command is 23 | // redundant. 24 | command: vendorgithubschema: { 25 | repoRoot: #repoRoot 26 | 27 | getActionJSONSchema: http.Get & { 28 | // Tip link for humans: 29 | // https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-action.json 30 | url: "https://raw.githubusercontent.com/SchemaStore/schemastore/c3d4b35e7bbd40b2a95191e393f8c0bad340e97f/src/schemas/json/github-action.json" 31 | } 32 | 33 | importActionJSONSchema: exec.Run & { 34 | stdin: getActionJSONSchema.response.body 35 | cmd: "cue import -f -p github -l #Action: jsonschema: - -o -" 36 | stdout: string 37 | } 38 | 39 | vendorGitHubActionSchema: file.Create & { 40 | _path: path.FromSlash("cue.mod/pkg/json.schemastore.org/github/github-action.cue", "unix") 41 | filename: path.Join([strings.TrimSpace(repoRoot.stdout), _path], _goos) 42 | contents: importActionJSONSchema.stdout 43 | } 44 | 45 | getWorkflowJSONSchema: http.Get & { 46 | // Tip link for humans: 47 | // https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json 48 | url: "https://raw.githubusercontent.com/SchemaStore/schemastore/6fe4707b9d1c5d45cfc8d5b6d56968e65d2bdc38/src/schemas/json/github-workflow.json" 49 | } 50 | 51 | importWorkflowJSONSchema: exec.Run & { 52 | stdin: getWorkflowJSONSchema.response.body 53 | cmd: "cue import -f -p github -l #Workflow: jsonschema: - -o -" 54 | stdout: string 55 | } 56 | 57 | vendorGitHubWorkflowSchema: file.Create & { 58 | _path: path.FromSlash("cue.mod/pkg/json.schemastore.org/github/github-workflow.cue", "unix") 59 | filename: path.Join([strings.TrimSpace(repoRoot.stdout), _path], _goos) 60 | contents: importWorkflowJSONSchema.stdout 61 | } 62 | } 63 | 64 | // genworkflows exports workflow configurations to .yml files. 65 | // 66 | // When the as-yet-unpublished embeding example is implemented, 67 | // this command will become superfluous and could be replaced 68 | // by a cue export call. 69 | command: genworkflows: { 70 | repoRoot: #repoRoot 71 | 72 | for _, w in workflows { 73 | "\(w.filename)": file.Create & { 74 | _path: path.FromSlash(".github/workflows", "unix") 75 | filename: path.Join([strings.TrimSpace(repoRoot.stdout), _path, w.filename], _goos) 76 | contents: """ 77 | # Generated by cue cmd genworkflows; do not edit 78 | 79 | \(yaml.Marshal(w.workflow)) 80 | """ 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /cue.mod/module.cue: -------------------------------------------------------------------------------- 1 | module: "github.com/cue-lang/setup-cue" 2 | -------------------------------------------------------------------------------- /cue.mod/pkg/json.schemastore.org/github/github-action.cue: -------------------------------------------------------------------------------- 1 | package github 2 | 3 | #Action: { 4 | @jsonschema(schema="http://json-schema.org/draft-07/schema#") 5 | @jsonschema(id="https://json.schemastore.org/github-action.json") 6 | 7 | // The name of your action. GitHub displays the `name` in the 8 | // Actions tab to help visually identify actions in each job. 9 | name: string 10 | 11 | // The name of the action's author. 12 | author?: string 13 | 14 | // A short description of the action. 15 | description: string 16 | 17 | // Input parameters allow you to specify data that the action 18 | // expects to use during runtime. GitHub stores input parameters 19 | // as environment variables. Input ids with uppercase letters are 20 | // converted to lowercase during runtime. We recommended using 21 | // lowercase input ids. 22 | inputs?: { 23 | {[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$" & !~"^()$"]: { 24 | // A string description of the input parameter. 25 | description: string 26 | 27 | // A string shown to users using the deprecated input. 28 | deprecationMessage?: string 29 | 30 | // A boolean to indicate whether the action requires the input 31 | // parameter. Set to `true` when the parameter is required. 32 | required?: bool 33 | 34 | // A string representing the default value. The default value is 35 | // used when an input parameter isn't specified in a workflow 36 | // file. 37 | default?: string 38 | }} 39 | } 40 | outputs?: _ 41 | runs: #["runs-javascript"] | #["runs-composite"] | #["runs-docker"] 42 | 43 | // You can use a color and Feather icon to create a badge to 44 | // personalize and distinguish your action. Badges are shown next 45 | // to your action name in GitHub Marketplace. 46 | branding?: { 47 | // The background color of the badge. 48 | color?: "white" | "yellow" | "blue" | "green" | "orange" | "red" | "purple" | "gray-dark" 49 | 50 | // The name of the Feather icon to use. 51 | icon?: "activity" | "airplay" | "alert-circle" | "alert-octagon" | "alert-triangle" | "align-center" | "align-justify" | "align-left" | "align-right" | "anchor" | "aperture" | "archive" | "arrow-down-circle" | "arrow-down-left" | "arrow-down-right" | "arrow-down" | "arrow-left-circle" | "arrow-left" | "arrow-right-circle" | "arrow-right" | "arrow-up-circle" | "arrow-up-left" | "arrow-up-right" | "arrow-up" | "at-sign" | "award" | "bar-chart-2" | "bar-chart" | "battery-charging" | "battery" | "bell-off" | "bell" | "bluetooth" | "bold" | "book-open" | "book" | "bookmark" | "box" | "briefcase" | "calendar" | "camera-off" | "camera" | "cast" | "check-circle" | "check-square" | "check" | "chevron-down" | "chevron-left" | "chevron-right" | "chevron-up" | "chevrons-down" | "chevrons-left" | "chevrons-right" | "chevrons-up" | "circle" | "clipboard" | "clock" | "cloud-drizzle" | "cloud-lightning" | "cloud-off" | "cloud-rain" | "cloud-snow" | "cloud" | "code" | "command" | "compass" | "copy" | "corner-down-left" | "corner-down-right" | "corner-left-down" | "corner-left-up" | "corner-right-down" | "corner-right-up" | "corner-up-left" | "corner-up-right" | "cpu" | "credit-card" | "crop" | "crosshair" | "database" | "delete" | "disc" | "dollar-sign" | "download-cloud" | "download" | "droplet" | "edit-2" | "edit-3" | "edit" | "external-link" | "eye-off" | "eye" | "facebook" | "fast-forward" | "feather" | "file-minus" | "file-plus" | "file-text" | "file" | "film" | "filter" | "flag" | "folder-minus" | "folder-plus" | "folder" | "gift" | "git-branch" | "git-commit" | "git-merge" | "git-pull-request" | "globe" | "grid" | "hard-drive" | "hash" | "headphones" | "heart" | "help-circle" | "home" | "image" | "inbox" | "info" | "italic" | "layers" | "layout" | "life-buoy" | "link-2" | "link" | "list" | "loader" | "lock" | "log-in" | "log-out" | "mail" | "map-pin" | "map" | "maximize-2" | "maximize" | "menu" | "message-circle" | "message-square" | "mic-off" | "mic" | "minimize-2" | "minimize" | "minus-circle" | "minus-square" | "minus" | "monitor" | "moon" | "more-horizontal" | "more-vertical" | "move" | "music" | "navigation-2" | "navigation" | "octagon" | "package" | "paperclip" | "pause-circle" | "pause" | "percent" | "phone-call" | "phone-forwarded" | "phone-incoming" | "phone-missed" | "phone-off" | "phone-outgoing" | "phone" | "pie-chart" | "play-circle" | "play" | "plus-circle" | "plus-square" | "plus" | "pocket" | "power" | "printer" | "radio" | "refresh-ccw" | "refresh-cw" | "repeat" | "rewind" | "rotate-ccw" | "rotate-cw" | "rss" | "save" | "scissors" | "search" | "send" | "server" | "settings" | "share-2" | "share" | "shield-off" | "shield" | "shopping-bag" | "shopping-cart" | "shuffle" | "sidebar" | "skip-back" | "skip-forward" | "slash" | "sliders" | "smartphone" | "speaker" | "square" | "star" | "stop-circle" | "sun" | "sunrise" | "sunset" | "tablet" | "tag" | "target" | "terminal" | "thermometer" | "thumbs-down" | "thumbs-up" | "toggle-left" | "toggle-right" | "trash-2" | "trash" | "trending-down" | "trending-up" | "triangle" | "truck" | "tv" | "type" | "umbrella" | "underline" | "unlock" | "upload-cloud" | "upload" | "user-check" | "user-minus" | "user-plus" | "user-x" | "user" | "users" | "video-off" | "video" | "voicemail" | "volume-1" | "volume-2" | "volume-x" | "volume" | "watch" | "wifi-off" | "wifi" | "wind" | "x-circle" | "x-square" | "x" | "zap-off" | "zap" | "zoom-in" | "zoom-out" 52 | } 53 | 54 | #expressionSyntax: =~""" 55 | ^\\$\\{\\{(.|[\r 56 | ])*\\}\\}$ 57 | """ 58 | 59 | #stringContainingExpressionSyntax: =~""" 60 | ^.*\\$\\{\\{(.|[\r 61 | ])*\\}\\}.*$ 62 | """ 63 | 64 | #: "pre-if": string 65 | 66 | #: "post-if": string 67 | 68 | #: "runs-javascript": { 69 | // The application used to execute the code specified in `main`. 70 | using: "node12" | "node16" | "node20" 71 | 72 | // The file that contains your action code. The application 73 | // specified in `using` executes this file. 74 | main: string 75 | 76 | // Allows you to run a script at the start of a job, before the 77 | // `main:` action begins. For example, you can use `pre:` to run 78 | // a prerequisite setup script. The application specified with 79 | // the `using` syntax will execute this file. The `pre:` action 80 | // always runs by default but you can override this using 81 | // `pre-if`. 82 | pre?: string 83 | "pre-if"?: #["pre-if"] 84 | 85 | // Allows you to run a script at the end of a job, once the 86 | // `main:` action has completed. For example, you can use `post:` 87 | // to terminate certain processes or remove unneeded files. The 88 | // application specified with the `using` syntax will execute 89 | // this file. The `post:` action always runs by default but you 90 | // can override this using `post-if`. 91 | post?: string 92 | "post-if"?: #["post-if"] 93 | } 94 | 95 | #: "runs-composite": { 96 | // To use a composite run steps action, set this to 'composite'. 97 | using: "composite" 98 | 99 | // The run steps that you plan to run in this action. 100 | steps: [...({ 101 | run: _ 102 | shell: _ 103 | ... 104 | } | { 105 | uses: _ 106 | ... 107 | }) & { 108 | // The command you want to run. This can be inline or a script in 109 | // your action repository. 110 | run?: string 111 | 112 | // The shell where you want to run the command. 113 | shell?: (string | ("bash" | "pwsh" | "python" | "sh" | "cmd" | "powershell")) & string 114 | 115 | // Selects an action to run as part of a step in your job. 116 | uses?: string 117 | 118 | // A map of the input parameters defined by the action. Each input 119 | // parameter is a key/value pair. Input parameters are set as 120 | // environment variables. The variable is prefixed with INPUT_ 121 | // and converted to upper case. 122 | with?: { 123 | ... 124 | } 125 | 126 | // The name of the composite run step. 127 | name?: string 128 | 129 | // A unique identifier for the step. You can use the `id` to 130 | // reference the step in contexts. 131 | id?: string 132 | 133 | // You can use the if conditional to prevent a step from running 134 | // unless a condition is met. You can use any supported context 135 | // and expression to create a conditional. 136 | // Expressions in an if conditional do not require the ${{ }} 137 | // syntax. For more information, see 138 | // https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions. 139 | if?: string 140 | 141 | // Sets a map of environment variables for only that step. 142 | env?: { 143 | [string]: string 144 | } 145 | 146 | // Prevents a job from failing when a step fails. Set to true to 147 | // allow a job to pass when this step fails. 148 | "continue-on-error"?: bool | #expressionSyntax | *false 149 | 150 | // Specifies the working directory where the command is run. 151 | "working-directory"?: string 152 | }] 153 | } 154 | 155 | #: "runs-docker": { 156 | // You must set this value to 'docker'. 157 | using: "docker" 158 | 159 | // The Docker image to use as the container to run the action. The 160 | // value can be the Docker base image name, a local `Dockerfile` 161 | // in your repository, or a public image in Docker Hub or another 162 | // registry. To reference a `Dockerfile` local to your 163 | // repository, use a path relative to your action metadata file. 164 | // The `docker` application will execute this file. 165 | image: string 166 | 167 | // Specifies a key/value map of environment variables to set in 168 | // the container environment. 169 | env?: { 170 | [string]: bool | number | string 171 | } | #stringContainingExpressionSyntax 172 | 173 | // Overrides the Docker `ENTRYPOINT` in the `Dockerfile`, or sets 174 | // it if one wasn't already specified. Use `entrypoint` when the 175 | // `Dockerfile` does not specify an `ENTRYPOINT` or you want to 176 | // override the `ENTRYPOINT` instruction. If you omit 177 | // `entrypoint`, the commands you specify in the Docker 178 | // `ENTRYPOINT` instruction will execute. The Docker `ENTRYPOINT 179 | // instruction has a *shell* form and *exec* form. The Docker 180 | // `ENTRYPOINT` documentation recommends using the *exec* form of 181 | // the `ENTRYPOINT` instruction. 182 | entrypoint?: string 183 | 184 | // Allows you to run a script before the `entrypoint` action 185 | // begins. For example, you can use `pre-entrypoint:` to run a 186 | // prerequisite setup script. GitHub Actions uses `docker run` to 187 | // launch this action, and runs the script inside a new container 188 | // that uses the same base image. This means that the runtime 189 | // state is different from the main `entrypoint` container, and 190 | // any states you require must be accessed in either the 191 | // workspace, `HOME`, or as a `STATE_` variable. The 192 | // `pre-entrypoint:` action always runs by default but you can 193 | // override this using `pre-if`. 194 | "pre-entrypoint"?: string 195 | "pre-if"?: #["pre-if"] 196 | 197 | // Allows you to run a cleanup script once the `runs.entrypoint` 198 | // action has completed. GitHub Actions uses `docker run` to 199 | // launch this action. Because GitHub Actions runs the script 200 | // inside a new container using the same base image, the runtime 201 | // state is different from the main `entrypoint` container. You 202 | // can access any state you need in either the workspace, `HOME`, 203 | // or as a `STATE_` variable. The `post-entrypoint:` action 204 | // always runs by default but you can override this using 205 | // `post-if`. 206 | "post-entrypoint"?: string 207 | "post-if"?: #["post-if"] 208 | 209 | // An array of strings that define the inputs for a Docker 210 | // container. Inputs can include hardcoded strings. GitHub passes 211 | // the `args` to the container's `ENTRYPOINT` when the container 212 | // starts up. 213 | // The `args` are used in place of the `CMD` instruction in a 214 | // `Dockerfile`. If you use `CMD` in your `Dockerfile`, use the 215 | // guidelines ordered by preference: 216 | // - Document required arguments in the action's README and omit 217 | // them from the `CMD` instruction. 218 | // - Use defaults that allow using the action without specifying 219 | // any `args`. 220 | // - If the action exposes a `--help` flag, or something similar, 221 | // use that to make your action self-documenting. 222 | args?: [...string] 223 | } 224 | 225 | #outputs: { 226 | {[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$" & !~"^()$"]: { 227 | // A string description of the output parameter. 228 | description: string 229 | }} 230 | } 231 | 232 | #: "outputs-composite": { 233 | {[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$" & !~"^()$"]: { 234 | // A string description of the output parameter. 235 | description: string 236 | 237 | // The value that the output parameter will be mapped to. You can 238 | // set this to a string or an expression with context. For 239 | // example, you can use the steps context to set the value of an 240 | // output to the output value of a step. 241 | value: string 242 | }} 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /cue.mod/pkg/json.schemastore.org/github/github-workflow.cue: -------------------------------------------------------------------------------- 1 | package github 2 | 3 | import "strings" 4 | 5 | #Workflow: { 6 | @jsonschema(schema="http://json-schema.org/draft-07/schema") 7 | null | bool | number | string | [...] | { 8 | // The name of your workflow. GitHub displays the names of your 9 | // workflows on your repository's actions page. If you omit this 10 | // field, GitHub sets the name to the workflow's filename. 11 | name?: string 12 | 13 | // The name of the GitHub event that triggers the workflow. You 14 | // can provide a single event string, array of events, array of 15 | // event types, or an event configuration map that schedules a 16 | // workflow or restricts the execution of a workflow to specific 17 | // files, tags, or branch changes. For a list of available 18 | // events, see 19 | // https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows. 20 | on: #event | [...#event] & [_, ...] | { 21 | // Runs your workflow anytime the check_run event occurs. More 22 | // than one activity type triggers this event. For information 23 | // about the REST API, see 24 | // https://developer.github.com/v3/checks/runs. 25 | check_run?: #eventObject & { 26 | types?: #types & [..."created" | "rerequested" | "completed" | "requested_action"] | *["created", "rerequested", "completed", "requested_action"] 27 | ... 28 | } 29 | 30 | // Runs your workflow anytime the check_suite event occurs. More 31 | // than one activity type triggers this event. For information 32 | // about the REST API, see 33 | // https://developer.github.com/v3/checks/suites/. 34 | check_suite?: #eventObject & { 35 | types?: #types & [..."completed" | "requested" | "rerequested"] | *["completed", "requested", "rerequested"] 36 | ... 37 | } 38 | 39 | // Runs your workflow anytime someone creates a branch or tag, 40 | // which triggers the create event. For information about the 41 | // REST API, see 42 | // https://developer.github.com/v3/git/refs/#create-a-reference. 43 | create?: #eventObject 44 | 45 | // Runs your workflow anytime someone deletes a branch or tag, 46 | // which triggers the delete event. For information about the 47 | // REST API, see 48 | // https://developer.github.com/v3/git/refs/#delete-a-reference. 49 | delete?: #eventObject 50 | 51 | // Runs your workflow anytime someone creates a deployment, which 52 | // triggers the deployment event. Deployments created with a 53 | // commit SHA may not have a Git ref. For information about the 54 | // REST API, see 55 | // https://developer.github.com/v3/repos/deployments/. 56 | deployment?: #eventObject 57 | 58 | // Runs your workflow anytime a third party provides a deployment 59 | // status, which triggers the deployment_status event. 60 | // Deployments created with a commit SHA may not have a Git ref. 61 | // For information about the REST API, see 62 | // https://developer.github.com/v3/repos/deployments/#create-a-deployment-status. 63 | deployment_status?: #eventObject 64 | 65 | // Runs your workflow anytime when someone forks a repository, 66 | // which triggers the fork event. For information about the REST 67 | // API, see 68 | // https://developer.github.com/v3/repos/forks/#create-a-fork. 69 | fork?: #eventObject 70 | 71 | // Runs your workflow when someone creates or updates a Wiki page, 72 | // which triggers the gollum event. 73 | gollum?: #eventObject 74 | 75 | // Runs your workflow anytime the issue_comment event occurs. More 76 | // than one activity type triggers this event. For information 77 | // about the REST API, see 78 | // https://developer.github.com/v3/issues/comments/. 79 | issue_comment?: #eventObject & { 80 | types?: #types & [..."created" | "edited" | "deleted"] | *["created", "edited", "deleted"] 81 | ... 82 | } 83 | 84 | // Runs your workflow anytime the issues event occurs. More than 85 | // one activity type triggers this event. For information about 86 | // the REST API, see https://developer.github.com/v3/issues. 87 | issues?: #eventObject & { 88 | types?: #types & [..."opened" | "edited" | "deleted" | "transferred" | "pinned" | "unpinned" | "closed" | "reopened" | "assigned" | "unassigned" | "labeled" | "unlabeled" | "locked" | "unlocked" | "milestoned" | "demilestoned"] | *["opened", "edited", "deleted", "transferred", "pinned", "unpinned", "closed", "reopened", "assigned", "unassigned", "labeled", "unlabeled", "locked", "unlocked", "milestoned", "demilestoned"] 89 | ... 90 | } 91 | 92 | // Runs your workflow anytime the label event occurs. More than 93 | // one activity type triggers this event. For information about 94 | // the REST API, see 95 | // https://developer.github.com/v3/issues/labels/. 96 | label?: #eventObject & { 97 | types?: #types & [..."created" | "edited" | "deleted"] | *["created", "edited", "deleted"] 98 | ... 99 | } 100 | 101 | // Runs your workflow anytime the member event occurs. More than 102 | // one activity type triggers this event. For information about 103 | // the REST API, see 104 | // https://developer.github.com/v3/repos/collaborators/. 105 | member?: #eventObject & { 106 | types?: #types & [..."added" | "edited" | "deleted"] | *["added", "edited", "deleted"] 107 | ... 108 | } 109 | 110 | // Runs your workflow anytime the milestone event occurs. More 111 | // than one activity type triggers this event. For information 112 | // about the REST API, see 113 | // https://developer.github.com/v3/issues/milestones/. 114 | milestone?: #eventObject & { 115 | types?: #types & [..."created" | "closed" | "opened" | "edited" | "deleted"] | *["created", "closed", "opened", "edited", "deleted"] 116 | ... 117 | } 118 | 119 | // Runs your workflow anytime someone pushes to a GitHub 120 | // Pages-enabled branch, which triggers the page_build event. For 121 | // information about the REST API, see 122 | // https://developer.github.com/v3/repos/pages/. 123 | page_build?: #eventObject 124 | 125 | // Runs your workflow anytime the project event occurs. More than 126 | // one activity type triggers this event. For information about 127 | // the REST API, see https://developer.github.com/v3/projects/. 128 | project?: #eventObject & { 129 | types?: #types & [..."created" | "updated" | "closed" | "reopened" | "edited" | "deleted"] | *["created", "updated", "closed", "reopened", "edited", "deleted"] 130 | ... 131 | } 132 | 133 | // Runs your workflow anytime the project_card event occurs. More 134 | // than one activity type triggers this event. For information 135 | // about the REST API, see 136 | // https://developer.github.com/v3/projects/cards. 137 | project_card?: #eventObject & { 138 | types?: #types & [..."created" | "moved" | "converted" | "edited" | "deleted"] | *["created", "moved", "converted", "edited", "deleted"] 139 | ... 140 | } 141 | 142 | // Runs your workflow anytime the project_column event occurs. 143 | // More than one activity type triggers this event. For 144 | // information about the REST API, see 145 | // https://developer.github.com/v3/projects/columns. 146 | project_column?: #eventObject & { 147 | types?: #types & [..."created" | "updated" | "moved" | "deleted"] | *["created", "updated", "moved", "deleted"] 148 | ... 149 | } 150 | 151 | // Runs your workflow anytime someone makes a private repository 152 | // public, which triggers the public event. For information about 153 | // the REST API, see https://developer.github.com/v3/repos/#edit. 154 | public?: #eventObject 155 | 156 | // Runs your workflow anytime the pull_request event occurs. More 157 | // than one activity type triggers this event. For information 158 | // about the REST API, see https://developer.github.com/v3/pulls. 159 | // Note: Workflows do not run on private base repositories when 160 | // you open a pull request from a forked repository. 161 | // When you create a pull request from a forked repository to the 162 | // base repository, GitHub sends the pull_request event to the 163 | // base repository and no pull request events occur on the forked 164 | // repository. 165 | // Workflows don't run on forked repositories by default. You must 166 | // enable GitHub Actions in the Actions tab of the forked 167 | // repository. 168 | // The permissions for the GITHUB_TOKEN in forked repositories is 169 | // read-only. For more information about the GITHUB_TOKEN, see 170 | // https://help.github.com/en/articles/virtual-environments-for-github-actions. 171 | pull_request?: #ref & { 172 | types?: #types & [..."assigned" | "unassigned" | "labeled" | "unlabeled" | "opened" | "edited" | "closed" | "reopened" | "synchronize" | "ready_for_review" | "locked" | "unlocked" | "review_requested" | "review_request_removed"] | *["opened", "synchronize", "reopened"] 173 | 174 | {[=~"^(branche|tag|path)s(-ignore)?$" & !~"^(types)$"]: _} 175 | } 176 | 177 | // Runs your workflow anytime the pull_request_review event 178 | // occurs. More than one activity type triggers this event. For 179 | // information about the REST API, see 180 | // https://developer.github.com/v3/pulls/reviews. 181 | // Note: Workflows do not run on private base repositories when 182 | // you open a pull request from a forked repository. 183 | // When you create a pull request from a forked repository to the 184 | // base repository, GitHub sends the pull_request event to the 185 | // base repository and no pull request events occur on the forked 186 | // repository. 187 | // Workflows don't run on forked repositories by default. You must 188 | // enable GitHub Actions in the Actions tab of the forked 189 | // repository. 190 | // The permissions for the GITHUB_TOKEN in forked repositories is 191 | // read-only. For more information about the GITHUB_TOKEN, see 192 | // https://help.github.com/en/articles/virtual-environments-for-github-actions. 193 | pull_request_review?: #eventObject & { 194 | types?: #types & [..."submitted" | "edited" | "dismissed"] | *["submitted", "edited", "dismissed"] 195 | ... 196 | } 197 | 198 | // Runs your workflow anytime a comment on a pull request's 199 | // unified diff is modified, which triggers the 200 | // pull_request_review_comment event. More than one activity type 201 | // triggers this event. For information about the REST API, see 202 | // https://developer.github.com/v3/pulls/comments. 203 | // Note: Workflows do not run on private base repositories when 204 | // you open a pull request from a forked repository. 205 | // When you create a pull request from a forked repository to the 206 | // base repository, GitHub sends the pull_request event to the 207 | // base repository and no pull request events occur on the forked 208 | // repository. 209 | // Workflows don't run on forked repositories by default. You must 210 | // enable GitHub Actions in the Actions tab of the forked 211 | // repository. 212 | // The permissions for the GITHUB_TOKEN in forked repositories is 213 | // read-only. For more information about the GITHUB_TOKEN, see 214 | // https://help.github.com/en/articles/virtual-environments-for-github-actions. 215 | pull_request_review_comment?: #eventObject & { 216 | types?: #types & [..."created" | "edited" | "deleted"] | *["created", "edited", "deleted"] 217 | ... 218 | } 219 | 220 | // This event is similar to pull_request, except that it runs in 221 | // the context of the base repository of the pull request, rather 222 | // than in the merge commit. This means that you can more safely 223 | // make your secrets available to the workflows triggered by the 224 | // pull request, because only workflows defined in the commit on 225 | // the base repository are run. For example, this event allows 226 | // you to create workflows that label and comment on pull 227 | // requests, based on the contents of the event payload. 228 | pull_request_target?: #ref & { 229 | types?: #types & [..."assigned" | "unassigned" | "labeled" | "unlabeled" | "opened" | "edited" | "closed" | "reopened" | "synchronize" | "ready_for_review" | "locked" | "unlocked" | "review_requested" | "review_request_removed"] | *["opened", "synchronize", "reopened"] 230 | 231 | {[=~"^(branche|tag|path)s(-ignore)?$" & !~"^(types)$"]: _} 232 | } 233 | 234 | // Runs your workflow when someone pushes to a repository branch, 235 | // which triggers the push event. 236 | // Note: The webhook payload available to GitHub Actions does not 237 | // include the added, removed, and modified attributes in the 238 | // commit object. You can retrieve the full commit object using 239 | // the REST API. For more information, see 240 | // https://developer.github.com/v3/repos/commits/#get-a-single-commit. 241 | push?: #ref & { 242 | {[=~"^(branche|tag|path)s(-ignore)?$" & !~"^()$"]: _} 243 | } 244 | 245 | // Runs your workflow anytime a package is published or updated. 246 | // For more information, see 247 | // https://help.github.com/en/github/managing-packages-with-github-packages. 248 | registry_package?: #eventObject & { 249 | types?: #types & [..."published" | "updated"] | *["published", "updated"] 250 | ... 251 | } 252 | 253 | // Runs your workflow anytime the release event occurs. More than 254 | // one activity type triggers this event. For information about 255 | // the REST API, see 256 | // https://developer.github.com/v3/repos/releases/ in the GitHub 257 | // Developer documentation. 258 | release?: #eventObject & { 259 | types?: #types & [..."published" | "unpublished" | "created" | "edited" | "deleted" | "prereleased" | "released"] | *["published", "unpublished", "created", "edited", "deleted", "prereleased", "released"] 260 | ... 261 | } 262 | 263 | // Runs your workflow anytime the status of a Git commit changes, 264 | // which triggers the status event. For information about the 265 | // REST API, see https://developer.github.com/v3/repos/statuses/. 266 | status?: #eventObject 267 | 268 | // Runs your workflow anytime the watch event occurs. More than 269 | // one activity type triggers this event. For information about 270 | // the REST API, see 271 | // https://developer.github.com/v3/activity/starring/. 272 | watch?: #eventObject 273 | 274 | // You can now create workflows that are manually triggered with 275 | // the new workflow_dispatch event. You will then see a 'Run 276 | // workflow' button on the Actions tab, enabling you to easily 277 | // trigger a run. 278 | workflow_dispatch?: null | bool | number | string | [...] | { 279 | // Input parameters allow you to specify data that the action 280 | // expects to use during runtime. GitHub stores input parameters 281 | // as environment variables. Input ids with uppercase letters are 282 | // converted to lowercase during runtime. We recommended using 283 | // lowercase input ids. 284 | inputs?: { 285 | {[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$" & !~"^()$"]: { 286 | // A string description of the input parameter. 287 | description: string 288 | 289 | // A string shown to users using the deprecated input. 290 | deprecationMessage?: string 291 | 292 | // A boolean to indicate whether the action requires the input 293 | // parameter. Set to true when the parameter is required. 294 | required: bool 295 | 296 | // A string representing the default value. The default value is 297 | // used when an input parameter isn't specified in a workflow 298 | // file. 299 | default?: string 300 | }} 301 | } 302 | ... 303 | } 304 | 305 | // This event occurs when a workflow run is requested or 306 | // completed, and allows you to execute a workflow based on the 307 | // finished result of another workflow. For example, if your 308 | // pull_request workflow generates build artifacts, you can 309 | // create a new workflow that uses workflow_run to analyze the 310 | // results and add a comment to the original pull request. 311 | workflow_run?: #eventObject & { 312 | types?: #types & [..."requested" | "completed"] | *["requested", "completed"] 313 | workflows?: [...string] & [_, ...] 314 | 315 | {[=~"^branches(-ignore)?$" & !~"^(types|workflows)$"]: _} 316 | ... 317 | } 318 | 319 | // You can use the GitHub API to trigger a webhook event called 320 | // repository_dispatch when you want to trigger a workflow for 321 | // activity that happens outside of GitHub. For more information, 322 | // see 323 | // https://developer.github.com/v3/repos/#create-a-repository-dispatch-event. 324 | // To trigger the custom repository_dispatch webhook event, you 325 | // must send a POST request to a GitHub API endpoint and provide 326 | // an event_type name to describe the activity type. To trigger a 327 | // workflow run, you must also configure your workflow to use the 328 | // repository_dispatch event. 329 | repository_dispatch?: #eventObject 330 | 331 | // You can schedule a workflow to run at specific UTC times using 332 | // POSIX cron syntax 333 | // (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07). 334 | // Scheduled workflows run on the latest commit on the default or 335 | // base branch. The shortest interval you can run scheduled 336 | // workflows is once every 5 minutes. 337 | // Note: GitHub Actions does not support the non-standard syntax 338 | // @yearly, @monthly, @weekly, @daily, @hourly, and @reboot. 339 | // You can use crontab guru (https://crontab.guru/). to help 340 | // generate your cron syntax and confirm what time it will run. 341 | // To help you get started, there is also a list of crontab guru 342 | // examples (https://crontab.guru/examples.html). 343 | schedule?: [...null | bool | number | string | [...] | { 344 | cron?: =~"^(((\\d+,)+\\d+|((\\d+|\\*)\\/\\d+|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)|(\\d+-\\d+)|\\d+|\\*|MON|TUE|WED|THU|FRI|SAT|SUN) ?){5,7}$" 345 | }] & [_, ...] 346 | } 347 | 348 | // A map of environment variables that are available to all jobs 349 | // and steps in the workflow. 350 | env?: #env 351 | 352 | // A map of default settings that will apply to all jobs in the 353 | // workflow. 354 | defaults?: #defaults 355 | 356 | // A workflow run is made up of one or more jobs. Jobs run in 357 | // parallel by default. To run jobs sequentially, you can define 358 | // dependencies on other jobs using the jobs..needs 359 | // keyword. 360 | // Each job runs in a fresh instance of the virtual environment 361 | // specified by runs-on. 362 | // You can run an unlimited number of jobs as long as you are 363 | // within the workflow usage limits. For more information, see 364 | // https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#usage-limits. 365 | jobs: { 366 | {[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$" & !~"^()$"]: { 367 | // The name of the job displayed on GitHub. 368 | name?: string 369 | 370 | // Identifies any jobs that must complete successfully before this 371 | // job will run. It can be a string or array of strings. If a job 372 | // fails, all jobs that need it are skipped unless the jobs use a 373 | // conditional statement that causes the job to continue. 374 | needs?: [...#name] & [_, ...] | #name 375 | 376 | // The type of machine to run the job on. The machine can be 377 | // either a GitHub-hosted runner, or a self-hosted runner. 378 | "runs-on": "macos-10.15" | "macos-11.0" | "macos-latest" | "self-hosted" | "ubuntu-16.04" | "ubuntu-18.04" | "ubuntu-20.04" | "ubuntu-latest" | "windows-2016" | "windows-2019" | "windows-latest" | (["self-hosted"] | ["self-hosted", #machine] | ["self-hosted", #architecture] | ["self-hosted", #machine, #architecture] | ["self-hosted", #architecture, #machine]) & [...] | #expressionSyntax 379 | 380 | // The environment that the job references. 381 | environment?: string | #environment 382 | 383 | // A map of outputs for a job. Job outputs are available to all 384 | // downstream jobs that depend on this job. 385 | outputs?: { 386 | [string]: string 387 | } 388 | 389 | // A map of environment variables that are available to all steps 390 | // in the job. 391 | env?: #env 392 | 393 | // A map of default settings that will apply to all steps in the 394 | // job. 395 | defaults?: #defaults 396 | 397 | // You can use the if conditional to prevent a job from running 398 | // unless a condition is met. You can use any supported context 399 | // and expression to create a conditional. 400 | // Expressions in an if conditional do not require the ${{ }} 401 | // syntax. For more information, see 402 | // https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions. 403 | if?: string 404 | 405 | // A job contains a sequence of tasks called steps. Steps can run 406 | // commands, run setup tasks, or run an action in your 407 | // repository, a public repository, or an action published in a 408 | // Docker registry. Not all steps run actions, but all actions 409 | // run as a step. Each step runs in its own process in the 410 | // virtual environment and has access to the workspace and 411 | // filesystem. Because steps run in their own process, changes to 412 | // environment variables are not preserved between steps. GitHub 413 | // provides built-in steps to set up and complete a job. 414 | steps?: [...{ 415 | // A unique identifier for the step. You can use the id to 416 | // reference the step in contexts. For more information, see 417 | // https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions. 418 | id?: string 419 | 420 | // You can use the if conditional to prevent a step from running 421 | // unless a condition is met. You can use any supported context 422 | // and expression to create a conditional. 423 | // Expressions in an if conditional do not require the ${{ }} 424 | // syntax. For more information, see 425 | // https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions. 426 | if?: string 427 | 428 | // A name for your step to display on GitHub. 429 | name?: string 430 | 431 | // Selects an action to run as part of a step in your job. An 432 | // action is a reusable unit of code. You can use an action 433 | // defined in the same repository as the workflow, a public 434 | // repository, or in a published Docker container image 435 | // (https://hub.docker.com/). 436 | // We strongly recommend that you include the version of the 437 | // action you are using by specifying a Git ref, SHA, or Docker 438 | // tag number. If you don't specify a version, it could break 439 | // your workflows or cause unexpected behavior when the action 440 | // owner publishes an update. 441 | // - Using the commit SHA of a released action version is the 442 | // safest for stability and security. 443 | // - Using the specific major action version allows you to receive 444 | // critical fixes and security patches while still maintaining 445 | // compatibility. It also assures that your workflow should still 446 | // work. 447 | // - Using the master branch of an action may be convenient, but 448 | // if someone releases a new major version with a breaking 449 | // change, your workflow could break. 450 | // Some actions require inputs that you must set using the with 451 | // keyword. Review the action's README file to determine the 452 | // inputs required. 453 | // Actions are either JavaScript files or Docker containers. If 454 | // the action you're using is a Docker container you must run the 455 | // job in a Linux virtual environment. For more details, see 456 | // https://help.github.com/en/articles/virtual-environments-for-github-actions. 457 | uses?: string 458 | 459 | // Runs command-line programs using the operating system's shell. 460 | // If you do not provide a name, the step name will default to 461 | // the text specified in the run command. 462 | // Commands run using non-login shells by default. You can choose 463 | // a different shell and customize the shell used to run 464 | // commands. For more information, see 465 | // https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell. 466 | // Each run keyword represents a new process and shell in the 467 | // virtual environment. When you provide multi-line commands, 468 | // each line runs in the same shell. 469 | run?: string, "working-directory"?: #["working-directory"], shell?: #shell 470 | 471 | // A map of the input parameters defined by the action. Each input 472 | // parameter is a key/value pair. Input parameters are set as 473 | // environment variables. The variable is prefixed with INPUT_ 474 | // and converted to upper case. 475 | with?: #env & { 476 | args?: string, entrypoint?: string, ... 477 | } 478 | 479 | // Sets environment variables for steps to use in the virtual 480 | // environment. You can also set environment variables for the 481 | // entire workflow or a job. 482 | env?: #env 483 | 484 | // Prevents a job from failing when a step fails. Set to true to 485 | // allow a job to pass when this step fails. 486 | "continue-on-error"?: bool | #expressionSyntax | *false 487 | 488 | // The maximum number of minutes to run the step before killing 489 | // the process. 490 | "timeout-minutes"?: number 491 | }] & [_, ...] 492 | 493 | // The maximum number of minutes to let a workflow run before 494 | // GitHub automatically cancels it. Default: 360 495 | "timeout-minutes"?: number | *360 496 | 497 | // A strategy creates a build matrix for your jobs. You can define 498 | // different variations of an environment to run each job in. 499 | strategy?: { 500 | // A build matrix is a set of different configurations of the 501 | // virtual environment. For example you might run a job against 502 | // more than one supported version of a language, operating 503 | // system, or tool. Each configuration is a copy of the job that 504 | // runs and reports a status. 505 | // You can specify a matrix by supplying an array for the 506 | // configuration options. For example, if the GitHub virtual 507 | // environment supports Node.js versions 6, 8, and 10 you could 508 | // specify an array of those versions in the matrix. 509 | // When you define a matrix of operating systems, you must set the 510 | // required runs-on keyword to the operating system of the 511 | // current job, rather than hard-coding the operating system 512 | // name. To access the operating system name, you can use the 513 | // matrix.os context parameter to set runs-on. For more 514 | // information, see 515 | // https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions. 516 | matrix: ({ 517 | ... 518 | } | #expressionSyntax) & { 519 | {[=~"^(in|ex)clude$" & !~"^()$"]: [...{ 520 | [string]: #configuration 521 | }] & [_, ...]} 522 | {[!~"^(in|ex)clude$" & !~"^()$"]: [...#configuration] & [_, ...]} 523 | } 524 | 525 | // When set to true, GitHub cancels all in-progress jobs if any 526 | // matrix job fails. Default: true 527 | "fail-fast"?: bool | *true 528 | 529 | // The maximum number of jobs that can run simultaneously when 530 | // using a matrix job strategy. By default, GitHub will maximize 531 | // the number of jobs run in parallel depending on the available 532 | // runners on GitHub-hosted virtual machines. 533 | "max-parallel"?: number 534 | } 535 | 536 | // Prevents a workflow run from failing when a job fails. Set to 537 | // true to allow a workflow run to pass when this job fails. 538 | "continue-on-error"?: bool | #expressionSyntax 539 | 540 | // A container to run any steps in a job that don't already 541 | // specify a container. If you have steps that use both script 542 | // and container actions, the container actions will run as 543 | // sibling containers on the same network with the same volume 544 | // mounts. 545 | // If you do not set a container, all steps will run directly on 546 | // the host specified by runs-on unless a step refers to an 547 | // action configured to run in a container. 548 | container?: string | #container 549 | 550 | // Additional containers to host services for a job in a workflow. 551 | // These are useful for creating databases or cache services like 552 | // redis. The runner on the virtual machine will automatically 553 | // create a network and manage the life cycle of the service 554 | // containers. 555 | // When you use a service container for a job or your step uses 556 | // container actions, you don't need to set port information to 557 | // access the service. Docker automatically exposes all ports 558 | // between containers on the same network. 559 | // When both the job and the action run in a container, you can 560 | // directly reference the container by its hostname. The hostname 561 | // is automatically mapped to the service name. 562 | // When a step does not use a container action, you must access 563 | // the service using localhost and bind the ports. 564 | services?: { 565 | [string]: #container 566 | } 567 | }} 568 | } 569 | } 570 | 571 | #architecture: "ARM32" | "x64" | "x86" 572 | 573 | #branch: #globs 574 | 575 | #configuration: string | number | bool | { 576 | [string]: #configuration 577 | } | [...#configuration] 578 | 579 | #container: { 580 | // The Docker image to use as the container to run the action. The 581 | // value can be the Docker Hub image name or a registry name. 582 | image: string 583 | 584 | // If the image's container registry requires authentication to 585 | // pull the image, you can use credentials to set a map of the 586 | // username and password. The credentials are the same values 587 | // that you would provide to the `docker login` command. 588 | credentials?: { 589 | username?: string 590 | password?: string 591 | ... 592 | } 593 | 594 | // Sets an array of environment variables in the container. 595 | env?: #env 596 | 597 | // Sets an array of ports to expose on the container. 598 | ports?: [...number | string] & [_, ...] 599 | 600 | // Sets an array of volumes for the container to use. You can use 601 | // volumes to share data between services or other steps in a 602 | // job. You can specify named Docker volumes, anonymous Docker 603 | // volumes, or bind mounts on the host. 604 | // To specify a volume, you specify the source and destination 605 | // path: : 606 | // The is a volume name or an absolute path on the host 607 | // machine, and is an absolute path in the 608 | // container. 609 | volumes?: [...=~"^[^:]+:[^:]+$"] & [_, ...] 610 | 611 | // Additional Docker container resource options. For a list of 612 | // options, see 613 | // https://docs.docker.com/engine/reference/commandline/create/#options. 614 | options?: string 615 | } 616 | 617 | #defaults: run?: { 618 | shell?: #shell 619 | "working-directory"?: #["working-directory"] 620 | } 621 | 622 | #env: [string]: bool | number | string 623 | 624 | #environment: { 625 | // The name of the environment configured in the repo. 626 | name: string 627 | 628 | // A deployment URL 629 | url?: string 630 | } 631 | 632 | #event: "check_run" | "check_suite" | "create" | "delete" | "deployment" | "deployment_status" | "fork" | "gollum" | "issue_comment" | "issues" | "label" | "member" | "milestone" | "page_build" | "project" | "project_card" | "project_column" | "public" | "pull_request" | "pull_request_review" | "pull_request_review_comment" | "pull_request_target" | "push" | "registry_package" | "release" | "status" | "watch" | "workflow_dispatch" | "workflow_run" | "repository_dispatch" 633 | 634 | #eventObject: null | { 635 | ... 636 | } 637 | 638 | #expressionSyntax: =~"^\\$\\{\\{.*\\}\\}$" 639 | 640 | #globs: [...strings.MinRunes(1)] & [_, ...] 641 | 642 | #machine: "linux" | "macos" | "windows" 643 | 644 | #name: =~"^[_a-zA-Z][a-zA-Z0-9_-]*$" 645 | 646 | #path: #globs 647 | 648 | #ref: null | { 649 | branches?: #branch 650 | "branches-ignore"?: #branch 651 | tags?: #branch 652 | "tags-ignore"?: #branch 653 | paths?: #path 654 | "paths-ignore"?: #path 655 | ... 656 | } 657 | 658 | #shell: (string | ("bash" | "pwsh" | "python" | "sh" | "cmd" | "powershell")) & string 659 | 660 | #types: [_, ...] 661 | 662 | #: "working-directory": string 663 | } 664 | -------------------------------------------------------------------------------- /dist/LICENSE: -------------------------------------------------------------------------------- 1 | @actions/core 2 | MIT 3 | The MIT License (MIT) 4 | 5 | Copyright 2019 GitHub 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | @actions/exec 14 | MIT 15 | The MIT License (MIT) 16 | 17 | Copyright 2019 GitHub 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | @actions/http-client 26 | MIT 27 | Actions Http Client for Node.js 28 | 29 | Copyright (c) GitHub, Inc. 30 | 31 | All rights reserved. 32 | 33 | MIT License 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 36 | associated documentation files (the "Software"), to deal in the Software without restriction, 37 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 38 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 39 | subject to the following conditions: 40 | 41 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 44 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 45 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 46 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 47 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 48 | 49 | 50 | @actions/io 51 | MIT 52 | The MIT License (MIT) 53 | 54 | Copyright 2019 GitHub 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 57 | 58 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 59 | 60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 61 | 62 | @actions/tool-cache 63 | MIT 64 | The MIT License (MIT) 65 | 66 | Copyright 2019 GitHub 67 | 68 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 69 | 70 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 71 | 72 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 73 | 74 | @fastify/busboy 75 | MIT 76 | Copyright Brian White. All rights reserved. 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy 79 | of this software and associated documentation files (the "Software"), to 80 | deal in the Software without restriction, including without limitation the 81 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 82 | sell copies of the Software, and to permit persons to whom the Software is 83 | furnished to do so, subject to the following conditions: 84 | 85 | The above copyright notice and this permission notice shall be included in 86 | all copies or substantial portions of the Software. 87 | 88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 93 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 94 | IN THE SOFTWARE. 95 | 96 | @vercel/ncc 97 | MIT 98 | Copyright 2018 ZEIT, Inc. 99 | 100 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 101 | 102 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 103 | 104 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 105 | 106 | semver 107 | ISC 108 | The ISC License 109 | 110 | Copyright (c) Isaac Z. Schlueter and Contributors 111 | 112 | Permission to use, copy, modify, and/or distribute this software for any 113 | purpose with or without fee is hereby granted, provided that the above 114 | copyright notice and this permission notice appear in all copies. 115 | 116 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 117 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 118 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 119 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 120 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 121 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 122 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 123 | 124 | 125 | tunnel 126 | MIT 127 | The MIT License (MIT) 128 | 129 | Copyright (c) 2012 Koichi Kobayashi 130 | 131 | Permission is hereby granted, free of charge, to any person obtaining a copy 132 | of this software and associated documentation files (the "Software"), to deal 133 | in the Software without restriction, including without limitation the rights 134 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 135 | copies of the Software, and to permit persons to whom the Software is 136 | furnished to do so, subject to the following conditions: 137 | 138 | The above copyright notice and this permission notice shall be included in 139 | all copies or substantial portions of the Software. 140 | 141 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 142 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 143 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 144 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 145 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 146 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 147 | THE SOFTWARE. 148 | 149 | 150 | undici 151 | MIT 152 | MIT License 153 | 154 | Copyright (c) Matteo Collina and Undici contributors 155 | 156 | Permission is hereby granted, free of charge, to any person obtaining a copy 157 | of this software and associated documentation files (the "Software"), to deal 158 | in the Software without restriction, including without limitation the rights 159 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 160 | copies of the Software, and to permit persons to whom the Software is 161 | furnished to do so, subject to the following conditions: 162 | 163 | The above copyright notice and this permission notice shall be included in all 164 | copies or substantial portions of the Software. 165 | 166 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 169 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 170 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 171 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 172 | SOFTWARE. 173 | 174 | 175 | uuid 176 | MIT 177 | The MIT License (MIT) 178 | 179 | Copyright (c) 2010-2020 Robert Kieffer and other contributors 180 | 181 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 182 | 183 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 184 | 185 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 186 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The CUE Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | module.exports = { 16 | clearMocks: true, 17 | moduleFileExtensions: ['js', 'ts'], 18 | testEnvironment: 'node', 19 | testMatch: ['**/*.test.ts'], 20 | transform: { 21 | '^.+\\.ts$': 'ts-jest' 22 | }, 23 | verbose: false, 24 | coverageThreshold: { 25 | "global": { 26 | "branches": 0, 27 | "functions": 10, 28 | "lines": 25, 29 | "statements": 25 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "setup-cue", 3 | "version": "0.0.0", 4 | "description": "Install CUE on your runner using Github Actions", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "build": "tsc --outDir ./lib --rootDir ./src", 8 | "test": "jest", 9 | "test-coverage": "jest --coverage", 10 | "dist": "ncc build src/run.ts --license LICENSE" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/cue-lang/setup-cue.git" 15 | }, 16 | "keywords": [ 17 | "eks" 18 | ], 19 | "author": "cbrgm", 20 | "license": "Apache 2.0", 21 | "devDependencies": { 22 | "@types/jest": "27.5.2", 23 | "@types/node": "20.11.10", 24 | "@types/semver": "7.3.13", 25 | "@vercel/ncc": "0.33.4", 26 | "jest": "29.0.0", 27 | "ts-jest": "29.1.2", 28 | "typescript": "5.3.3" 29 | }, 30 | "dependencies": { 31 | "@actions/core": "1.10.0", 32 | "@actions/exec": "1.1.1", 33 | "@actions/tool-cache": "1.7.2" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/run.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The CUE Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import * as os from 'os'; 16 | import * as path from 'path'; 17 | import * as util from 'util'; 18 | import * as fs from 'fs'; 19 | 20 | import * as toolCache from '@actions/tool-cache'; 21 | import * as core from '@actions/core'; 22 | 23 | const cuectlToolName = 'cue'; 24 | const cuectlLatestReleaseUrl = 'https://proxy.golang.org/cuelang.org/go/@latest'; 25 | 26 | export function getExecutableExtension(): string { 27 | if (os.type().match(/^Win/)) { 28 | return '.exe'; 29 | } 30 | return ''; 31 | } 32 | 33 | export function getCuectlOSArchitecture(): string { 34 | let arch = os.arch(); 35 | if (arch === 'x64') { 36 | return 'amd64'; 37 | } 38 | return arch; 39 | } 40 | 41 | export async function getLatestCuectlVersion(): Promise { 42 | try { 43 | const downloadPath = await toolCache.downloadTool(cuectlLatestReleaseUrl); 44 | const response = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim()); 45 | return response.Version; 46 | } catch (error) { 47 | throw new Error(util.format("Cannot get the latest cue releases infos from %s. Error %s.", cuectlLatestReleaseUrl, error)); 48 | } 49 | } 50 | 51 | export function getCuectlDownloadURL(version: string, arch: string): string { 52 | switch (os.type()) { 53 | case 'Linux': 54 | return util.format('https://github.com/cue-lang/cue/releases/download/%s/cue_%s_linux_%s.tar.gz', version, version, arch); 55 | 56 | case 'Darwin': 57 | return util.format('https://github.com/cue-lang/cue/releases/download/%s/cue_%s_darwin_%s.tar.gz', version, version, arch); 58 | 59 | case 'Windows_NT': 60 | default: 61 | return util.format('https://github.com/cue-lang/cue/releases/download/%s/cue_%s_windows_%s.zip', version, version, arch); 62 | 63 | } 64 | } 65 | 66 | export async function downloadCuectl(version: string): Promise { 67 | if (!version) { version = await getLatestCuectlVersion(); } 68 | let cachedToolpath = toolCache.find(cuectlToolName, version); 69 | let cuectlDownloadPath = ''; 70 | let extractedCuectlPath = ''; 71 | let arch = getCuectlOSArchitecture(); 72 | if (!cachedToolpath) { 73 | try { 74 | cuectlDownloadPath = await toolCache.downloadTool(getCuectlDownloadURL(version, arch)); 75 | if(os.type() === 'Windows_NT') { 76 | extractedCuectlPath = await toolCache.extractZip(cuectlDownloadPath); 77 | } else { 78 | extractedCuectlPath = await toolCache.extractTar(cuectlDownloadPath); 79 | } 80 | } catch (exception) { 81 | if (exception instanceof toolCache.HTTPError && exception.httpStatusCode === 404) { 82 | throw new Error(util.format("Cuectl '%s' for '%s' arch not found.", version, arch)); 83 | } else { 84 | throw new Error('DownloadCuectlFailed'); 85 | } 86 | } 87 | 88 | let toolName = cuectlToolName + getExecutableExtension() 89 | cachedToolpath = await toolCache.cacheDir(extractedCuectlPath, toolName, cuectlToolName, version); 90 | } 91 | 92 | const cuectlPath = path.join(cachedToolpath, cuectlToolName + getExecutableExtension()); 93 | fs.chmodSync(cuectlPath, '777'); 94 | return cuectlPath; 95 | } 96 | 97 | export async function run() { 98 | let version = core.getInput('version', { 'required': true }); 99 | if (version.toLocaleLowerCase() === 'latest') { 100 | version = await getLatestCuectlVersion(); 101 | } 102 | 103 | core.debug(util.format("Downloading CUE version %s", version)); 104 | let cachedCuectlPath = await downloadCuectl(version); 105 | 106 | core.addPath(path.dirname(cachedCuectlPath)); 107 | 108 | console.log(`CUE binary version: '${version}' has been cached at ${cachedCuectlPath}`); 109 | core.setOutput('cuectl-path', cachedCuectlPath); 110 | } 111 | 112 | 113 | run().catch(core.setFailed); 114 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "module": "commonjs" 5 | }, 6 | "exclude": [ 7 | "node_modules", 8 | "__tests__" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /workflows.cue: -------------------------------------------------------------------------------- 1 | package action 2 | 3 | import "json.schemastore.org/github" 4 | 5 | workflows: [...{ 6 | filename: string 7 | workflow: github.#Workflow 8 | }] 9 | workflows: [ 10 | { 11 | filename: "build-and-test.yml" 12 | workflow: buildAndTest 13 | }, 14 | ] 15 | 16 | buildAndTest: github.#Workflow & { 17 | name: "build and test" 18 | on: { 19 | pull_request: types: [ 20 | "opened", 21 | "synchronize", 22 | ] 23 | push: branches: [ 24 | "main", 25 | ] 26 | } 27 | 28 | jobs: build: { 29 | "runs-on": "ubuntu-latest" 30 | steps: [ 31 | { 32 | name: "Checkout" 33 | uses: "actions/checkout@v4" 34 | }, 35 | { 36 | name: "Use node.js 20.x" 37 | uses: "actions/setup-node@v4" 38 | with: "node-version": 20 39 | }, 40 | { 41 | name: "Use CUE" 42 | uses: "./" 43 | with: version: "v0.7.1" 44 | }, 45 | { 46 | name: "Check CUE version" 47 | run: "cue version" 48 | }, 49 | { 50 | name: "Run tests" 51 | run: """ 52 | npm ci 53 | 54 | """ 55 | }, 56 | { 57 | name: "Build" 58 | run: "npm run dist" 59 | }, 60 | { 61 | name: "Re-vendor GitHub schemas" 62 | run: "cue cmd vendorgithubschema" 63 | }, 64 | { 65 | name: "Re-gen GitHub Action schema" 66 | run: "cue cmd genaction" 67 | }, 68 | { 69 | name: "Re-gen GitHub Actions workflows" 70 | run: "cue cmd genworkflows" 71 | }, 72 | { 73 | name: "Check commit clean" 74 | run: "test -z \"$(git status --porcelain)\" || (git status; git diff; false)" 75 | }, 76 | ] 77 | } 78 | } 79 | --------------------------------------------------------------------------------