-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (159 loc) · 5.76 KB
/
build-release.yaml
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
name: Build and Release VSIX
on:
workflow_dispatch:
push:
branches:
- main
- master
env:
PUBLISHER_NAME: blazium-engine
concurrency:
group: ci-anko-runner
cancel-in-progress: true
jobs:
get-latest-sha:
name: 🔍 Get Latest SHA & Base Version
runs-on: windows-latest
outputs:
version_string: ${{ steps.new_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: blazium-engine/vscode-anko-highlighter
ref: master
fetch-depth: 2
- name: Get Latest Commit SHA
id: get_sha
run: echo "sha=$(git rev-parse HEAD)" >> $ENV:GITHUB_OUTPUT
- name: Generate Changelog.json
id: new_version
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_OWNER: blazium-engine
GITHUB_REPO: vscode-anko-highlighter
BASE_BRANCH: 0acc2206c2a57f104d3295ec4e5b5ce7b7d9d4dd
CURRENT_BRANCH: ${{ steps.get_sha.outputs.sha }}
MAJOR_VERSION: 0
MINOR_VERSION: 0
PATCH_VERSION: 2
run: |
# Ensure the working directory is correct
Set-Location -Path "${{ github.workspace }}"
# Trigger the changelog generation script
node ./scripts/changelog.js $(Get-Location)
# Validate if changelog.json exists
if (-Not (Test-Path -Path "changelog.json")) {
Write-Error "changelog.json not found."
exit 1
}
# Parse changelog.json to extract version information
$changelog = Get-Content -Raw -Path "changelog.json" | ConvertFrom-Json
$major = $changelog.version.major
$minor = $changelog.version.minor
$patch = $changelog.version.patch
# Combine version variables into a single variable
$version = "$major.$minor.$patch"
# Set outputs
echo "version=$version" >> $ENV:GITHUB_OUTPUT
# Create a debug summary
$summary = @(
"# Version Information",
"- Major: $major",
"- Minor: $minor",
"- Patch: $patch",
"- Full Version: $version"
) -join "`n"
echo $summary >> $ENV:GITHUB_STEP_SUMMARY
build:
name: Building VSIX Package
needs: get-latest-sha
runs-on: windows-latest
outputs:
version: ${{ steps.update_version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Install dependencies
run: |
cd .\anko\
npm install
- name: Update Package Version
id: update_version
run: |
# Ensure the working directory is correct
Set-Location -Path "${{ github.workspace }}"
# Load the package.json file
$packageJsonPath = "./anko/package.json"
if (-Not (Test-Path -Path $packageJsonPath)) {
Write-Error "package.json not found at $packageJsonPath."
exit 1
}
# Update the version field
$packageJson = Get-Content -Raw -Path $packageJsonPath | ConvertFrom-Json
$packageJson.version = "${{ needs.get-latest-sha.outputs.version_string }}"
# Save the updated package.json
$packageJson | ConvertTo-Json -Depth 10 | Set-Content -Path $packageJsonPath -Encoding utf8
# Log the update
Write-Host "Updated version to $($packageJson.version) in package.json."
echo "version=${{ needs.get-latest-sha.outputs.version_string }}" >> $ENV:GITHUB_OUTPUT
- name: Build VSIX file
run: |
cd .\anko\
vsce package --out ..\dist\blazium-anko-extension-${{ needs.get-latest-sha.outputs.version_string }}.vsix
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: blazium-anko-extension-vsix
path: dist/blazium-anko-extension-${{ needs.get-latest-sha.outputs.version_string }}.vsix
retention-days: 1
release:
name: Deploy Github Release for Anko Highlighter
needs: build
runs-on: windows-latest
permissions:
contents: write # Grants write permissions for content operations
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: blazium-anko-extension-vsix
path: ${{ github.workspace }}\dist
- name: Create GitHub Release
id: createRelease
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.version }}
release_name: Blazium Anko Extension v${{ needs.build.outputs.version }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ${{ github.workspace }}\dist\blazium-anko-extension-${{ needs.build.outputs.version }}.vsix
asset_name: blazium-anko-extension-${{ needs.build.outputs.version }}.vsix
asset_content_type: application/octet-stream
- name: Deploy to Visual Studio Marketplace
env:
VSCE_PAT: ${{ secrets.VS_MARKETPLACE_PAT }}
run: |
vsce verify-pat ${{ env.PUBLISHER_NAME }}
vsce login ${{ env.PUBLISHER_NAME }}
vsce publish --packagePath ${{ github.workspace }}\dist\blazium-anko-extension-${{ needs.build.outputs.version }}.vsix