-
Notifications
You must be signed in to change notification settings - Fork 6
201 lines (179 loc) · 6.51 KB
/
release.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: VSCode Release
on:
workflow_call:
inputs:
jsTag:
description: "JS Wrapper tag name"
required: false
type: string
default: nightly
vscodeTag:
description: "Tag name"
required: false
type: string
default: nightly
dev:
description: "Is dev build"
required: false
default: true
type: boolean
publish:
description: "Publish to marketplace"
required: false
default: true
type: boolean
workflow_dispatch:
inputs:
jsTag:
description: "JSW tag name (ignored if not dev build)"
required: false
vscodeTag:
description: "Tag name (ignored if not dev build)"
required: false
dev:
description: "Is dev build"
required: false
default: true
type: boolean
publish:
description: "Publish to marketplace"
required: false
default: false
type: boolean
permissions:
id-token: write
contents: write
packages: write
pull-requests: write
jobs:
delete:
uses: Checkmarx/ast-vscode-extension/.github/workflows/delete-dev-releases.yml@main
with:
tag: ${{ inputs.vscodeTag }}
secrets: inherit
if: inputs.dev
release:
runs-on: ubuntu-latest
env:
BRANCH_NAME: update-npm-version
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
steps:
# CHECKOUT PROJECT
- name: Checkout
uses: actions/[email protected]
# GIT CONFIGURATION
- run: |
git config user.name vscode-releases
git config user.email [email protected]
# AUTHENTICATE TO GITHUB PACKAGE REGISTRY
- name: Authenticate with GitHub package registry
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
# SETUP NODE
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.15.0
# GET TAG NAME
- name: Generate Tag name
run: |
if [ ${{ inputs.dev }} == true ]; then
echo "TAG_NAME=$(npm version prerelease --preid=${{ inputs.vscodeTag }} --no-git-tag-version --allow-same-version)" >> $GITHUB_ENV
else
echo "TAG_NAME=$(npm version minor --no-git-tag-version)" >> $GITHUB_ENV
fi
# INSTALL NPM DEPENDENCIES
- name: Install dependencies
run: npm install
# GET AND INSTALL JS WRAPPER VERSION PROVIDED BY USER
- name: Get and install JS Wrapper if provided by user
if: inputs.dev == true && inputs.jsTag != ''
run: |
echo "Getting js wrapper ${{inputs.jsTag}} version..."
JS_VERSION_NAME=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper/versions | jq '.[]|select((.name | contains("-${{inputs.jsTag}}.0")) or .name == "${{inputs.jsTag}}")|.name' | tr -d '"')
if [ ${JS_VERSION_NAME} != '' ]; then
echo "Install JS Wrapper version ${JS_VERSION_NAME}"
npm install "@checkmarxdev/ast-cli-javascript-wrapper@"${JS_VERSION_NAME}
else
echo "JS wrapper with version ${JS_VERSION_NAME} not found"
fi
# INSTALL VSCE
- name: Install VSCE
run: npm install -g vsce
# PACKAGE PROJECT
- name: Package .vsix file
run: |
if [ ${{ inputs.dev }} == true ]; then
node .github/scripts/updateDevVersion.js
vsce package --pre-release
else
vsce package
fi
# CREATE GH RELEASE NAME
- name: Handle GH Release name
run: |
VSIX_TAG_NAME=$(cat package.json | jq .version | cut -d'"' -f 2)
echo "VSIX_TAG_NAME=$VSIX_TAG_NAME" >> $GITHUB_ENV
if [ ${{ inputs.dev }} == true ]; then
echo "GH_RELEASE_NAME=${{env.TAG_NAME}} (${VSIX_TAG_NAME})" >> $GITHUB_ENV
else
echo "GH_RELEASE_NAME=${{env.TAG_NAME}}" >> $GITHUB_ENV
fi
# CREATE PR FOR VERSION
- name: Create Pull Request
id: create_pr
if: inputs.dev == false
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e #v6.0.5
with:
token: ${{ env.GITHUB_TOKEN }}
branch: ${{ env.BRANCH_NAME }}
title: "Update Version - Automated Changes"
body: "This is an automated PR created by GitHub Actions"
base: main
draft: false
# WAIT FOR PR CREATION
- name: Wait for PR to be created
id: pr
if: inputs.dev == false
uses: octokit/request-action@872c5c97b3c85c23516a572f02b31401ef82415d #v2.3.1
with:
route: GET /repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ env.BRANCH_NAME }}
# MERGE PR TO MAIN
- name: Merge Pull Request
if: inputs.dev == false
uses: octokit/request-action@872c5c97b3c85c23516a572f02b31401ef82415d #v2.3.1
with:
route: PUT /repos/${{ github.repository }}/pulls/${{ steps.create_pr.outputs.pull-request-number }}/merge
merge_method: squash
# PUSH TAGS IF IT IS A RELEASE
- name: Push tag
if: inputs.dev == false
run: |
git pull
git tag ${{ env.TAG_NAME }}
git push --tags
# CREATE GH RELEASE
- name: Create Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 #v1
with:
name: ${{env.GH_RELEASE_NAME}}
tag_name: ${{env.TAG_NAME}}
generate_release_notes: true
files: ast-results-${{env.VSIX_TAG_NAME}}.vsix
prerelease: ${{ inputs.dev }}
# PUBLISH TO MARKETPLACE
- name: Publish
env:
MARKET_TOKEN: ${{ secrets.MARKET_TOKEN }}
if: env.MARKET_TOKEN != null && (inputs.dev == false || (inputs.dev == true && inputs.publish == true))
run: |
if [ ${{ inputs.dev }} == true ]; then
vsce publish --pre-release -p ${{ env.MARKET_TOKEN }}
else
vsce publish -p ${{ env.MARKET_TOKEN }}
fi
# GENERATE AND WRITE CHANGELOG TO FILE
- name: Generate release changelog
uses: BobAnkh/auto-generate-changelog@b8e208489ce4f71adc3b6467020dd276f1445e8a #v1.2.5
with:
ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
PATH: "CHANGELOG.md"