fix: update vss-extension-dev.json file #148
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: publish-test | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
workflow_dispatch: | |
jobs: | |
publish-test: | |
if: "!contains(github.event.commits[0].message, '[skip ci]')" | |
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: publish-extension | |
id: publish-extension | |
env: | |
PUBLISHER_NAME: ${{ secrets.PUBLISHER_NAME }} | |
ORG_NAME: ${{ secrets.ORG_NAME }} | |
USER_TOKEN: ${{ secrets.USER_TOKEN }} | |
MAJOR: 1 | |
MINOR: 0 | |
PATCH: $[counter($MINOR, 0)] | |
VERSION: $MAJOR.$MINOR.$PATCH | |
commit_message: ${{ github.event.head_commit.message }} | |
run: | | |
name="Synopsys-security-scan" | |
echo $name | |
echo "EXTENSION_NAME=$name" | |
vss_extension_dev=$(cat vss-extension-dev.json) | |
azure_extension_version=$(echo $vss_extension_dev | jq -r '.version') | |
echo $azure_extension_version | |
major=$(echo $azure_extension_version | awk -F. '{print $1}') | |
minor=$(echo $azure_extension_version | awk -F. '{print $2}') | |
patch=$(echo $azure_extension_version | awk -F. '{print $3}') | |
COMMIT_MESSAGE_HEADER=$(git log -1 --pretty=%B | head -n 1) | |
echo $COMMIT_MESSAGE_HEADER | |
COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE_HEADER" | awk -F: '{print $1}') | |
commit=$(echo "$commit_message" | awk -F: '{print $1}') | |
echo $COMMIT_MESSAGE | |
echo "commit" $commit | |
if [[ "$COMMIT_MESSAGE" == "BREAKING CHANGE" ]]; then | |
version=$((major+1)).0.0 | |
echo "updated major version" | |
elif [[ "$COMMIT_MESSAGE" == "feat" ]]; then | |
version=$major.$((minor+1)).0 | |
echo "updated minor version" | |
elif [[ "$COMMIT_MESSAGE" == "fix" ]]; then | |
version=$major.$minor.$((patch+1)) | |
echo "updated patch version" | |
else | |
version=$azure_extension_version | |
fi | |
echo $version | |
jq --arg version "$version" '.version = $version' vss-extension-dev.json > vss-extension-dev.json.tmp && mv vss-extension-dev.json.tmp vss-extension-dev.json | |
cat vss-extension-dev.json | |
echo "AZURE_EXTENSION_VERSION=$azure_extension_version" | |
# npm i -g tfx-cli | |
# tfx extension publish --publisher TestCIPub --manifest-globs vss-extension-dev.json --token ${USER_TOKEN} | |
# with: | |
# name: publish-extension | |
# path: | |
# "*.vsix" | |
- name: update extension version | |
if: steps.publish-extension.conclusion == 'success' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} | |
run: | | |
echo "updating version" | |
echo "$(git log -n 1 --pretty=format:%an)" | |
echo "$(git log -n 1 --pretty=format:%ae)" | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b automatic_version_update | |
git add vss-extension-dev.json | |
git commit -m "update extension version" | |
git push origin automatic_version_update | |
echo gh --version | |
gh pr create --base main --head automatic_version_update --title "pr test" --body "Created by Github action" --fill | |
gh pr merge --merge --subject "automated pr merge" --body " merging automated pr changes" | |
git branch -d automatic_version_update | |
# - 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 |