Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
matzkoh committed Oct 19, 2023
1 parent 477a481 commit 199f27f
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: ci

on:
pull_request:
push:
branches:
- main

permissions:
contents: write
issues: write
pull-requests: write

jobs:
test-default:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- id: run
uses: ./

- run: test -n "${{ steps.run.outputs.node-build-version }}"
- run: test "${{ steps.run.outputs.node-version }}" = "$(< .node-version)"

test-with-path:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- id: run
uses: ./
with:
node-version-path: .nvmrc

- run: test -n "${{ steps.run.outputs.node-build-version }}"
- run: test "${{ steps.run.outputs.node-version }}" = "$(< .nvmrc)"

test-with-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- id: run
continue-on-error: true
uses: ./
with:
node-version: 999.999.999

- run: test -n "${{ steps.run.outputs.node-build-version }}"
- run: test "${{ steps.run.outputs.node-version }}" = "999.999.999"
- run: test "${{ steps.run.outcome }}" = "failure"

release:
needs:
- test-default
- test-with-path
- test-with-version
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: tag

on:
release:
types:
- published
- edited

permissions:
contents: write

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: Actions-R-Us/actions-tagger@v2
with:
publish_latest_tag: true
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.8.1
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.8.1
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[![Test](https://github.com/matzkoh/check-node-version/actions/workflows/default.yml/badge.svg)](https://github.com/matzkoh/check-node-version/actions/workflows/default.yml)

# matzkoh/check-node-version

This GitHub Action checks if commands like `nodenv install` will definitely succeed.

It checks the `node-build` repository, which is the source of the installation, and fails if the target version does not exist.

## Examples

### Basic

```yaml
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: /.node-version
sparse-checkout-cone-mode: false

- uses: matzkoh/check-node-version@v1
```
### Optional
```yaml
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: /.node-version
sparse-checkout-cone-mode: false

- id: check-node-version
continue-on-error: true # continue even if the node version is not yet released
uses: matzkoh/check-node-version@v1
with:
node-version-path: .nvmrc # use a file other than `.node-version` if desired

- run: echo ${{ steps.check-node-version.outcome == 'success' && 'released 😀' || 'not yet released 😢' }}
```
## Inputs
See [action.yml](action.yml)
| Name | Description | Default | Required |
| ------------------- | ------------------------------------------------------------------- | --------------- | -------- |
| `node-version-path` | Path to the file containing the node version to check | `.node-version` | ❌ |
| `node-version` | Node version to check. If not specified, it will be read from file. | | ❌ |

## Outputs

See [action.yml](action.yml)

| Name | Description |
| -------------------- | -------------------------------------------------------------------- |
| `node-version` | Same as `node-version` input. Checked version. |
| `node-build-version` | Latest release version of brew `node-build` formula used for checks. |
37 changes: 37 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: check-node-version
description: GitHub Actions to check if node-version has been released and is available via brew node-build.
author: matzkoh

inputs:
node-version:
description: The version to check
node-version-path:
description: The path to the .node-version file
default: .node-version

runs:
using: composite
steps:
- id: check
shell: bash
run: |
if [ -n "${{ inputs.node-version }}" ]; then
node_version=${{ inputs.node-version }}
else
node_version=$(< ${{ inputs.node-version-path }})
fi
node_build_version=$(curl -s 'https://formulae.brew.sh/api/formula/node-build.json' | jq -r '.versions.stable')
echo "node-version=${node_version}" >> $GITHUB_OUTPUT
echo "node-build-version=${node_build_version}" >> $GITHUB_OUTPUT
curl -fsIo /dev/null "https://raw.githubusercontent.com/nodenv/node-build/v${node_build_version}/share/node-build/${node_version}"
outputs:
node-version:
description: The version in .node-version
value: ${{ steps.check.outputs.node-version }}
node-build-version:
description: The latest node-build version
value: ${{ steps.check.outputs.node-build-version }}
9 changes: 9 additions & 0 deletions release.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('semantic-release').GlobalConfig} */
module.exports = {
branches: ['main'],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/github',
],
}

0 comments on commit 199f27f

Please sign in to comment.