Skip to content

Commit 400a526

Browse files
Merge branch 'main' into SIGINT-2282
2 parents 60b675e + ebde3bb commit 400a526

9 files changed

+375
-70
lines changed

.github/workflows/create-tag.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: create-tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
TAG:
7+
description: 'TAG'
8+
required: true
9+
default: ""
10+
type: string
11+
TAG_BODY:
12+
description: 'TAG DESCRIPTION'
13+
required: false
14+
default: ""
15+
type: string
16+
IS_DRAFT:
17+
description: 'CREATE AS DRAFT'
18+
required: false
19+
default: false
20+
type: boolean
21+
IS_PRERELEASE:
22+
description: 'PRERELEASE TAG'
23+
required: true
24+
default: true
25+
type: boolean
26+
jobs:
27+
create-tag:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Set Node.js 20.x
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 20.x
36+
37+
- name: Install dependencies
38+
run: cd blackduck-security-task && npm ci
39+
40+
- name: Rebuild the dist/ directory
41+
run: cd blackduck-security-task && npm run build && npm run package
42+
43+
- name: Compare the expected and actual dist/ directories
44+
run: |
45+
cd blackduck-security-task
46+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
47+
echo "Detected uncommitted changes after build. See status below:"
48+
git diff
49+
exit 1
50+
fi
51+
id: diff
52+
53+
- name: replace \n
54+
id: process_body
55+
run: |
56+
tag_body="${{ github.event.inputs.TAG_BODY }}"
57+
echo "${tag_body}">>processed_body.txt
58+
sed -i 's/\\n/\n/g' processed_body.txt
59+
cat processed_body.txt
60+
processed_body=$(cat processed_body.txt | tr '\n' '\n')
61+
echo "PROCESSED_BODY<<EOF">>$GITHUB_ENV
62+
echo "$processed_body">>$GITHUB_ENV
63+
echo "EOF">>$GITHUB_ENV
64+
65+
- name: Create tag
66+
id: create_tag
67+
uses: actions/create-release@latest
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
70+
with:
71+
tag_name: ${{ github.event.inputs.TAG }}
72+
release_name: "BLACK DUCK EXTENSION ${{ github.event.inputs.TAG }}"
73+
body: ${{ env.PROCESSED_BODY }}
74+
draft: ${{ github.event.inputs.IS_DRAFT }}
75+
prerelease: ${{ github.event.inputs.IS_PRERELEASE }}
+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: publish-QAExtension
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish-QAExtension:
8+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set Node.js 20.x
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20.x
17+
18+
- name: Install dependencies
19+
run: cd blackduck-security-task && npm ci
20+
21+
- name: Rebuild the dist/ directory
22+
run: cd blackduck-security-task && npm run build && npm run package
23+
24+
- name: Compare the expected and actual dist/ directories
25+
run: |
26+
cd blackduck-security-task
27+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
28+
echo "Detected uncommitted changes after build. See status below:"
29+
git diff
30+
exit 1
31+
fi
32+
id: diff
33+
34+
- name: versioning
35+
id: version-update
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
38+
run: |
39+
extension_name=$(jq -r '.name' < vss-extension-dev.json)
40+
echo "EXTENSION_NAME=$extension_name" >> $GITHUB_ENV
41+
echo "EXTENSION NAME: "$extension_name
42+
current_extension_version=$(jq -r '.version' < vss-extension-dev.json)
43+
echo "CURRENT_VERSION=$current_extension_version" >> $GITHUB_ENV
44+
echo "CURRENT QAEXTENSION VERSION: " $current_extension_version
45+
previous_published_qaextension_version=$(grep 'published_qaextension_version' extension_version.txt | cut -d '=' -f 2)
46+
echo "PREVIOUS PUBLISHED QAEXTENSION VERSION: " $previous_published_qaextension_version
47+
previous_major=$(echo $previous_published_qaextension_version | awk -F. '{print $1}')
48+
previous_minor=$(echo $previous_published_qaextension_version | awk -F. '{print $2}')
49+
previous_patch=$(echo $previous_published_qaextension_version | awk -F. '{print $3}')
50+
current_major=$(echo $current_extension_version | awk -F. '{print $1}')
51+
current_minor=$(echo $current_extension_version | awk -F. '{print $2}')
52+
if [ "$previous_major" -eq "$current_major" ] && [ "$previous_minor" -eq "$current_minor" ]; then
53+
current_patch=$((previous_patch+1))
54+
new_version=$current_major.$current_minor.$current_patch
55+
echo "Updating extension version to: ${new_version}"
56+
else
57+
new_version=$current_extension_version
58+
echo "Extension version will not be updating automatically. Current version: ${new_version}"
59+
fi
60+
echo "Updating vss-extension-dev.json with the new version: ${new_version}"
61+
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
62+
echo "Updated vss-extension-dev.json file"
63+
cat vss-extension-dev.json
64+
echo
65+
66+
echo "Updating extension_version.txt with the new version: ${new_version}"
67+
sed -i "s/published_qaextension_version=.*/published_qaextension_version=$new_version/" extension_version.txt
68+
cat extension_version.txt
69+
echo
70+
echo "Updated extension_version.txt file"
71+
72+
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
73+
- name: publish-QAExtension
74+
id: publish-qaextension
75+
if: ${{ steps.version-update.conclusion == 'success' }}
76+
env:
77+
PUBLISHER_NAME: ${{ secrets.PUBLISHER_NAME }}
78+
ORGANIZATION_NAME: ${{ secrets.ORG_NAME }}
79+
USER_TOKEN: ${{ secrets.USER_TOKEN }} #personal_access_token of azure devops account
80+
run: |
81+
vss_extension_dev=$(cat vss-extension-dev.json)
82+
extension_name=$(echo $vss_extension_dev | jq -r '.name' )
83+
echo "Extension Name:" $extension_name
84+
extension_version=$(echo $vss_extension_dev | jq -r '.version')
85+
echo "Extension Version:" $extension_version
86+
echo "Installing tfx-cli..."
87+
npm i -g tfx-cli
88+
echo "Creating extension $extension_name with version $extension_version"
89+
npx tfx-cli extension create --manifest-globs vss-extension-dev.json
90+
echo "Extension $extension_name created successfully!"
91+
echo "Publishing extension $extension_name with version $extension_version"
92+
tfx extension publish --publisher ${PUBLISHER_NAME} --manifest-globs vss-extension-dev.json --token ${USER_TOKEN} | tee tfx_output.log
93+
publish_exit_code=${PIPESTATUS[0]}
94+
if [ $publish_exit_code -eq 0 ]; then
95+
echo "Extension $extension_name with version $extension_version published successfully!"
96+
else
97+
echo "Failed to publish the extension $extension_name with version $extension_version."
98+
exit 1
99+
fi
100+
101+
102+
- name: update extension version in file
103+
id: update-extension-version
104+
if: ${{ steps.publish-qaextension.conclusion == 'success' }}
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
107+
run: |
108+
echo "Updating extension version in vss-extension-dev.json & extension_version.txt file"
109+
git config --local user.name "$(git log -n 1 --pretty=format:%an)"
110+
git config --local user.email "$(git log -n 1 --pretty=format:%ae)"
111+
git checkout -b qaextension_version_update
112+
git add vss-extension-dev.json extension_version.txt
113+
git commit -m "update extension version to ${{ env.NEW_VERSION }} [skip ci]"
114+
git push origin qaextension_version_update
115+
echo gh --version
116+
gh pr create --base main --head qaextension_version_update --title "Version upgrade to ${{ env.NEW_VERSION }}" --body "${{ env.EXTENSION_NAME }} version upgrade to ${{ env.NEW_VERSION }}"
117+
gh pr merge --squash --subject "Extension version upgrade to ${{ env.NEW_VERSION }} [skip ci]" --delete-branch
118+
119+
- name: Upload Artifact
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: ${{ env.EXTENSION_NAME }}-${{ env.NEW_VERSION }}.vsix
123+
path: "*.vsix"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: publish-blackduck-extension
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
isPublish:
7+
description: 'DO YOU WANT TO PUBLISH BLACK DUCK EXTENSION TO MARKETPLACE'
8+
required: true
9+
default: false
10+
type: boolean
11+
12+
jobs:
13+
publish-blackduck-extension:
14+
if: ${{ github.event.inputs.isPublish == 'true' }}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set Node.js 20.x
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20.x
23+
24+
- name: Compare the expected and actual dist/ directories
25+
run: |
26+
cd blackduck-security-task
27+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
28+
echo "Detected uncommitted changes after build. See status below:"
29+
git diff
30+
exit 1
31+
fi
32+
id: diff
33+
34+
- name: publish-Extension
35+
id: publish-extension
36+
env:
37+
PROD_PUBLISHER_NAME: ${{ secrets.PROD_PUBLISHER_NAME }}
38+
PROD_ORGANIZATION_NAME: ${{ secrets.PROD_ORG_NAME }}
39+
PROD_USER_TOKEN: ${{ secrets.PROD_USER_TOKEN }} #personal_access_token of azure devops account
40+
run: |
41+
extension_name=$(jq -r '.name' < vss-extension.json)
42+
echo "EXTENSION_NAME=$extension_name" >> $GITHUB_ENV
43+
echo "EXTENSION NAME: "$extension_name
44+
extension_version=$(jq -r '.version' < vss-extension.json)
45+
echo "EXTENSION_VERSION=$extension_version" >> $GITHUB_ENV
46+
echo "EXTENSION VERSION: " $extension_version
47+
echo "Installing tfx-cli..."
48+
npm i -g tfx-cli
49+
echo "Creating extension $extension_name with version $extension_version"
50+
npx tfx-cli extension create --manifest-globs vss-extension.json
51+
echo "Extension $extension_name created successfully!"
52+
echo "Publishing extension $extension_name with version $extension_version"
53+
tfx extension publish --publisher ${PROD_PUBLISHER_NAME} --manifest-globs vss-extension.json --token ${PROD_USER_TOKEN} | tee tfx_output.log
54+
publish_exit_code=${PIPESTATUS[0]}
55+
if [ $publish_exit_code -eq 0 ]; then
56+
echo "Extension $extension_name with version $extension_version published successfully!"
57+
else
58+
echo "Failed to publish the extension $extension_name with version $extension_version."
59+
exit 1
60+
fi
61+
62+
- name: Upload Artifact
63+
uses: actions/upload-artifact@v4
64+
if: ${{ steps.publish-extension.conclusion == 'success' }}
65+
with:
66+
name: ${{ env.EXTENSION_NAME }}-${{ env.EXTENSION_VERSION }}.vsix
67+
path: "*.vsix"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: upgrade-extension-version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'EXTENSION VERSION'
8+
required: true
9+
default: ""
10+
type: string
11+
12+
jobs:
13+
upgrade-extension-version:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set Node.js 20.x
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20.x
22+
23+
- name: Install dependencies
24+
run: cd blackduck-security-task && npm ci
25+
26+
- name: Rebuild the dist/ directory
27+
run: cd blackduck-security-task && npm run build && npm run package
28+
29+
- name: Compare the expected and actual dist/ directories
30+
run: |
31+
cd blackduck-security-task
32+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
33+
echo "Detected uncommitted changes after build. See status below:"
34+
git diff
35+
exit 1
36+
fi
37+
id: diff
38+
39+
- name: versioning
40+
id: version-update
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
43+
run: |
44+
extension_name=$(jq -r '.name' < vss-extension.json)
45+
echo "EXTENSION_NAME=$extension_name" >> $GITHUB_ENV
46+
echo "EXTENSION NAME: "$extension_name
47+
current_extension_version=${{ github.event.inputs.version }}
48+
echo "CURRENT_VERSION=$current_extension_version" >> $GITHUB_ENV
49+
echo "CURRENT EXTENSION VERSION: " $current_extension_version
50+
current_major=$(echo $current_extension_version | awk -F. '{print $1}')
51+
current_minor=$(echo $current_extension_version | awk -F. '{print $2}')
52+
current_patch=$(echo $current_extension_version | awk -F. '{print $3}')
53+
54+
new_version=$current_extension_version
55+
echo "Updating vss-extension.json with the new version: ${new_version}"
56+
jq --arg new_version "$new_version" '.version = $new_version' vss-extension.json > vss-extension.json.tmp && mv vss-extension.json.tmp vss-extension.json
57+
echo "Updated vss-extension.json file"
58+
cat vss-extension.json
59+
echo
60+
61+
echo "Updating vss-extension-dev.json with the new version: ${new_version}"
62+
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
63+
echo "Updated vss-extension-dev.json file"
64+
cat vss-extension-dev.json
65+
echo
66+
67+
cd blackduck-security-task
68+
echo "Updating package.json with the new version: ${new_version}"
69+
jq --arg new_version "$new_version" '.version = $new_version' package.json > package.json.tmp && mv package.json.tmp package.json
70+
echo "Updated package.json file"
71+
cat package.json
72+
echo
73+
74+
echo "Updating package-lock.json with the new version: ${new_version}"
75+
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
76+
echo "Updated package-lock.json file"
77+
echo
78+
79+
echo "Updating task.json with the new version: ${new_version}"
80+
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
81+
echo "Updated task.json file"
82+
83+
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
84+
85+
- name: update extension version in file
86+
id: update-extension-version
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
89+
run: |
90+
echo "Updating extension version in vss-extension.json, vss-extension-dev.json, extension_version.txt, package.json, package-lock.json & task.json file"
91+
git config --local user.name "$(git log -n 1 --pretty=format:%an)"
92+
git config --local user.email "$(git log -n 1 --pretty=format:%ae)"
93+
git checkout -b extension_version_update
94+
git pull origin extension_version_update --rebase || true
95+
git add vss-extension.json vss-extension-dev.json extension_version.txt
96+
cd blackduck-security-task
97+
git add package.json package-lock.json task.json
98+
git commit -m "upgrade extension version to ${{ env.NEW_VERSION }} [skip ci]"
99+
git push origin extension_version_update --force
100+
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
101+
echo "Successful updated extension version in vss-extension.json, vss-extension-dev.json, extension_version.txt, package.json, package-lock.json & task.json file..."

.gitlab-ci-template.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
paths:
3333
- .m2/
3434
script:
35-
- cd blackduck-task
35+
- cd blackduck-security-task
3636
- npm ci
3737
- npm run format && npm run lint && npm run build && npm run package
3838

0 commit comments

Comments
 (0)