Skip to content

upgrade-extension-version #41

upgrade-extension-version

upgrade-extension-version #41

name: upgrade-extension-version
on:
workflow_dispatch:
inputs:
version:
description: 'EXTENSION VERSION'
required: true
default: ""
type: string
jobs:
upgrade-extension-version:
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
- name: versioning
id: version-update
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
extension_name=$(jq -r '.name' < vss-extension.json)
echo "EXTENSION_NAME=$extension_name" >> $GITHUB_ENV
echo "EXTENSION NAME: "$extension_name
current_extension_version=${{ github.event.inputs.version }}
echo "CURRENT_VERSION=$current_extension_version" >> $GITHUB_ENV
echo "CURRENT EXTENSION VERSION: " $current_extension_version
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}')
new_version=$current_extension_version
echo "Updating vss-extension.json with the new version: ${new_version}"
jq --arg new_version "$new_version" '.version = $new_version' vss-extension.json > vss-extension.json.tmp && mv vss-extension.json.tmp vss-extension.json
echo "Updated vss-extension.json file"
cat vss-extension.json
echo
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
echo
cd synopsys-task
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
echo "Updating task.json with the new version: ${new_version}"
jq --argjson major "$current_major" --argjson minor "$current_minor" --argjson patch "$current_patch" '(.version.Major = $major) | (.version.Minor = $minor) | (.version.Patch = $patch)' task.json > task.json.tmp && mv task.json.tmp task.json
echo "Updated task.json file"
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
- name: update extension version in file
id: update-extension-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Updating extension version in vss-extension.json, vss-extension-dev.json, extension_version.txt, package.json, package-lock.json & task.json file"
git config --local user.name "$(git log -n 1 --pretty=format:%an)"
git config --local user.email "$(git log -n 1 --pretty=format:%ae)"
git checkout -b extension_version_update
git pull origin extension_version_update --rebase || true
cd synopsys-task
npm i
npm run all
git add all
git commit -m "upgrade extension version to ${{ env.NEW_VERSION }} [skip ci]"
git push origin extension_version_update --force
gh pr create --base main --head extension_version_update --title "Extension version upgrade to ${{ env.NEW_VERSION }}" --body "${{ env.EXTENSION_NAME }} version upgrade to ${{ env.NEW_VERSION }}" --fill
echo "Successful updated extension version in vss-extension.json, vss-extension-dev.json, extension_version.txt, package.json, package-lock.json & task.json file..."