Skip to content

Commit

Permalink
Pin node/npm version
Browse files Browse the repository at this point in the history
  • Loading branch information
milespetrov committed Jul 29, 2024
1 parent a08fc98 commit 3feb9e5
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: latest
cache: 'npm'
node-version: 22.2.0
cache: 'npm'

- name: Try to restore node_modules folder from cache
id: cache-node-modules
uses: actions/cache@v4
with:
path: ./node_modules
key: npm-${{ hashFiles('./package-lock.json') }}
path: ./node_modules
key: npm-${{ hashFiles('./package-lock.json') }}

- name: Otherwise install npm dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci

- name: Update package.json version if necessary
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
npm version --allow-same-version --no-git-tag-version $TAG_VERSION
echo "::warning::Tag version ($TAG_VERSION) did not match package.json version ($PACKAGE_VERSION). Updated package.json to $TAG_VERSION."
else
echo "::info::Tag version ($TAG_VERSION) matches package.json version ($PACKAGE_VERSION)."
fi
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
npm version --allow-same-version --no-git-tag-version $TAG_VERSION
echo "::warning::Tag version ($TAG_VERSION) did not match package.json version ($PACKAGE_VERSION). Updated package.json to $TAG_VERSION."
else
echo "::info::Tag version ($TAG_VERSION) matches package.json version ($PACKAGE_VERSION)."
fi
- name: Build the files!
run: npm run build
env:
Expand All @@ -74,4 +74,4 @@ jobs:
uses: ./.github/workflows/deploy.yml
with:
cache_sha: ${{ format('{0}-{1}', github.ref_name, github.event.pull_request.head.sha || github.sha) }}
secrets: inherit
secrets: inherit

0 comments on commit 3feb9e5

Please sign in to comment.