Skip to content

Commit f497307

Browse files
committed
Re-enables insiders CI builds
Until the VS Code marketplace can truly handle pre-releases we can't adopt the current limited pre-release provided by VS Code
1 parent a3d6b71 commit f497307

File tree

8 files changed

+134
-15
lines changed

8 files changed

+134
-15
lines changed

.github/workflows/cd-insiders.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Publish Insiders
2+
3+
on:
4+
schedule:
5+
- cron: '0 9 * * *' # every day at 4am EST
6+
workflow_dispatch:
7+
8+
jobs:
9+
check:
10+
name: Check for updates
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
outputs:
15+
status: ${{ steps.earlyexit.outputs.status }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- id: earlyexit
22+
run: |
23+
git config user.name github-actions
24+
git config user.email [email protected]
25+
if git rev-parse origin/insiders >/dev/null 2>&1; then
26+
insidersRef=$(git show-ref -s origin/insiders)
27+
headRef=$(git show-ref --head -s head)
28+
echo "origin/insiders"
29+
echo $insidersRef
30+
echo "HEAD"
31+
echo $headRef
32+
if [ "$insidersRef" = "$headRef" ]; then
33+
echo "No changes since last insiders build. Exiting."
34+
echo "::set-output name=status::unchanged"
35+
exit 0
36+
else
37+
echo "Updating insiders"
38+
git push origin --delete insiders
39+
git checkout -b insiders
40+
git push origin insiders
41+
fi
42+
else
43+
echo "No insiders branch. Creating."
44+
git checkout -b insiders
45+
git push origin insiders
46+
fi
47+
echo "::set-output name=status::changed"
48+
49+
publish:
50+
name: Publish insiders
51+
needs: check
52+
runs-on: ubuntu-latest
53+
if: needs.check.outputs.status == 'changed'
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v3
57+
- name: Setup node
58+
uses: actions/setup-node@v3
59+
with:
60+
node-version: '14'
61+
- name: Install
62+
run: yarn
63+
- name: Apply insiders patch
64+
run: yarn run patch-insiders
65+
- name: Setup Environment
66+
run: node -e "console.log('PACKAGE_VERSION=' + require('./package.json').version + '\nPACKAGE_NAME=' + require('./package.json').name + '-' + require('./package.json').version)" >> $GITHUB_ENV
67+
- name: Package extension
68+
run: yarn run package
69+
- name: Publish extension
70+
run: yarn vsce publish --yarn --packagePath ./${{ env.PACKAGE_NAME }}.vsix -p ${{ secrets.GITLENS_VSCODE_MARKETPLACE_PAT }}
71+
- name: Publish artifact
72+
uses: actions/upload-artifact@v3
73+
with:
74+
name: ${{ env.PACKAGE_NAME }}.vsix
75+
path: ./${{ env.PACKAGE_NAME }}.vsix

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ BACKERS.md
3535
CODE_OF_CONDUCT.md
3636
CONTRIBUTING.md
3737
esbuild.js
38+
README.insiders.md
3839
README.pre.md
3940
svgo.config.js
4041
tsconfig*.json

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ After the version commit and new tags are pushed to GitHub, the [Publish Stable
199199

200200
If the action fails, the VSIX will need to be built locally with `yarn package` and uploaded manually in the marketplace.
201201

202-
### Pre-release edition
202+
### Pre-release edition (currently disabled until VS Code's marketplace supports pre-releases)
203203

204204
The [Publish Pre-release workflow](.github/workflows/cd-pre.yml) is automatically run every AM unless no new changes have been committed to `main`.
205+
206+
### Insiders edition
207+
208+
The [Publish Insiders workflow](.github/workflows/cd-insiders.yml) is automatically run every AM unless no new changes have been committed to `main`.

README.insiders.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> **This is the insiders edition of GitLens for early feedback, and testing. It works best with [VS Code Insiders](https://code.visualstudio.com/insiders).**

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3482,7 +3482,8 @@
34823482
"order": 70
34833483
},
34843484
"gitlens.insiders": {
3485-
"deprecationMessage": "Deprecated. Use the pre-release edition of GitLens instead"
3485+
"deprecationMessage": "Deprecated. Use the Insiders edition of GitLens instead",
3486+
"markdownDeprecationMessage": "Deprecated. Use the [Insiders edition](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens-insiders) of GitLens instead"
34863487
}
34873488
}
34883489
}
@@ -11636,7 +11637,9 @@
1163611637
"lint": "eslint \"src/**/*.ts?(x)\" --fix",
1163711638
"lint:webviews": "eslint \"src/webviews/apps/**/*.ts?(x)\" --fix",
1163811639
"package": "vsce package --yarn",
11640+
"package-insiders": "yarn run patch-insiders && yarn run package",
1163911641
"package-pre": "yarn run patch-pre && yarn run package --pre-release",
11642+
"patch-insiders": "node ./scripts/applyInsidersPatch.js",
1164011643
"patch-pre": "node ./scripts/applyPreReleasePatch.js",
1164111644
"pretty": "prettier --config .prettierrc --loglevel warn --write .",
1164211645
"pub": "vsce publish --yarn",

