-
Notifications
You must be signed in to change notification settings - Fork 2
195 lines (169 loc) · 6.78 KB
/
build.yml
File metadata and controls
195 lines (169 loc) · 6.78 KB
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
name: Build VSCode Web
on:
workflow_dispatch:
inputs:
version:
description: "Optional VSCode version (x.y or x.y.z)"
required: false
type: string
schedule:
- cron: "0 0 * * *"
permissions:
contents: write
id-token: write
pages: write
jobs:
check_update:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
vscode_ref: ${{ steps.get_release_tag.outputs.vscode_ref }}
package_version: ${{ steps.get_release_tag.outputs.package_version }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Resolve target VSCode version
id: get_release_tag
run: |
INPUT_VERSION="${{ github.event.inputs.version }}"
if [ -n "$INPUT_VERSION" ]; then
RAW_VERSION="${INPUT_VERSION#v}"
else
RAW_VERSION=$(curl -s https://api.github.com/repos/microsoft/vscode/releases/latest | jq -r .tag_name)
fi
RAW_VERSION="${RAW_VERSION#v}"
if [[ "$RAW_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
PACKAGE_VERSION="${RAW_VERSION}.0"
elif [[ "$RAW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
PACKAGE_VERSION="$RAW_VERSION"
else
echo "Unsupported VSCode version format: $RAW_VERSION"
exit 1
fi
echo "Using VSCode ref: $RAW_VERSION"
echo "Using package version: $PACKAGE_VERSION"
echo "vscode_ref=$RAW_VERSION" >> $GITHUB_OUTPUT
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
- name: Get current package.json version
id: get_current_version
run: |
cd code-oss
CURRENT_VERSION=$(jq -r .version package.json)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Check and update version
id: check
run: |
cd code-oss
CURRENT_VERSION="${{ steps.get_current_version.outputs.current_version }}"
PACKAGE_VERSION="${{ steps.get_release_tag.outputs.package_version }}"
INPUT_VERSION="${{ github.event.inputs.version }}"
if [ -n "$INPUT_VERSION" ]; then
echo "Manual version input provided; forcing build for ${PACKAGE_VERSION}"
echo "should_build=true" >> $GITHUB_OUTPUT
elif [ "$(printf '%s\n' "${CURRENT_VERSION}" "${PACKAGE_VERSION}" | sort -V | head -n1)" = "${CURRENT_VERSION}" ] && [ "${CURRENT_VERSION}" != "${PACKAGE_VERSION}" ]; then
echo "Version is less than latest tag"
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "Version is up to date or greater, skipping build steps"
echo "should_build=false" >> $GITHUB_OUTPUT
fi
build_and_deploy:
runs-on: ubuntu-latest
needs: check_update
if: needs.check_update.outputs.should_build == 'true'
steps:
- name: Checkout
uses: actions/checkout@v6
# git clone --branch x.y.z --single-branch https://github.com/microsoft/vscode.git --depth=1
- name: Checkout VSCode repository
uses: actions/checkout@v6
with:
repository: microsoft/vscode
ref: ${{ needs.check_update.outputs.vscode_ref }}
path: vscode
- uses: actions/checkout@v6
with:
repository: microsoft/vscode-loc
path: vscode-loc
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: vscode/.nvmrc
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential g++ libx11-dev libxkbfile-dev libsecret-1-dev libkrb5-dev python-is-python3
cd vscode && npm ci
- name: Build VSCode Web
run: |
cd vscode
npm run gulp compile-build-without-mangling # out-build
npm run gulp vscode-web-ci # out-vscode-web .build/web/extensions
- name: Copy build
run: |
node nls.mjs
deps_json=$(jq '.dependencies // {}' vscode/remote/web/package.json)
deps_keys=$(jq '.dependencies // {} | keys' vscode/remote/web/package.json)
jq --argjson deps "$deps_json" --argjson bundled "$deps_keys" '
.dependencies = $deps
| .bundledDependencies = $bundled
' code-oss/package.json > code-oss/package.json.tmp
cat code-oss/package.json.tmp
mv code-oss/package.json.tmp code-oss/package.json
cp -vR vscode/remote/web/node_modules code-oss/
cp -vR vscode/out-vscode-web code-oss/out
cp -vR vscode/.build/web/extensions code-oss/
rsync -vt vscode/resources/server/* code-oss/
cd code-oss && npm version "${{ needs.check_update.outputs.package_version }}" --no-git-tag-version
# - name: Setup Pages
# uses: actions/configure-pages@v4
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v3
# with:
# path: "./code-oss"
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4
- name: Commit and push version bump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global init.defaultBranch main
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add -A
# git commit --allow-empty --author="github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
git commit -m "chore: bump version to ${{ needs.check_update.outputs.package_version }}"
git push origin HEAD:${GITHUB_REF_NAME}
origin="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
tmp_dir=$(mktemp -d -t code-oss-XXX)
cp -R code-oss/* $tmp_dir
cd $tmp_dir
git init
git branch -M gh-pages
git remote add origin $origin
git add -A
git commit --allow-empty-message -m "${{ needs.check_update.outputs.package_version }}"
git push -f origin gh-pages
- name: Package build
run: |
ls -ahlF code-oss
cp README.md code-oss/
cd code-oss
cat package.json
npm pack
- name: Publishing on NPM
uses: JS-DevTools/npm-publish@v4
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./code-oss
access: public
provenance: true
- name: Release on GitHub
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.check_update.outputs.package_version }}
draft: false
generate_release_notes: false
files: |
code-oss/code-oss-*.tgz