Skip to content

Commit

Permalink
fix: prefix versions with type for better readability (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Apr 13, 2022
1 parent f6152a6 commit 53400a5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
39 changes: 20 additions & 19 deletions .github/workflows/nx-cloud-agents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,52 +51,53 @@ jobs:
# Set node/npm/yarn versions using volta, with optional overrides provided by the consumer
- uses: volta-cli/action@fdf4cf319494429a105efaa71d0e5ec67f338c6e
with:
node-version: '${{ inputs.node-version }}'
npm-version: '${{ inputs.npm-version }}'
yarn-version: '${{ inputs.yarn-version }}'
node-version: "${{ inputs.node-version }}"
npm-version: "${{ inputs.npm-version }}"
yarn-version: "${{ inputs.yarn-version }}"

- name: Print node/npm/yarn versions
id: print-versions
id: versions
run: |
node --version
npm --version
yarn --version || true
echo "::set-output name=use_yarn::$([[ -f ./yarn.lock ]] && echo "true" || echo "false")"
node_ver=$( node --version )
yarn_ver=$( yarn --version || true )
echo "Node: ${node_ver:1}"
echo "NPM: $( npm --version )"
if [[ $yarn_ver != '' ]]; then echo "Yarn: $yarn_ver"; fi
- name: Get node version for cache key
id: cache-key
run: echo "::set-output name=node_version::$(node --version)"
echo "::set-output name=node_version::${node_ver:1}"
echo "::set-output name=use_yarn::$([[ -f ./yarn.lock ]] && echo "true" || echo "false")"
- name: Use the node_modules cache if available [npm]
if: steps.print-versions.outputs.use_yarn != 'true'
if: steps.versions.outputs.use_yarn != 'true'
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ steps.cache-key.outputs.node_version }}-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.cache-key.outputs.node_version }}-
${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-
- name: Get yarn cache directory path
if: steps.print-versions.outputs.use_yarn == 'true'
if: steps.versions.outputs.use_yarn == 'true'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Use the node_modules cache if available [yarn]
if: steps.print-versions.outputs.use_yarn == 'true'
if: steps.versions.outputs.use_yarn == 'true'
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-
${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-yarn-
- name: Install dependencies
run: |
if [ -n "${{ inputs.install-command }}" ]; then
echo "Running custom install-command: ${{ inputs.install-command }}"
${{ inputs.install-command }}
elif [ "${{ steps.print-versions.outputs.use_yarn }}" == "true" ]; then
elif [ "${{ steps.versions.outputs.use_yarn }}" == "true" ]; then
echo "Running yarn install --frozen-lockfile"
yarn install --frozen-lockfile
else
Expand Down
35 changes: 18 additions & 17 deletions .github/workflows/nx-cloud-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,39 @@ jobs:
# Set node/npm/yarn versions using volta, with optional overrides provided by the consumer
- uses: volta-cli/action@fdf4cf319494429a105efaa71d0e5ec67f338c6e
with:
node-version: '${{ inputs.node-version }}'
npm-version: '${{ inputs.npm-version }}'
yarn-version: '${{ inputs.yarn-version }}'
node-version: "${{ inputs.node-version }}"
npm-version: "${{ inputs.npm-version }}"
yarn-version: "${{ inputs.yarn-version }}"

- name: Print node/npm/yarn versions
id: print-versions
id: versions
run: |
node --version
npm --version
yarn --version || true
echo "::set-output name=use_yarn::$([[ -f ./yarn.lock ]] && echo "true" || echo "false")"
node_ver=$( node --version )
yarn_ver=$( yarn --version || true )
echo "Node: ${node_ver:1}"
echo "NPM: $( npm --version )"
if [[ $yarn_ver != '' ]]; then echo "Yarn: $yarn_ver"; fi
- name: Get node version for cache key
id: cache-key
run: echo "::set-output name=node_version::$(node --version)"
echo "::set-output name=node_version::${node_ver:1}"
echo "::set-output name=use_yarn::$([[ -f ./yarn.lock ]] && echo "true" || echo "false")"
- name: Use the node_modules cache if available [npm]
if: steps.print-versions.outputs.use_yarn != 'true'
if: steps.versions.outputs.use_yarn != 'true'
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ steps.cache-key.outputs.node_version }}-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.cache-key.outputs.node_version }}-
${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-
- name: Get yarn cache directory path
if: steps.print-versions.outputs.use_yarn == 'true'
if: steps.versions.outputs.use_yarn == 'true'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Use the node_modules cache if available [yarn]
if: steps.print-versions.outputs.use_yarn == 'true'
if: steps.versions.outputs.use_yarn == 'true'
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
Expand All @@ -112,7 +113,7 @@ jobs:
if [ -n "${{ inputs.install-command }}" ]; then
echo "Running custom install-command: ${{ inputs.install-command }}"
${{ inputs.install-command }}
elif [ "${{ steps.print-versions.outputs.use_yarn }}" == "true" ]; then
elif [ "${{ steps.versions.outputs.use_yarn }}" == "true" ]; then
echo "Running yarn install --frozen-lockfile"
yarn install --frozen-lockfile
else
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"private": true,
"version": "0.1.0",
"version": "0.1.1",
"description": "This package.json is here purely to control the version of the Action, in combination with https://github.com/JamesHenry/publish-shell-action"
}

0 comments on commit 53400a5

Please sign in to comment.