scripts/applyInsidersPatch.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
const fs = require('fs');
3+
4+
// Patch README
5+
const insert = fs.readFileSync('./README.insiders.md', { encoding: 'utf8' });
6+
const data = fs.readFileSync('./README.md', { encoding: 'utf8' });
7+
fs.writeFileSync('./README.md', `${insert}\n${data}`);
8+
9+
// Patch package.json
10+
const date = new Date(new Date().toLocaleString('en-US', { timeZone: 'America/New_York' }));
11+
let packageJSON = require('../package.json');
12+
13+
packageJSON = JSON.stringify(
14+
{
15+
...packageJSON,
16+
name: `${packageJSON.name}-insiders`,
17+
displayName: 'GitLens (Insiders)',
18+
version: `${String(date.getFullYear())}.${date.getMonth() + 1}.${date.getDate()}${String(
19+
date.getHours(),
20+
).padStart(2, '0')}`,
21+
preview: true,
22+
},
23+
undefined,
24+
'\t',
25+
);
26+
packageJSON += '\n';
27+
28+
fs.writeFileSync('./package.json', packageJSON);

src/extension.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
4949
return undefined;
5050
});
5151

52-
const sw = new Stopwatch(`GitLens${prerelease ? ' (pre-release)' : ''} v${gitlensVersion}`, {
53-
log: {
54-
message: ` activating in ${env.appName}(${codeVersion}) on the ${isWeb ? 'web' : 'desktop'}`,
55-
//${context.extensionRuntime !== ExtensionRuntime.Node ? ' in a webworker' : ''}
52+
const sw = new Stopwatch(
53+
`GitLens${prerelease ? (insiders ? ' (Insiders)' : ' (pre-release)') : ''} v${gitlensVersion}`,
54+
{
55+
log: {
56+
message: ` activating in ${env.appName}(${codeVersion}) on the ${isWeb ? 'web' : 'desktop'}`,
57+
//${context.extensionRuntime !== ExtensionRuntime.Node ? ' in a webworker' : ''}
58+
},
5659
},
57-
});
60+
);
5861

5962
// If we are using the separate insiders extension, ensure that stable isn't also installed
6063
if (insiders) {
@@ -78,11 +81,13 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
7881
// If the build date is older than 14 days then show the expired error message
7982
if (date.getTime() < Date.now() - 14 * 24 * 60 * 60 * 1000) {
8083
sw.stop({
81-
message: ` was NOT activated because this pre-release version (${gitlensVersion}) has expired`,
84+
message: ` was NOT activated because this ${
85+
insiders ? 'insiders' : 'pre-release'
86+
} version (${gitlensVersion}) has expired`,
8287
});
8388

8489
// If we don't use a setTimeout here this notification will get lost for some reason
85-
setTimeout(() => void showPreReleaseExpiredErrorMessage(gitlensVersion), 0);
90+
setTimeout(() => void showPreReleaseExpiredErrorMessage(gitlensVersion, insiders), 0);
8691

8792
return undefined;
8893
}
@@ -98,8 +103,8 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
98103
setKeysForSync(context);
99104

100105
const storage = new Storage(context);
101-
const syncedVersion = storage.get(prerelease ? 'synced:preVersion' : 'synced:version');
102-
const localVersion = storage.get(prerelease ? 'preVersion' : 'version');
106+
const syncedVersion = storage.get(prerelease && !insiders ? 'synced:preVersion' : 'synced:version');
107+
const localVersion = storage.get(prerelease && !insiders ? 'preVersion' : 'version');
103108

104109
let previousVersion: string | undefined;
105110
if (localVersion == null || syncedVersion == null) {
@@ -142,11 +147,11 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
142147

143148
void showWelcomeOrWhatsNew(container, gitlensVersion, previousVersion);
144149

145-
void storage.store(prerelease ? 'preVersion' : 'version', gitlensVersion);
150+
void storage.store(prerelease && !insiders ? 'preVersion' : 'version', gitlensVersion);
146151

147152
// Only update our synced version if the new version is greater
148153
if (syncedVersion == null || compare(gitlensVersion, syncedVersion) === 1) {
149-
void storage.store(prerelease ? 'synced:preVersion' : 'synced:version', gitlensVersion);
154+
void storage.store(prerelease && !insiders ? 'synced:preVersion' : 'synced:version', gitlensVersion);
150155
}
151156

152157
if (outputLevel === OutputLevel.Debug) {

src/messages.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ export function showInsidersErrorMessage() {
111111
);
112112
}
113113

114-
export function showPreReleaseExpiredErrorMessage(version: string) {
114+
export function showPreReleaseExpiredErrorMessage(version: string, insiders: boolean) {
115115
return showMessage(
116116
'error',
117-
`This GitLens pre-release version (${version}) has expired. Please upgrade to a more recent version.`,
117+
`This GitLens ${
118+
insiders ? '(Insiders)' : 'pre-release'
119+
} version (${version}) has expired. Please upgrade to a more recent version.`,
118120
);
119121
}
120122

0 commit comments

Comments
 (0)