Skip to content

Commit 791f06f

Browse files
committed
ci: update version handling in build workflow
1 parent 602e160 commit 791f06f

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: "Optional VSCode version (x.y.z)"
7+
description: "Optional VSCode version (x.y or x.y.z)"
88
required: false
99
type: string
1010
schedule:
@@ -20,7 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
outputs:
2222
should_build: ${{ steps.check.outputs.should_build }}
23-
latest_tag: ${{ steps.get_release_tag.outputs.latest_tag }}
23+
vscode_ref: ${{ steps.get_release_tag.outputs.vscode_ref }}
24+
package_version: ${{ steps.get_release_tag.outputs.package_version }}
2425
steps:
2526
- name: Checkout
2627
uses: actions/checkout@v6
@@ -30,13 +31,26 @@ jobs:
3031
run: |
3132
INPUT_VERSION="${{ github.event.inputs.version }}"
3233
if [ -n "$INPUT_VERSION" ]; then
33-
# Normalize to plain version without leading 'v'
34-
RESOLVED_VERSION="${INPUT_VERSION#v}"
34+
RAW_VERSION="${INPUT_VERSION#v}"
3535
else
36-
RESOLVED_VERSION=$(curl -s https://api.github.com/repos/microsoft/vscode/releases/latest | jq -r .tag_name)
36+
RAW_VERSION=$(curl -s https://api.github.com/repos/microsoft/vscode/releases/latest | jq -r .tag_name)
3737
fi
38-
echo "Using version: $RESOLVED_VERSION"
39-
echo "latest_tag=$RESOLVED_VERSION" >> $GITHUB_OUTPUT
38+
39+
RAW_VERSION="${RAW_VERSION#v}"
40+
41+
if [[ "$RAW_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
42+
PACKAGE_VERSION="${RAW_VERSION}.0"
43+
elif [[ "$RAW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
44+
PACKAGE_VERSION="$RAW_VERSION"
45+
else
46+
echo "Unsupported VSCode version format: $RAW_VERSION"
47+
exit 1
48+
fi
49+
50+
echo "Using VSCode ref: $RAW_VERSION"
51+
echo "Using package version: $PACKAGE_VERSION"
52+
echo "vscode_ref=$RAW_VERSION" >> $GITHUB_OUTPUT
53+
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
4054
4155
- name: Get current package.json version
4256
id: get_current_version
@@ -50,12 +64,12 @@ jobs:
5064
run: |
5165
cd code-oss
5266
CURRENT_VERSION="${{ steps.get_current_version.outputs.current_version }}"
53-
LATEST_TAG="${{ steps.get_release_tag.outputs.latest_tag }}"
67+
PACKAGE_VERSION="${{ steps.get_release_tag.outputs.package_version }}"
5468
INPUT_VERSION="${{ github.event.inputs.version }}"
5569
if [ -n "$INPUT_VERSION" ]; then
56-
echo "Manual version input provided; forcing build for ${LATEST_TAG}"
70+
echo "Manual version input provided; forcing build for ${PACKAGE_VERSION}"
5771
echo "should_build=true" >> $GITHUB_OUTPUT
58-
elif [ "$(printf '%s\n' "${CURRENT_VERSION}" "${LATEST_TAG}" | sort -V | head -n1)" = "${CURRENT_VERSION}" ] && [ "${CURRENT_VERSION}" != "${LATEST_TAG}" ]; then
72+
elif [ "$(printf '%s\n' "${CURRENT_VERSION}" "${PACKAGE_VERSION}" | sort -V | head -n1)" = "${CURRENT_VERSION}" ] && [ "${CURRENT_VERSION}" != "${PACKAGE_VERSION}" ]; then
5973
echo "Version is less than latest tag"
6074
echo "should_build=true" >> $GITHUB_OUTPUT
6175
else
@@ -76,7 +90,7 @@ jobs:
7690
uses: actions/checkout@v6
7791
with:
7892
repository: microsoft/vscode
79-
ref: ${{ needs.check_update.outputs.latest_tag }}
93+
ref: ${{ needs.check_update.outputs.vscode_ref }}
8094
path: vscode
8195
- uses: actions/checkout@v6
8296
with:
@@ -118,7 +132,7 @@ jobs:
118132
cp -vR vscode/.build/web/extensions code-oss/
119133
rsync -vt vscode/resources/server/* code-oss/
120134
121-
cd code-oss && npm version "${{ needs.check_update.outputs.latest_tag }}" --no-git-tag-version
135+
cd code-oss && npm version "${{ needs.check_update.outputs.package_version }}" --no-git-tag-version
122136
123137
# - name: Setup Pages
124138
# uses: actions/configure-pages@v4
@@ -141,7 +155,7 @@ jobs:
141155
git config --global user.email "github-actions[bot]@users.noreply.github.com"
142156
git add -A
143157
# git commit --allow-empty --author="github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
144-
git commit -m "chore: bump version to ${{ needs.check_update.outputs.latest_tag }}"
158+
git commit -m "chore: bump version to ${{ needs.check_update.outputs.package_version }}"
145159
git push origin HEAD:${GITHUB_REF_NAME}
146160
147161
origin="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
@@ -152,7 +166,7 @@ jobs:
152166
git branch -M gh-pages
153167
git remote add origin $origin
154168
git add -A
155-
git commit --allow-empty-message -m "${{ needs.check_update.outputs.latest_tag }}"
169+
git commit --allow-empty-message -m "${{ needs.check_update.outputs.package_version }}"
156170
git push -f origin gh-pages
157171
158172
- name: Package build
@@ -174,7 +188,7 @@ jobs:
174188
- name: Release on GitHub
175189
uses: softprops/action-gh-release@v2
176190
with:
177-
tag_name: ${{ needs.check_update.outputs.latest_tag }}
191+
tag_name: ${{ needs.check_update.outputs.package_version }}
178192
draft: false
179193
generate_release_notes: false
180194
files: |

0 commit comments

Comments
 (0)