chore(deps): update root dev dependencies #1761
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
node-version: [18.x, 20.x] | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: true | |
- name: Cache pnpm modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-pnpm-modules | |
with: | |
path: ~/.pnpm-store | |
key: ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}- | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install pnpm modules | |
run: pnpm install | |
- name: Run build | |
run: pnpm run build | |
- name: Run linting | |
run: pnpm run lint | |
- name: Run unit tests | |
run: pnpm run test | |
- name: Run SonarCloud scan | |
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '18.x' | |
uses: sonarsource/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
version: | |
# Run version job only on pushes to the main branch. The job depends on completion of the build job. | |
if: github.repository == 'SAP/guided-answers-extension' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: build | |
outputs: | |
changes: ${{ steps.changesetVersion.outputs.changes }} # map step output to job output | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.ACCESS_PAT }} | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: true | |
- name: Cache pnpm modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-pnpm-modules | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- name: Install pnpm modules | |
run: pnpm install | |
- name: Apply changesets | |
id: changesetVersion | |
run: | | |
echo "changes=$(pnpm ci:version 2>&1 | grep -q 'No unreleased changesets found' && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT | |
git status | |
- name: Commit and push changes | |
if: steps.changesetVersion.outputs.changes == 'true' | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git status | |
git add -A | |
git status | |
git commit -m "chore: apply latest changesets" --no-verify || echo "No changesets found" | |
git log --pretty=oneline | head -n 10 | |
git push | |
release: | |
# Run release job only on pushes to the main branch. The job depends on completion of the build job. | |
# This job needs to run after the version job commit has been merged - so check if that step returns 'false' | |
if: github.repository == 'SAP/guided-answers-extension' && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.version.outputs.changes == 'false' | |
runs-on: ubuntu-latest | |
needs: version | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@v4 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: true | |
- name: Cache pnpm modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-pnpm-modules | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- name: Install pnpm modules | |
run: pnpm install | |
- name: Replace placeholder with instrumentation key | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
include: packages/ide-extension/src/telemetry/telemetry.ts | |
find: 'ApplicationInsightsInstrumentationKeyPLACEH0LDER' | |
replace: ${{ secrets.INSTRUMENTATION_KEY }} | |
regex: false | |
- name: Run build | |
run: pnpm run build | |
- name: Package vsix | |
run: pnpm run ide-ext:package | |
- name: Get version number from /packages/ide-extension/package.json | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@main | |
with: | |
path: packages/ide-extension | |
- name: Read last entry of changelog | |
run: | | |
echo "lastChangelogEntry<<END_CHANGEL0G_ENTRY" >> $GITHUB_ENV | |
node -e 'require(`changelog-parser`)(`./packages/ide-extension/CHANGELOG.md`).then((c)=>console.log(c?.versions?.[0]?.body || `See CHANGELOG.md for details`))' >> $GITHUB_ENV | |
echo "END_CHANGEL0G_ENTRY" >> $GITHUB_ENV | |
- name: Create Github Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body: ${{ env.lastChangelogEntry }} | |
draft: false | |
files: packages/ide-extension/sap-guided-answers*.vsix | |
fail_on_unmatched_files: true | |
tag_name: sap-guided-answers-extension@${{ steps.package-version.outputs.current-version}} |