Skip to content

Commit c1b5587

Browse files
committed
Publish prereleases
Fixes #1155 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent b9fbe94 commit c1b5587

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: release
22

33
on:
4+
schedule:
5+
- cron: '0 8 * * *'
46
workflow_dispatch:
57
inputs:
68
publishPreRelease:
@@ -39,10 +41,19 @@ jobs:
3941
with:
4042
path: release
4143
node-version: 20
44+
- name: Set version to prerelease version
45+
run: |
46+
node change-version-to-prerelease.mjs
47+
echo "publishPreReleaseFlag=--pre-release" >> $GITHUB_ENV
48+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true'}}
4249
- name: Install dependencies
4350
run: |
4451
npm install -g typescript "@vscode/vsce" "ovsx"
4552
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
53+
# Install latest yaml-language-server in the case of a prerelease
54+
- name: Update yaml-language-server
55+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true'}}
56+
run: npm i yaml-language-server@next
4657
- name: Build vscode-yaml
4758
uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 #v1.0.1
4859
with:
@@ -56,7 +67,7 @@ jobs:
5667
run: npm test --silent
5768
- name: Package
5869
run: |
59-
vsce package -o vscode-yaml-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
70+
vsce package ${{ env.publishPreReleaseFlag }} -o vscode-yaml-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
6071
sha256sum *.vsix > vscode-yaml-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix.sha256
6172
ls -lash *.vsix *.sha256
6273
- name: Upload VSIX Artifacts
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as fs from 'fs/promises';
2+
3+
function prependZero(number) {
4+
if (number > 99) {
5+
throw 'Unexpected value to prepend with zero';
6+
}
7+
return `${number < 10 ? '0' : ''}${number}`;
8+
}
9+
10+
const json = JSON.parse((await fs.readFile('./package.json')).toString());
11+
const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/);
12+
const major = stableVersion[1];
13+
const minor = stableVersion[2];
14+
const date = new Date();
15+
const month = date.getMonth() + 1;
16+
const day = date.getDate();
17+
const hours = date.getHours();
18+
const patch = `${date.getFullYear()}${prependZero(month)}${prependZero(day)}${prependZero(hours)}`;
19+
const insiderPackageJson = Object.assign(json, {
20+
version: `${major}.${minor}.${patch}`,
21+
});
22+
await fs.writeFile('./package.json', JSON.stringify(insiderPackageJson, null, 2));

0 commit comments

Comments
 (0)