Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial release #3

Merged
merged 12 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 23 additions & 40 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the

Check warning on line 1 in .devcontainer/devcontainer.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "GitHub Actions (TypeScript)",
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
"postCreateCommand": "npm install",
"customizations": {
"codespaces": {
"openFiles": ["README.md"]
},
"vscode": {
"extensions": [
"bierner.markdown-preview-github-styles",
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"github.copilot",
"github.copilot-chat",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"me-dutour-mathieu.vscode-github-actions",
"redhat.vscode-yaml",
"rvest.vs-code-prettier-eslint",
"yzhang.markdown-all-in-one"
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"markdown.extension.list.indentationSize": "adaptive",
"markdown.extension.italic.indicator": "_",
"markdown.extension.orderedList.marker": "one"
}
}
},
"remoteEnv": {
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
},
"features": {
"ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers-contrib/features/prettier:1": {}
}
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
8 changes: 7 additions & 1 deletion .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ jobs:
id: checkout
uses: actions/checkout@v4

- name: Parse Tool Versions
id: tool-versions-action
uses: ./
with:
file: .tool-versions

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
node-version: ${{ steps.tool-versions-action.outputs.nodejs-version }}
cache: npm

- name: Install Dependencies
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ jobs:
id: checkout
uses: actions/checkout@v4

- name: Parse Tool Versions
id: tool-versions-action
uses: ./
with:
file: .tool-versions

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
node-version: ${{ steps.tool-versions-action.outputs.nodejs-version }}
cache: npm

- name: Install Dependencies
Expand Down Expand Up @@ -53,12 +59,12 @@ jobs:
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
- name: Test Action
id: tool-versions-action
uses: ./
with:
milliseconds: 2000
file: .tool-versions

- name: Print Output
- name: Print NodeJS Version Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
run: echo "NodeJS Version ${{ steps.tool-versions-action.outputs.nodejs-version }}"
8 changes: 7 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ jobs:
with:
fetch-depth: 0

- name: Parse Tool Versions
id: tool-versions-action
uses: ./
with:
file: .tool-versions

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
node-version: ${{ steps.tool-versions-action.outputs.nodejs-version }}
cache: npm

- name: Install Dependencies
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.11.0
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Repository CODEOWNERS

* @actions/actions-oss-maintainers
* @AGS4NO
144 changes: 144 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Tool Versions Action

Clone the repository:

```shell
git clone git@github.com/AGS4NO/tool-versions-action
cd tool-versions-action
```

## Setup

After you've cloned the repository to your local machine or codespace, you'll
need to perform some initial setup steps before you can develop this action.

> [!NOTE]
>
> You'll need to have a reasonably modern version of
> [Node.js](https://nodejs.org) handy (20.x or later should work!). If you are
> using a version manager like [`nodenv`](https://github.com/nodenv/nodenv) or
> [`nvm`](https://github.com/nvm-sh/nvm), this template has a `.node-version`
> file at the root of the repository that will be used to automatically switch
> to the correct version when you `cd` into the repository. Additionally, this
> `.node-version` file is used by GitHub Actions in any `actions/setup-node`
> actions.

1. :hammer_and_wrench: Install the dependencies

```bash
npm install
```

1. :building_construction: Package the TypeScript for distribution

```bash
npm run bundle
```

1. :white_check_mark: Run the tests

```bash
$ npm test

Test Suites: 2 passed, 2 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 2.93 s, estimated 3 s

...
```

## Update the Action Code

1. Create a new branch

```bash
git checkout -b releases/v1
```

1. Update the contents of `src/`
1. Add tests to `__tests__/` for your source code
1. Format, test, and build the action

```bash
npm run all
```

> [!WARNING]
>
> This step is important! It will run [`ncc`](https://github.com/vercel/ncc)
> to build the final JavaScript action code with all dependencies included.
> If you do not run this step, this action will not work correctly when it is
> used in a workflow. This step also includes the `--license` option for
> `ncc`, which will create a license file for all of the production node
> modules used in this project.

1. Commit your changes

```bash
git add .
git commit -m "Release v1"
```

1. Push them to the repository

```bash
git push -u origin releases/v1
```

1. Create a pull request and get feedback on your action
1. Merge the pull request into the `main` branch

The action updates are now published and ready for use in other repositories! :rocket:

For information about versioning, see
[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
in the GitHub Actions toolkit.

## Validate the Action

You can now validate the action by referencing it in a workflow file. For
example, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference this
action in the same repository.

```yaml
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Parse Tool Versions
id: tool-versions-action
uses: ./
with:
file: .tool-versions

- name: Print Output
id: output
run: echo "${{ steps.tool-versions-action.outputs.nodejs-version }}"
```

## Publishing a New Release

After testing, create a version tag(s) for the action. For more information, see
[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
in the GitHub Actions toolkit.

This project includes a helper script, [`script/release`](./script/release)
designed to streamline the process of tagging and pushing new releases for
GitHub Actions.

GitHub Actions allows users to select a specific version of the action to use,
based on release tags. This script simplifies this process by performing the
following steps:

1. **Retrieving the latest release tag:** The script starts by fetching the most
recent release tag by looking at the local data available in your repository.
1. **Prompting for a new release tag:** The user is then prompted to enter a new
release tag. To assist with this, the script displays the latest release tag
and provides a regular expression to validate the format of the new tag.
1. **Tagging the new release:** Once a valid new tag is entered, the script tags
the new release.
1. **Pushing the new tag to the remote:** Finally, the script pushes the new tag
to the remote repository. From here, you will need to create a new release in
GitHub and users can easily reference the new tag in their workflows.
Loading
Loading