Skip to content

Commit f2aba91

Browse files
authored
Merge pull request #3 from pollenjp/release/v1
release/v1
2 parents d5fb1ed + 537f457 commit f2aba91

File tree

19 files changed

+3088
-476
lines changed

19 files changed

+3088
-476
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,15 @@ jobs:
4646

4747
test-action:
4848
name: GitHub Actions Test
49-
runs-on: ubuntu-latest
50-
49+
strategy:
50+
matrix:
51+
host: [ubuntu-latest, macos-latest, windows-latest]
52+
version: [latest, 3.10.0]
53+
runs-on: ${{ matrix.host }}
5154
steps:
52-
- name: Checkout
53-
id: checkout
54-
uses: actions/checkout@v4
55-
56-
- name: Test Local Action
57-
id: test-action
58-
uses: ./
55+
- uses: actions/checkout@v4
56+
- uses: ./
5957
with:
60-
milliseconds: 2000
61-
62-
- name: Print Output
63-
id: output
64-
run: echo "${{ steps.test-action.outputs.time }}"
58+
version: ${{ matrix.version }}
59+
- name: check
60+
run: shfmt --version

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 21.6.2

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Repository CODEOWNERS
22

3-
* @actions/actions-oss-maintainers
3+
* @pollenjp

LICENSE

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
MIT License
22

3+
Copyright (c) 2024 pollenJP
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
---
24+
25+
MIT License
26+
327
Copyright GitHub
428

529
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -18,4 +42,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1842
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1943
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2044
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
45+
SOFTWARE.

README.md

Lines changed: 2 additions & 262 deletions
Original file line numberDiff line numberDiff line change
@@ -1,263 +1,3 @@
1-
# Create a GitHub Action Using TypeScript
1+
# setup-shfmt
22

3-
[![GitHub Super-Linter](https://github.com/actions/typescript-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)
4-
![CI](https://github.com/actions/typescript-action/actions/workflows/ci.yml/badge.svg)
5-
[![Check dist/](https://github.com/actions/typescript-action/actions/workflows/check-dist.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/check-dist.yml)
6-
[![CodeQL](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml)
7-
[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)
8-
9-
Use this template to bootstrap the creation of a TypeScript action. :rocket:
10-
11-
This template includes compilation support, tests, a validation workflow,
12-
publishing, and versioning guidance.
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).
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-
> [`fnm`](https://github.com/Schniz/fnm), this template has a `.node-version`
45-
> file at the root of the repository that can be used to automatically switch to
46-
> 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. (Optional) Test your action locally
135-
136-
The [`@github/local-action`](https://github.com/github/local-action) utility
137-
can be used to test your action locally. It is a simple command-line tool
138-
that "stubs" (or simulates) the GitHub Actions Toolkit. This way, you can run
139-
your TypeScript action locally without having to commit and push your changes
140-
to a repository.
141-
142-
The `local-action` utility can be run in the following ways:
143-
144-
- Visual Studio Code Debugger
145-
146-
Make sure to review and, if needed, update
147-
[`.vscode/launch.json`](./.vscode/launch.json)
148-
149-
- Terminal/Command Prompt
150-
151-
```bash
152-
# npx local action <action-yaml-path> <entrypoint> <dotenv-file>
153-
npx local-action . src/main.ts .env
154-
```
155-
156-
You can provide a `.env` file to the `local-action` CLI to set environment
157-
variables used by the GitHub Actions Toolkit. For example, setting inputs and
158-
event payload data used by your action. For more information, see the example
159-
file, [`.env.example`](./.env.example), and the
160-
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).
161-
162-
1. Commit your changes
163-
164-
```bash
165-
git add .
166-
git commit -m "My first action is ready!"
167-
```
168-
169-
1. Push them to your repository
170-
171-
```bash
172-
git push -u origin releases/v1
173-
```
174-
175-
1. Create a pull request and get feedback on your action
176-
1. Merge the pull request into the `main` branch
177-
178-
Your action is now published! :rocket:
179-
180-
For information about versioning your action, see
181-
[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
182-
in the GitHub Actions toolkit.
183-
184-
## Validate the Action
185-
186-
You can now validate the action by referencing it in a workflow file. For
187-
example, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference an
188-
action in the same repository.
189-
190-
```yaml
191-
steps:
192-
- name: Checkout
193-
id: checkout
194-
uses: actions/checkout@v4
195-
196-
- name: Test Local Action
197-
id: test-action
198-
uses: ./
199-
with:
200-
milliseconds: 1000
201-
202-
- name: Print Output
203-
id: output
204-
run: echo "${{ steps.test-action.outputs.time }}"
205-
```
206-
207-
For example workflow runs, check out the
208-
[Actions tab](https://github.com/actions/typescript-action/actions)! :rocket:
209-
210-
## Usage
211-
212-
After testing, you can create version tag(s) that developers can use to
213-
reference different stable versions of your action. For more information, see
214-
[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
215-
in the GitHub Actions toolkit.
216-
217-
To include the action in a workflow in another repository, you can use the
218-
`uses` syntax with the `@` symbol to reference a specific branch, tag, or commit
219-
hash.
220-
221-
```yaml
222-
steps:
223-
- name: Checkout
224-
id: checkout
225-
uses: actions/checkout@v4
226-
227-
- name: Test Local Action
228-
id: test-action
229-
uses: actions/typescript-action@v1 # Commit with the `v1` tag
230-
with:
231-
milliseconds: 1000
232-
233-
- name: Print Output
234-
id: output
235-
run: echo "${{ steps.test-action.outputs.time }}"
236-
```
237-
238-
## Publishing a New Release
239-
240-
This project includes a helper script, [`script/release`](./script/release)
241-
designed to streamline the process of tagging and pushing new releases for
242-
GitHub Actions.
243-
244-
GitHub Actions allows users to select a specific version of the action to use,
245-
based on release tags. This script simplifies this process by performing the
246-
following steps:
247-
248-
1. **Retrieving the latest release tag:** The script starts by fetching the most
249-
recent SemVer release tag of the current branch, by looking at the local data
250-
available in your repository.
251-
1. **Prompting for a new release tag:** The user is then prompted to enter a new
252-
release tag. To assist with this, the script displays the tag retrieved in
253-
the previous step, and validates the format of the inputted tag (vX.X.X). The
254-
user is also reminded to update the version field in package.json.
255-
1. **Tagging the new release:** The script then tags a new release and syncs the
256-
separate major tag (e.g. v1, v2) with the new release tag (e.g. v1.0.0,
257-
v2.1.2). When the user is creating a new major release, the script
258-
auto-detects this and creates a `releases/v#` branch for the previous major
259-
version.
260-
1. **Pushing changes to remote:** Finally, the script pushes the necessary
261-
commits, tags and branches to the remote repository. From here, you will need
262-
to create a new release in GitHub so users can easily reference the new tags
263-
in their workflows.
3+
- Install shfmt and cache it for GitHub Actions

0 commit comments

Comments
 (0)