Skip to content

Commit cd18d31

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

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
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,17 @@ jobs:
3941
with:
4042
path: release
4143
node-version: 20
44+
- name: Set version to prerelease version
45+
run: node change-version-to-prerelease.mjs
46+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true'}}
4247
- name: Install dependencies
4348
run: |
4449
npm install -g typescript "@vscode/vsce" "ovsx"
4550
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
51+
# Install latest yaml-language-server in the case of a prerelease
52+
- name: Update yaml-language-server
53+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true'}}
54+
run: npm i yaml-language-server@next
4655
- name: Build vscode-yaml
4756
uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 #v1.0.1
4857
with:
@@ -55,10 +64,17 @@ jobs:
5564
with:
5665
run: npm test --silent
5766
- name: Package
67+
if: ${{ github.event_name != 'schedule' && inputs.publishPreRelease == 'false'}}
5868
run: |
5969
vsce package -o vscode-yaml-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
6070
sha256sum *.vsix > vscode-yaml-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix.sha256
6171
ls -lash *.vsix *.sha256
72+
- name: Package pre-release
73+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true'}}
74+
run: |
75+
vsce package --pre-release -o vscode-yaml-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
76+
sha256sum *.vsix > vscode-yaml-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix.sha256
77+
ls -lash *.vsix *.sha256
6278
- name: Upload VSIX Artifacts
6379
uses: actions/upload-artifact@v4
6480
with:
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)