Clone the repository:
git clone git@github.com/AGS4NO/tool-versions-action
cd tool-versions-action
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 handy (20.x or later should work!). If you are
using a version manager like nodenv
or
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.
-
🛠️ Install the dependencies
npm install
-
🏗️ Package the TypeScript for distribution
npm run bundle
-
✅ Run the tests
$ npm test Test Suites: 2 passed, 2 total Tests: 3 passed, 3 total Snapshots: 0 total Time: 2.93 s, estimated 3 s ...
-
Create a new branch
git checkout -b releases/v1
-
Update the contents of
src/
-
Add tests to
__tests__/
for your source code -
Format, test, and build the action
npm run all
[!WARNING]
This step is important! It will run
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 forncc
, which will create a license file for all of the production node modules used in this project. -
Commit your changes
git add . git commit -m "Release v1"
-
Push them to the repository
git push -u origin releases/v1
-
Create a pull request and get feedback on your action
-
Merge the pull request into the
main
branch
The action updates are now published and ready for use in other repositories! 🚀
For information about versioning, see Versioning in the GitHub Actions toolkit.
You can now validate the action by referencing it in a workflow file. For
example, ci.yml
demonstrates how to reference this
action in the same repository.
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 }}"
After testing, create a version tag(s) for the action. For more information, see Versioning in the GitHub Actions toolkit.
This project includes a helper script, 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:
- 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.
- 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.
- Tagging the new release: Once a valid new tag is entered, the script tags the new release.
- 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.