|
1 |
| -# Create a JavaScript Action |
| 1 | +# setup-swiftwasm |
2 | 2 |
|
3 |
| -<p align="center"> |
4 |
| - <a href="https://github.com/actions/javascript-action/actions"><img alt="javscript-action status" src="https://github.com/actions/javascript-action/workflows/units-test/badge.svg"></a> |
5 |
| -</p> |
| 3 | +A GitHub Action that downloads a SwiftWasm toolchain and adds it to the `PATH`. |
6 | 4 |
|
7 |
| -Use this template to bootstrap the creation of a JavaScript action.:rocket: |
8 | 5 |
|
9 |
| -This template includes tests, linting, a validation workflow, publishing, and versioning guidance. |
10 |
| - |
11 |
| -If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) |
12 |
| - |
13 |
| -## Create an action from this template |
14 |
| - |
15 |
| -Click the `Use this Template` and provide the new repo details for your action |
16 |
| - |
17 |
| -## Code in Main |
18 |
| - |
19 |
| -Install the dependencies |
20 |
| - |
21 |
| -```bash |
22 |
| -npm install |
23 |
| -``` |
24 |
| - |
25 |
| -Run the tests :heavy_check_mark: |
26 |
| - |
27 |
| -```bash |
28 |
| -$ npm test |
29 |
| - |
30 |
| - PASS ./index.test.js |
31 |
| - ✓ throws invalid number (3ms) |
32 |
| - ✓ wait 500 ms (504ms) |
33 |
| - ✓ test runs (95ms) |
34 |
| -... |
35 |
| -``` |
36 |
| - |
37 |
| -## Change action.yml |
38 |
| - |
39 |
| -The action.yml defines the inputs and output for your action. |
40 |
| - |
41 |
| -Update the action.yml with your name, description, inputs and outputs for your action. |
42 |
| - |
43 |
| -See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) |
44 |
| - |
45 |
| -## Change the Code |
46 |
| - |
47 |
| -Most toolkit and CI/CD operations involve async operations so the action is run in an async function. |
48 |
| - |
49 |
| -```javascript |
50 |
| -const core = require('@actions/core'); |
51 |
| -... |
52 |
| - |
53 |
| -async function run() { |
54 |
| - try { |
55 |
| - ... |
56 |
| - } |
57 |
| - catch (error) { |
58 |
| - core.setFailed(error.message); |
59 |
| - } |
60 |
| -} |
61 |
| - |
62 |
| -run() |
63 |
| -``` |
64 |
| - |
65 |
| -See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. |
66 |
| - |
67 |
| -## Package for distribution |
68 |
| - |
69 |
| -GitHub Actions will run the entry point from the action.yml. Packaging assembles the code into one file that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules. |
70 |
| - |
71 |
| -Actions are run from GitHub repos. Packaging the action will create a packaged action in the dist folder. |
| 6 | +## Usage |
72 | 7 |
|
73 |
| -Run prepare |
| 8 | +To run the action with the latest SwiftWasm toolchain, add the following to your workflow file: |
74 | 9 |
|
75 |
| -```bash |
76 |
| -npm run prepare |
| 10 | +```yaml |
| 11 | +- uses: swiftwasm/setup-swiftwasm@v1 |
| 12 | +- run: swift --version # `swift` command in SwiftWasm |
77 | 13 | ```
|
78 | 14 |
|
79 |
| -Since the packaged index.js is run from the dist folder. |
| 15 | +A specific toolchain version can be specified with the `swift-version` input: |
80 | 16 |
|
81 |
| -```bash |
82 |
| -git add dist |
| 17 | +```yaml |
| 18 | +- uses: swiftwasm/setup-swiftwasm@v1 |
| 19 | + with: |
| 20 | + swift-version: "wasm-5.6.0-RELEASE" |
83 | 21 | ```
|
84 | 22 |
|
85 |
| -## Create a release branch |
86 |
| - |
87 |
| -Users shouldn't consume the action from master since that would be latest code and actions can break compatibility between major versions. |
88 |
| - |
89 |
| -Checkin to the v1 release branch |
| 23 | +You can also specify nightly toolchains: |
90 | 24 |
|
91 |
| -```bash |
92 |
| -git checkout -b v1 |
93 |
| -git commit -a -m "v1 release" |
94 |
| -``` |
95 |
| - |
96 |
| -```bash |
97 |
| -git push origin v1 |
| 25 | +```yaml |
| 26 | +- uses: swiftwasm/setup-swiftwasm@v1 |
| 27 | + with: |
| 28 | + swift-version: "wasm-DEVELOPMENT-SNAPSHOT-2022-10-04-a" |
98 | 29 | ```
|
99 | 30 |
|
100 |
| -Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project. |
101 |
| - |
102 |
| -Your action is now published! :rocket: |
103 |
| - |
104 |
| -See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) |
| 31 | +You can find the list of available toolchain versions on the [SwiftWasm Releases page](https://github.com/swiftwasm/swift/releases). |
105 | 32 |
|
106 |
| -## Usage |
107 |
| - |
108 |
| -You can now consume the action by referencing the v1 branch |
109 |
| - |
110 |
| -```yaml |
111 |
| -uses: actions/javascript-action@v1 |
112 |
| -with: |
113 |
| - milliseconds: 1000 |
114 |
| -``` |
| 33 | +## Supported Platforms |
115 | 34 |
|
116 |
| -See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket: |
| 35 | +The action currently supports macOS and Ubuntu runners. |
0 commit comments