Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
Siyaram Meena committed Sep 4, 2024
1 parent bfc62c6 commit a226a45
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 175 deletions.
98 changes: 49 additions & 49 deletions .github/workflows/check-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
#name: Check Code Coverage
#
#on:
# push:
# branches:
# - main
# paths-ignore:
# - '**.md'
# pull_request:
# branches:
# - main
# paths-ignore:
# - '**.md'
# workflow_dispatch:
#
#jobs:
# code-coverage:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - name: Set Node.js 20.x
# uses: actions/setup-node@v4
# with:
# node-version: 20.x
#
# - name: Install dependencies
# run: cd synopsys-task && npm ci
#
# - name: Unit Test Cases
# id: unit-test-cases
# shell: bash
# run: |
# cd synopsys-task && npm run test
# coverageFile="coverage/index.html"
#
# ### fetching line coverage from coverage/index.html file
# coverageSpan=$(grep -B 1 '<span class="quiet">Lines</span>' $coverageFile | head -n 1)
# coverageHtml=$(echo "$coverageSpan" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# coverageInPercent=$(echo $coverageHtml | sed -n 's/.*<span class="strong">\([0-9.]*%\).*/\1/p' | tr -d ' ')
# echo "Line Coverage: $coverageInPercent"
#
# ### remove percentage sign from coverageInPercent and convert to a floatin-point number
# coverageValue=$(echo "$coverageInPercent" | tr -d '%' | sed 's/,/./g')
# ### check if the coverage is below 90%
# if [[ $coverageValue < 90 ]]; then
# echo "##[error]Line coverage is below 90%"
# exit 1
# fi
name: Check Code Coverage

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

jobs:
code-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install dependencies
run: cd synopsys-task && npm ci

