Skip to content

Commit

Permalink
feat: enable support for node16 (#15)
Browse files Browse the repository at this point in the history
- update action runtime to `node16`
- code cleanup
- add dist output ci check
- fix deprecated `::set-output` usages

BREAKING CHANGE: Update node runtime from `v12` to `v16`
  • Loading branch information
wdconinc committed Sep 5, 2023
1 parent d23f54e commit 0bfa2be
Show file tree
Hide file tree
Showing 9 changed files with 11,867 additions and 155 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# In TypeScript actions, `dist/index.js` is a special file. When you reference
# an action with `uses:`, `dist/index.js` is the code that will be run. For this
# project, the `dist/index.js` file is generated from other source files through
# the build process. We need to make sure that the checked-in `dist/index.js`
# file matches what is expected from the build.
#
# This workflow will fail if the checked-in `dist/index.js` file does not match
# what is expected from the build.
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest

permissions:
contents: read
statuses: write

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm

- name: Install Dependencies
id: install
run: npm ci

- name: Build lib/ Directory
id: lib
run: npm run all

- name: Build dist/ Directory
id: build
run: npm run package

- name: Compare Expected and Actual Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
# If index.js was different than expected, upload the expected version as
# a workflow artifact.
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:
name: Test Action Build
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
- name: Install node_modules
uses: bahmutov/npm-install@v1
- run: npm run all
test:
name: Test Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Create mock test object
id: mock
# example object being tested
Expand All @@ -53,7 +53,7 @@ jobs:
# },
# ],
# }
run: echo "::set-output name=json::{\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}"
run: echo "json={\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}" >> "$GITHUB_OUTPUT"
- name: Works with simple values
id: test1
uses: ./
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ For the following _complex_ examples, let's assume that we receive the following
}
```

Specifically, the `"Get mock test object"` step will set the above object to its output (via [`::set-output`](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter)) and makes it available via `steps.mock.outputs.json` in other steps.
Specifically, the `"Get mock test object"` step will set the above object to its output (via [`$GITHUB_OUTPUT`](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)) and makes it available via `steps.mock.outputs.json` in other steps.

---

Expand All @@ -266,7 +266,7 @@ jobs:
steps:
- name: Get mock test object
id: mock
run: echo "::set-output name=json::{\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}"
run: echo "json={\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}" >> "$GITHUB_OUTPUT"
- name: Complex values
id: test # used to access output in other steps
uses: nickofthyme/object-remap@v1
Expand Down Expand Up @@ -316,7 +316,7 @@ jobs:
steps:
- name: Get mock test object
id: mock
run: echo "::set-output name=json::{\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}"
run: echo "json={\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}" >> "$GITHUB_OUTPUT"
- name: Complex values
id: test # used to access output in other steps
uses: nickofthyme/object-remap@v1
Expand Down Expand Up @@ -347,7 +347,7 @@ jobs:
steps:
- name: Get mock test object
id: mock
run: echo "::set-output name=json::{\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}"
run: echo "json={\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}" >> "$GITHUB_OUTPUT"
- name: Complex values
id: test # used to access output in other steps
uses: nickofthyme/object-remap@v1
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ outputs:
json:
description: remapped json output as a string
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
5 changes: 3 additions & 2 deletions clean_dist.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

# Needed to cleanup ncc output for CRLF error
# Note: Only runs on mac machines
sed -i "" "s/$(printf '\r')\$//" dist/index.js
# Note: Avoid space between -i and empty string
# so this works on linux and mac machines
sed -i"" "s/$(printf '\r')\$//" dist/index.js
Loading

0 comments on commit 0bfa2be

Please sign in to comment.