|
1 | | -# Create a GitHub Action Using TypeScript |
| 1 | +# Deploy Lua Plugin |
2 | 2 |
|
3 | 3 | [](https://github.com/super-linter/super-linter) |
4 | 4 |  |
5 | 5 | [](https://github.com/actions/typescript-action/actions/workflows/check-dist.yml) |
6 | 6 | [](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml) |
7 | 7 | [](./badges/coverage.svg) |
8 | 8 |
|
9 | | -Use this template to bootstrap the creation of a TypeScript action. :rocket: |
| 9 | +An action to help you deploy your Qt Creator Lua extension to the Qt Creator |
| 10 | +Extension Store. |
10 | 11 |
|
11 | | -This template includes compilation support, tests, a validation workflow, |
12 | | -publishing, and versioning guidance. |
| 12 | +## Getting started |
13 | 13 |
|
14 | | -If you are new, there's also a simpler introduction in the |
15 | | -[Hello world JavaScript action repository](https://github.com/actions/hello-world-javascript-action). |
| 14 | +Once you have prepare your Lua extension for deployment, you can use this action |
| 15 | +to deploy it to the Qt Creator Extension Store. |
16 | 16 |
|
17 | | -## Create Your Own Action |
18 | | - |
19 | | -To create your own action, you can use this repository as a template! Just |
20 | | -follow the below instructions: |
21 | | - |
22 | | -1. Click the **Use this template** button at the top of the repository |
23 | | -1. Select **Create a new repository** |
24 | | -1. Select an owner and name for your new repository |
25 | | -1. Click **Create repository** |
26 | | -1. Clone your new repository |
27 | | - |
28 | | -> [!IMPORTANT] |
29 | | -> |
30 | | -> Make sure to remove or update the [`CODEOWNERS`](./CODEOWNERS) file! For |
31 | | -> details on how to use this file, see |
32 | | -> [About code owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners). |
33 | | -
|
34 | | -## Initial Setup |
35 | | - |
36 | | -After you've cloned the repository to your local machine or codespace, you'll |
37 | | -need to perform some initial setup steps before you can develop your action. |
38 | | - |
39 | | -> [!NOTE] |
40 | | -> |
41 | | -> You'll need to have a reasonably modern version of |
42 | | -> [Node.js](https://nodejs.org) handy (20.x or later should work!). If you are |
43 | | -> using a version manager like [`nodenv`](https://github.com/nodenv/nodenv) or |
44 | | -> [`nvm`](https://github.com/nvm-sh/nvm), this template has a `.node-version` |
45 | | -> file at the root of the repository that will be used to automatically switch |
46 | | -> to the correct version when you `cd` into the repository. Additionally, this |
47 | | -> `.node-version` file is used by GitHub Actions in any `actions/setup-node` |
48 | | -> actions. |
49 | | -
|
50 | | -1. :hammer_and_wrench: Install the dependencies |
51 | | - |
52 | | - ```bash |
53 | | - npm install |
54 | | - ``` |
55 | | - |
56 | | -1. :building_construction: Package the TypeScript for distribution |
57 | | - |
58 | | - ```bash |
59 | | - npm run bundle |
60 | | - ``` |
61 | | - |
62 | | -1. :white_check_mark: Run the tests |
63 | | - |
64 | | - ```bash |
65 | | - $ npm test |
66 | | - |
67 | | - PASS ./index.test.js |
68 | | - ✓ throws invalid number (3ms) |
69 | | - ✓ wait 500 ms (504ms) |
70 | | - ✓ test runs (95ms) |
71 | | - |
72 | | - ... |
73 | | - ``` |
74 | | - |
75 | | -## Update the Action Metadata |
76 | | - |
77 | | -The [`action.yml`](action.yml) file defines metadata about your action, such as |
78 | | -input(s) and output(s). For details about this file, see |
79 | | -[Metadata syntax for GitHub Actions](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions). |
80 | | - |
81 | | -When you copy this repository, update `action.yml` with the name, description, |
82 | | -inputs, and outputs for your action. |
83 | | - |
84 | | -## Update the Action Code |
85 | | - |
86 | | -The [`src/`](./src/) directory is the heart of your action! This contains the |
87 | | -source code that will be run when your action is invoked. You can replace the |
88 | | -contents of this directory with your own code. |
89 | | - |
90 | | -There are a few things to keep in mind when writing your action code: |
91 | | - |
92 | | -- Most GitHub Actions toolkit and CI/CD operations are processed asynchronously. |
93 | | - In `main.ts`, you will see that the action is run in an `async` function. |
94 | | - |
95 | | - ```javascript |
96 | | - import * as core from '@actions/core' |
97 | | - //... |
98 | | - |
99 | | - async function run() { |
100 | | - try { |
101 | | - //... |
102 | | - } catch (error) { |
103 | | - core.setFailed(error.message) |
104 | | - } |
105 | | - } |
106 | | - ``` |
107 | | - |
108 | | - For more information about the GitHub Actions toolkit, see the |
109 | | - [documentation](https://github.com/actions/toolkit/blob/master/README.md). |
110 | | - |
111 | | -So, what are you waiting for? Go ahead and start customizing your action! |
112 | | - |
113 | | -1. Create a new branch |
114 | | - |
115 | | - ```bash |
116 | | - git checkout -b releases/v1 |
117 | | - ``` |
118 | | - |
119 | | -1. Replace the contents of `src/` with your action code |
120 | | -1. Add tests to `__tests__/` for your source code |
121 | | -1. Format, test, and build the action |
122 | | - |
123 | | - ```bash |
124 | | - npm run all |
125 | | - ``` |
126 | | - |
127 | | - > This step is important! It will run [`ncc`](https://github.com/vercel/ncc) |
128 | | - > to build the final JavaScript action code with all dependencies included. |
129 | | - > If you do not run this step, your action will not work correctly when it is |
130 | | - > used in a workflow. This step also includes the `--license` option for |
131 | | - > `ncc`, which will create a license file for all of the production node |
132 | | - > modules used in your project. |
133 | | -
|
134 | | -1. Commit your changes |
135 | | - |
136 | | - ```bash |
137 | | - git add . |
138 | | - git commit -m "My first action is ready!" |
139 | | - ``` |
140 | | - |
141 | | -1. Push them to your repository |
142 | | - |
143 | | - ```bash |
144 | | - git push -u origin releases/v1 |
145 | | - ``` |
146 | | - |
147 | | -1. Create a pull request and get feedback on your action |
148 | | -1. Merge the pull request into the `main` branch |
149 | | - |
150 | | -Your action is now published! :rocket: |
151 | | - |
152 | | -For information about versioning your action, see |
153 | | -[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) |
154 | | -in the GitHub Actions toolkit. |
155 | | - |
156 | | -## Validate the Action |
157 | | - |
158 | | -You can now validate the action by referencing it in a workflow file. For |
159 | | -example, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference an |
160 | | -action in the same repository. |
161 | | - |
162 | | -```yaml |
163 | | -steps: |
164 | | - - name: Checkout |
165 | | - id: checkout |
166 | | - uses: actions/checkout@v4 |
167 | | - |
168 | | - - name: Test Local Action |
169 | | - id: test-action |
170 | | - uses: ./ |
171 | | - with: |
172 | | - milliseconds: 1000 |
173 | | - |
174 | | - - name: Print Output |
175 | | - id: output |
176 | | - run: echo "${{ steps.test-action.outputs.time }}" |
177 | | -``` |
178 | | -
|
179 | | -For example workflow runs, check out the |
180 | | -[Actions tab](https://github.com/actions/typescript-action/actions)! :rocket: |
181 | | -
|
182 | | -## Usage |
183 | | -
|
184 | | -After testing, you can create version tag(s) that developers can use to |
185 | | -reference different stable versions of your action. For more information, see |
186 | | -[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) |
187 | | -in the GitHub Actions toolkit. |
188 | | -
|
189 | | -To include the action in a workflow in another repository, you can use the |
190 | | -`uses` syntax with the `@` symbol to reference a specific branch, tag, or commit |
191 | | -hash. |
| 17 | +You will need to have an [API token (TBA)](http://link-to-api-token-settings) |
| 18 | +from the Qt Creator Extension Store. |
192 | 19 |
|
193 | 20 | ```yaml |
194 | | -steps: |
195 | | - - name: Checkout |
196 | | - id: checkout |
197 | | - uses: actions/checkout@v4 |
198 | | -
|
199 | | - - name: Test Local Action |
200 | | - id: test-action |
201 | | - uses: actions/typescript-action@v1 # Commit with the `v1` tag |
202 | | - with: |
203 | | - milliseconds: 1000 |
204 | | - |
205 | | - - name: Print Output |
206 | | - id: output |
207 | | - run: echo "${{ steps.test-action.outputs.time }}" |
| 21 | +- name: Release on Extension Store |
| 22 | + |
| 23 | + with: |
| 24 | + token: ${{ secrets.EXTENSION_STORE_API_TOKEN }} |
| 25 | + spec: MyPlugin/myplugin.lua |
| 26 | + download-url: http://example.com/my-plugin.zip |
208 | 27 | ``` |
209 | 28 |
|
210 | | -## Publishing a New Release |
211 | | -
|
212 | | -This project includes a helper script, [`script/release`](./script/release) |
213 | | -designed to streamline the process of tagging and pushing new releases for |
214 | | -GitHub Actions. |
215 | | - |
216 | | -GitHub Actions allows users to select a specific version of the action to use, |
217 | | -based on release tags. This script simplifies this process by performing the |
218 | | -following steps: |
219 | | - |
220 | | -1. **Retrieving the latest release tag:** The script starts by fetching the most |
221 | | - recent SemVer release tag of the current branch, by looking at the local data |
222 | | - available in your repository. |
223 | | -1. **Prompting for a new release tag:** The user is then prompted to enter a new |
224 | | - release tag. To assist with this, the script displays the tag retrieved in |
225 | | - the previous step, and validates the format of the inputted tag (vX.X.X). The |
226 | | - user is also reminded to update the version field in package.json. |
227 | | -1. **Tagging the new release:** The script then tags a new release and syncs the |
228 | | - separate major tag (e.g. v1, v2) with the new release tag (e.g. v1.0.0, |
229 | | - v2.1.2). When the user is creating a new major release, the script |
230 | | - auto-detects this and creates a `releases/v#` branch for the previous major |
231 | | - version. |
232 | | -1. **Pushing changes to remote:** Finally, the script pushes the necessary |
233 | | - commits, tags and branches to the remote repository. From here, you will need |
234 | | - to create a new release in GitHub so users can easily reference the new tags |
235 | | - in their workflows. |
| 29 | +You can use the "Qt Creator Lua Plugin" template in Qt Creator to get a full |
| 30 | +example of a ci workflow file. |
0 commit comments