Skip to content

Commit

Permalink
Add GitHub Action to Detect TypeScript Version Conflicts (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuniu-ms authored Nov 15, 2024
1 parent 4a28a75 commit 0174b99
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/npm-grunt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: NodeJS with Grunt

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Update dependencies in package.json
run: |
current_version=$(jq -r '.version' package.json)
echo "Current version: $current_version"
# Extract the part of the version after the first dot
remaining_version=${current_version#*.}
# Concatenate "3." with the remaining part
ai_version="3.$remaining_version"
echo "AI version: $ai_version"
# Replace the versions in sample/applicationinsights-react-sample/package.json with the current reactJS version
sed -i "s/\"@microsoft\\/applicationinsights-core-js\": \"[^\"]*\"/\"@microsoft\/applicationinsights-core-js\": \"$ai_version\"/" sample/applicationinsights-react-sample/package.json
sed -i "s/\"@microsoft\\/applicationinsights-react-js\": \"[^\"]*\"/\"@microsoft\/applicationinsights-react-js\": \"$current_version\"/" sample/applicationinsights-react-sample/package.json
sed -i "s/\"@microsoft\\/applicationinsights-web\": \"[^\"]*\"/\"@microsoft\/applicationinsights-web\": \"$ai_version\"/" sample/applicationinsights-react-sample/package.json
# add applicationinsights-common into package.json also
echo "\"@microsoft/applicationinsights-common\": \"$current_version\"," | sed -i "/\"@microsoft\/applicationinsights-core-js\": \"$ai_version\"/i \ \"@microsoft/applicationinsights-common\": \"$ai_version\"," sample/applicationinsights-react-sample/package.json
- name: Display updated package.json
run: cat sample/applicationinsights-react-sample/package.json

- name: Get latest version of @microsoft/applicationinsights-web
id: get_version
run: |
latest_version=$(npm show @microsoft/applicationinsights-web version)
echo "Latest version: $latest_version"
echo "latest_version=$latest_version" >> $GITHUB_ENV
- name: Build
working-directory: sample/applicationinsights-react-sample
run: |
npm install
npm install @microsoft/applicationinsights-web@${{ env.latest_version }} --verbose
npm run build
env:
latest_version: ${{ env.latest_version }}

0 comments on commit 0174b99

Please sign in to comment.