- name: Unit Test Cases
id: unit-test-cases
shell: bash
run: |
cd synopsys-task && npm run test
coverageFile="coverage/index.html"
### fetching line coverage from coverage/index.html file
coverageSpan=$(grep -B 1 '<span class="quiet">Lines</span>' $coverageFile | head -n 1)
coverageHtml=$(echo "$coverageSpan" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
coverageInPercent=$(echo $coverageHtml | sed -n 's/.*<span class="strong">\([0-9.]*%\).*/\1/p' | tr -d ' ')
echo "Line Coverage: $coverageInPercent"
### remove percentage sign from coverageInPercent and convert to a floatin-point number
coverageValue=$(echo "$coverageInPercent" | tr -d '%' | sed 's/,/./g')
### check if the coverage is below 90%
if [[ $coverageValue < 90 ]]; then
echo "##[error]Line coverage is below 90%"
exit 1
fi
108 changes: 54 additions & 54 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
## `dist/index.js` is a special file in Actions.
## When you reference an action with `uses:` in a workflow,
## `index.js` is the code that will run.
## For our project, we generate this file through a build process from other source files.
## We need to make sure the checked-in `index.js` actually matches what we expect it to be.
#name: Check dist/
#
#on:
# push:
# branches:
# - main
# paths-ignore:
# - '**.md'
# pull_request:
# branches:
# - main
# paths-ignore:
# - '**.md'
# workflow_dispatch:
#
#jobs:
# check-dist:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
#
# - name: Set Node.js 20.x
# uses: actions/setup-node@v4
# with:
# node-version: 20.x
#
# - name: Install dependencies
# run: cd synopsys-task && npm ci
#
# - name: Rebuild the dist/ directory
# run: cd synopsys-task && npm run build && npm run package
#
# - name: Compare the expected and actual dist/ directories
# run: |
# cd synopsys-task
# if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
# echo "Detected uncommitted changes after build. See status below:"
# git diff
# exit 1
# fi
# id: diff
#
# # If index.js was different than expected, upload the expected version as an artifact
# - uses: actions/upload-artifact@v3
# if: ${{ failure() && steps.diff.conclusion == 'failure' }}
# with:
# name: dist
# path: synopsys-task/dist/
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/

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

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install dependencies
run: cd synopsys-task && npm ci

- name: Rebuild the dist/ directory
run: cd synopsys-task && npm run build && npm run package

- name: Compare the expected and actual dist/ directories
run: |
cd synopsys-task
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: synopsys-task/dist/
9 changes: 2 additions & 7 deletions .github/workflows/deploy-extension.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: deploy-extension-test
name: deploy-synopsys-extension

on:
workflow_dispatch:
Expand All @@ -14,7 +14,7 @@ jobs:
env:
DEPLOY_PUBLISHER_NAME: ${{ secrets.DEPLOY_PUBLISHER_NAME }}
DEPLOY_ORGANIZATION_NAME: ${{ secrets.DEPLOY_ORG_NAME }}
USER_TOKEN: ${{ secrets.USER_TOKEN }} #personal_access_token of azure devops account
USER_TOKEN: ${{ secrets.DEPLOY_USER_TOKEN }} #personal_access_token of azure devops account
run: |
vss_extension=$(cat vss-extension.json)
extension_name=$(echo $vss_extension | jq -r '.name' )
Expand All @@ -33,8 +33,3 @@ jobs:
# exit 1
# fi

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: extension-artifact
path: vss-extension.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish-test
name: publish-QAExtension

on:
push:
Expand All @@ -14,8 +14,8 @@ on:
workflow_dispatch:

jobs:
publish-test:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
if: "!contains(github.event.commits[0].message, '[skip ci]')"
publish-QAExtension:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -26,51 +26,6 @@ jobs:
with:
node-version: 20.x

# - name: versioning
# id: version-update
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
# run: |
# vss_extension_dev=$(cat vss-extension-dev.json)
# extension_name=$(echo $vss_extension_dev | jq -r '.name' )
# echo "EXTENSION_NAME=$extension_name" >> $GITHUB_ENV
# current_extension_version=$(echo $vss_extension_dev | jq -r '.version')
# echo "CURRENT_VERSION=$current_extension_version" >> $GITHUB_ENV
# echo "current extension version: " $current_extension_version
# major=$(echo $current_extension_version | awk -F. '{print $1}')
# minor=$(echo $current_extension_version | awk -F. '{print $2}')
# patch=$(echo $current_extension_version | awk -F. '{print $3}')
# COMMIT_MESSAGE_HEADER=$(git log -1 --pretty=%B | head -n 1)
# COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE_HEADER" | awk -F: '{print $1}')
# echo "commit message: " $COMMIT_MESSAGE_HEADER
# if [[ "$COMMIT_MESSAGE" == "BREAKING CHANGE" ]]; then
# new_version=$((major+1)).0.0
# echo "Updating extension version $current_extension_version --> $new_version"
# elif [[ "$COMMIT_MESSAGE" == "perf" ]]; then
# new_version=$((major+1)).0.0
# echo "Updating extension version $current_extension_version --> $new_version"
# elif [[ "$COMMIT_MESSAGE" == "feat" ]]; then
# new_version=$major.$((minor+1)).0
# echo "Updating extension version $current_extension_version --> $new_version"
# elif [[ "$COMMIT_MESSAGE" == "fix" ]]; then
# new_version=$major.$minor.$((patch+1))
# echo "Updating extension version $current_extension_version --> $new_version"
# else
# new_version=$current_extension_version
# echo "Extension version will not be updated. Current version: $new_version"
# fi
#
# if [[ "$current_extension_version" != "$new_version" ]]; then
# echo "Updating vss-extension-dev.json with the new version: ${new_version}"
# jq --arg new_version "$new_version" '.version = $new_version' vss-extension-dev.json > vss-extension-dev.json.tmp && mv vss-extension-dev.json.tmp vss-extension-dev.json
# echo "Updated vss-extension-dev.json file"
# cat vss-extension-dev.json
# else
# echo "vss-extension-dev.json file"
# cat vss-extension-dev.json
# fi
# echo "NEW_VERSION=$new_version" >> $GITHUB_ENV

- name: versioning
id: version-update
env:
Expand All @@ -82,10 +37,10 @@ jobs:
current_extension_version=$(echo $vss_extension_dev | jq -r '.version')
echo "CURRENT_VERSION=$current_extension_version" >> $GITHUB_ENV
echo "current extension version: " $current_extension_version
previous_extension_version=$(grep 'extension_version' extension_version.txt | cut -d '=' -f 2)
echo "previous extension version:" $previous_extension_version
previous_major=$(echo $previous_extension_version | awk -F. '{print $1}')
previous_minor=$(echo $previous_extension_version | awk -F. '{print $2}')
previous_published_extension_version=$(grep 'published_extension_version' extension_version.txt | cut -d '=' -f 2)
echo "previous published extension version:" $previous_published_extension_version
previous_major=$(echo $previous_published_extension_versionn | awk -F. '{print $1}')
previous_minor=$(echo $previous_published_extension_version | awk -F. '{print $2}')
current_major=$(echo $current_extension_version | awk -F. '{print $1}')
current_minor=$(echo $current_extension_version | awk -F. '{print $2}')
current_patch=$(echo $current_extension_version | awk -F. '{print $3}')
Expand All @@ -97,36 +52,30 @@ jobs:
echo "Updated vss-extension-dev.json file"
cat vss-extension-dev.json
echo "Updating extension_version.txt with the new version: ${new_version}"
sed -i "s/extension_version=.*/extension_version=$new_version/" extension_version.txt
sed -i "s/previous_published_extension_version=.*/previous_published_extension_version=$new_version/" extension_version.txt
echo "Updated extension_version.txt file"
cat extension_version.txt
cd synopsys-task
echo "Updating package.json version to: ${new_version}"
echo "Updating package.json with the new version: ${new_version}"
jq --arg new_version "$new_version" '.version = $new_version' package.json > package.json.tmp && mv package.json.tmp package.json
echo "Updated package.json file"
cat package.json
echo "Updating package-lock.json version to: ${new_version}"
echo "Updating package-lock.json with the new version: ${new_version}"
jq --arg new_version "$new_version" '(.version = $new_version) | (.packages[""].version = $new_version)' package-lock.json > package-lock.json.tmp && mv package-lock.json.tmp package-lock.json
echo "Updated package-lock.json file"
echo "Updating task.json version to: ${new_version}"
echo "Updating task.json with the new version: ${new_version}"
jq --argjson patch_version $((current_patch+1)) '.version.Patch |= $patch_version' task.json > task.json.tmp && mv task.json.tmp task.json
echo "Updated task.json file"
else
new_version=$current_extension_version
echo "Extension version will not be updated automatically. Current version: ${new_version}"
fi
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV

- name: publish-extension
id: publish-extension
- name: publish-QAExtension
id: publish-qaextension
if: ${{ steps.version-update.conclusion == 'success' }}
env:
PUBLISHER_NAME: ${{ secrets.PUBLISHER_NAME }}
Expand All @@ -138,6 +87,9 @@ jobs:
echo "Extension Name:" $extension_name
extension_version=$(echo $vss_extension_dev | jq -r '.version')
echo "Extension Version:" $extension_version
echo "Install dependencies && Rebuild the dist/ directory"
cd synopsys-task && npm ci && npm run build && npm run package
cd ../
echo "Installing tfx-cli..."
npm i -g tfx-cli
echo "Creating extension $extension_name with version $extension_version"
Expand All @@ -156,9 +108,9 @@ jobs:
# tfx extension publish --publisher ${PUBLISHER_NAME} --manifest-globs vss-extension-dev.json --share-with ${ORGANIZATION_NAME} --token ${USER_TOKEN} | tee tfx_output.log
# tfx extension publish --publisher TestCIPub --manifest-globs vss-extension-dev.json --token ${USER_TOKEN} | tee tfx_output.log

- name: update extension version
- name: push extension version in file
id: update-extension-version
if: ${{ steps.publish-extension.conclusion == 'success' && env.NEW_VERSION != env.CURRENT_VERSION }}
if: ${{ steps.publish-qaextension.conclusion == 'success' && env.NEW_VERSION != env.CURRENT_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
run: |
Expand All @@ -170,7 +122,7 @@ jobs:
git add package.json package-lock.json task.json
git commit -m "update extension version [skip ci]"
git push origin main
echo "Successful updated version in vss-extension-dev.json..."
echo "Successful updated version in vss-extension-dev.json, extension_version.txt, package.json, package-lock.json & task.json file"
# git config --local user.name "github-actions[bot]"
# git config --local user.email "github-actions[bot]@users.noreply.github.com"
- name: Upload Artifact
Expand Down
2 changes: 1 addition & 1 deletion extension_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
extension_version=2.2.8
published_extension_version=2.2.8

0 comments on commit a226a45

Please sign in to comment.