-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (97 loc) · 4.38 KB
/
publish-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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 }}
commit_message: ${{ github.event.head_commit.message }}
run: |
name="Synopsys-security-scan"
echo "EXTENSION_NAME=$name"
vss_extension_dev=$(cat vss-extension-dev.json)
azure_extension_version=$(echo $vss_extension_dev | jq -r '.version')
echo "current version: " $azure_extension_version
echo "CURRENT_VERSION=$azure_extension_version" >> $GITHUB_ENV
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)
COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE_HEADER" | awk -F: '{print $1}')
echo "commit message: " $COMMIT_MESSAGE_HEADER
if [[ "$COMMIT_MESSAGE" == "BREAKING CHANGE" ]]; then
version=$((major+1)).0.0
echo "updating extension version $azure_extension_version to $version"
elif [[ "$COMMIT_MESSAGE" == "feat" ]]; then
version=$major.$((minor+1)).0
echo "updating extension version $azure_extension_version to $version"
elif [[ "$COMMIT_MESSAGE" == "fix" ]]; then
version=$major.$minor.$((patch+1))
echo "updating extension version $azure_extension_version to $version"
else
version=$azure_extension_version
fi
if [[ "$azure_extension_version" != "$version" ]]; then
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
echo "NEW_VERSION=$version" >> $GITHUB_ENV
echo "Publishing extension with latest version: $version"
npm i -g tfx-cli
tfx extension publish --publisher TestCIPub --manifest-globs vss-extension-dev.json --token ${USER_TOKEN}
echo "Successful published extension..."
else
echo "No extension version update"
echo "NEW_VERSION=$version" >> $GITHUB_ENV
fi
cat vss-extension-dev.json
echo "AZURE_EXTENSION_VERSION=$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
id: update-extension-version
if: ${{ env.NEW_VERSION != env.CURRENT_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
run: |
echo "Updating version in vss-extension-dev.json..."
echo git config --local user.name "$(git log -n 1 --pretty=format:%an)"
echo git config --local user.email "$(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 add vss-extension-dev.json
git commit -m "update extension version [skip ci]"
git push origin main
echo "Successful updated version in vss-extension-dev.json..."
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: extension-artifact
path: vss-extension-dev.json
# gh pr create --base main --head automatic_version_update --title "pr test" --body "Created by Github action" --fill
# gh pr merge --squash --subject "automated pr merge [skip ci]" --body " merging automated pr changes" --delete-branch
# git branch -d automatic_version_update