Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflow file option #188

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,17 @@ module.exports = class extends Generator {
generator.extensionConfig.pkgManager = pckgManagerAnswer.pkgManager;
});
},

askForGithubWorkflows: () => {
return generator.prompt({
type: 'confirm',
name: 'gitHubWorkFlowInit',
message: 'Include GitHub workflow file?',
default: true
}).then(gitAnswer => {
generator.extensionConfig.gitHubWorkFlowInit = gitAnswer.gitHubWorkFlowInit;
});
},
};

// run all prompts in sequence. Results can be ignored.
Expand Down Expand Up @@ -567,6 +578,9 @@ module.exports = class extends Generator {
this.fs.copy(this.sourceRoot() + '/gitignore', context.name + '/.gitignore');
this.fs.copy(this.sourceRoot() + '/gitattributes', context.name + '/.gitattributes');
}
if (this.extensionConfig.gitHubWorkFlowInit) {
this.fs.copy(this.sourceRoot() + '/github', context.name + '/.github');
}
}

// Write Color Theme Extension
Expand Down Expand Up @@ -600,6 +614,9 @@ module.exports = class extends Generator {
this.fs.copy(this.sourceRoot() + '/gitignore', context.name + '/.gitignore');
this.fs.copy(this.sourceRoot() + '/gitattributes', context.name + '/.gitattributes');
}
if (this.extensionConfig.gitHubWorkFlowInit) {
this.fs.copy(this.sourceRoot() + '/github', context.name + '/.github');
}
}

// Write Language Extension
Expand All @@ -624,6 +641,9 @@ module.exports = class extends Generator {
this.fs.copy(this.sourceRoot() + '/gitignore', context.name + '/.gitignore');
this.fs.copy(this.sourceRoot() + '/gitattributes', context.name + '/.gitattributes');
}
if (this.extensionConfig.gitHubWorkFlowInit) {
this.fs.copy(this.sourceRoot() + '/github', context.name + '/.github');
}
}

// Write Snippets Extension
Expand All @@ -641,6 +661,9 @@ module.exports = class extends Generator {
this.fs.copy(this.sourceRoot() + '/gitignore', context.name + '/.gitignore');
this.fs.copy(this.sourceRoot() + '/gitattributes', context.name + '/.gitattributes');
}
if (this.extensionConfig.gitHubWorkFlowInit) {
this.fs.copy(this.sourceRoot() + '/github', context.name + '/.github');
}
}

// Write Snippets Extension
Expand All @@ -657,6 +680,9 @@ module.exports = class extends Generator {
this.fs.copy(this.sourceRoot() + '/gitignore', context.name + '/.gitignore');
this.fs.copy(this.sourceRoot() + '/gitattributes', context.name + '/.gitattributes');
}
if (this.extensionConfig.gitHubWorkFlowInit) {
this.fs.copy(this.sourceRoot() + '/github', context.name + '/.github');
}
}

// Write Command Extension (TypeScript)
Expand All @@ -680,6 +706,10 @@ module.exports = class extends Generator {

this.fs.copy(this.sourceRoot() + '/tslint.json', context.name + '/tslint.json');

if (this.extensionConfig.gitHubWorkFlowInit) {
this.fs.copy(this.sourceRoot() + '/github', context.name + '/.github');
}

this.extensionConfig.installDependencies = true;
}

Expand All @@ -705,6 +735,10 @@ module.exports = class extends Generator {
this.fs.copyTpl(this.sourceRoot() + '/package.json', context.name + '/package.json', context);
this.fs.copyTpl(this.sourceRoot() + '/.eslintrc.json', context.name + '/.eslintrc.json', context);

if (this.extensionConfig.gitHubWorkFlowInit) {
this.fs.copy(this.sourceRoot() + '/github', context.name + '/.github');
}

this.extensionConfig.installDependencies = true;
}

Expand Down
6 changes: 5 additions & 1 deletion generators/app/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ exports.writingLocalizationExtension = (generator) => {
generator.fs.copy(generator.sourceRoot() + '/gitignore', context.name + '/.gitignore');
generator.fs.copy(generator.sourceRoot() + '/gitattributes', context.name + '/.gitattributes');

if (context.gitHubWorkFlowInit) {
generator.fs.copy(generator.sourceRoot() + '/github', context.name + '/.github');
}

context.installDependencies = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Package extension
run: |
tag=${GITHUB_REF#refs/tags/}
echo "Setting package version $tag"
npm --no-git-tag-version version "$tag"
npx vsce package
- name: Publish extension to marketplace
env:
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
run: |
npx vsce publish -p "$AZURE_TOKEN"
4 changes: 2 additions & 2 deletions generators/app/templates/ext-colortheme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": <%- JSON.stringify(name) %>,
"displayName": <%- JSON.stringify(displayName) %>,
"description": <%- JSON.stringify(description) %>,
"version": "0.0.1",
"version": "<% if (gitHubWorkFlowInit) { %>0.0.0<% } else { %>0.0.1<% } %>",
"engines": {
"vscode": <%- JSON.stringify(vsCodeEngine) %>
},
Expand All @@ -18,4 +18,4 @@
}
]
}
}
}
1 change: 1 addition & 0 deletions generators/app/templates/ext-colortheme/vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
.github/**
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test & Publish
on:
push:
release:
types: [published]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Start Xvfb
run: |
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
if: matrix.os == 'ubuntu-latest'
- name: Test extension on ${{ matrix.os }}
run: |
npm ci
npm test
env:
DISPLAY: ':99.0'
CI: 'true'

publish:
needs: [test]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Package extension
run: |
tag=${GITHUB_REF#refs/tags/}
echo "Setting package version $tag"
npm --no-git-tag-version version "$tag"
npx vsce package
- name: Publish extension to marketplace
env:
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
run: |
npx vsce publish -p "$AZURE_TOKEN"
2 changes: 1 addition & 1 deletion generators/app/templates/ext-command-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": <%- JSON.stringify(name) %>,
"displayName": <%- JSON.stringify(displayName) %>,
"description": <%- JSON.stringify(description) %>,
"version": "0.0.1",
"version": "<% if (gitHubWorkFlowInit) { %>0.0.0<% } else { %>0.0.1<% } %>",
"engines": {
"vscode": <%- JSON.stringify(vsCodeEngine) %>
},
Expand Down
1 change: 1 addition & 0 deletions generators/app/templates/ext-command-js/vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ vsc-extension-quickstart.md
**/jsconfig.json
**/*.map
**/.eslintrc.json
.github/**
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test & Publish
on:
push:
release:
types: [published]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Start Xvfb
run: |
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
if: matrix.os == 'ubuntu-latest'
- name: Test extension on ${{ matrix.os }}
run: |
npm ci
npm test
env:
DISPLAY: ':99.0'
CI: 'true'

publish:
needs: [test]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Package extension
run: |
tag=${GITHUB_REF#refs/tags/}
echo "Setting package version $tag"
npm --no-git-tag-version version "$tag"
npx vsce package
- name: Publish extension to marketplace
env:
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
run: |
npx vsce publish -p "$AZURE_TOKEN"
2 changes: 1 addition & 1 deletion generators/app/templates/ext-command-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": <%- JSON.stringify(name) %>,
"displayName": <%- JSON.stringify(displayName) %>,
"description": <%- JSON.stringify(description) %>,
"version": "0.0.1",
"version": "<% if (gitHubWorkFlowInit) { %>0.0.0<% } else { %>0.0.1<% } %>",
"engines": {
"vscode": <%- JSON.stringify(vsCodeEngine) %>
},
Expand Down
3 changes: 2 additions & 1 deletion generators/app/templates/ext-command-ts/vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
**/*.ts
.github/**
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Package extension
run: |
tag=${GITHUB_REF#refs/tags/}
echo "Setting package version $tag"
npm --no-git-tag-version version "$tag"
npx vsce package
- name: Publish extension to marketplace
env:
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
run: |
npx vsce publish -p "$AZURE_TOKEN"
4 changes: 2 additions & 2 deletions generators/app/templates/ext-extensionpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": <%- JSON.stringify(name) %>,
"displayName": <%- JSON.stringify(displayName) %>,
"description": <%- JSON.stringify(description) %>,
"version": "0.0.1",
"version": "<% if (gitHubWorkFlowInit) { %>0.0.0<% } else { %>0.0.1<% } %>",
"engines": {
"vscode": <%- JSON.stringify(vsCodeEngine) %>
},
Expand All @@ -13,4 +13,4 @@
"<%- extensionList[i] %>", <%}%>
"<%- extensionList[extensionList.length-1]%>"
]
}
}
1 change: 1 addition & 0 deletions generators/app/templates/ext-extensionpack/vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
.github/**
24 changes: 24 additions & 0 deletions generators/app/templates/ext-keymap/github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Package extension
run: |
tag=${GITHUB_REF#refs/tags/}
echo "Setting package version $tag"
npm --no-git-tag-version version "$tag"
npx vsce package
- name: Publish extension to marketplace
env:
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
run: |
npx vsce publish -p "$AZURE_TOKEN"
4 changes: 2 additions & 2 deletions generators/app/templates/ext-keymap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": <%- JSON.stringify(name) %>,
"displayName": <%- JSON.stringify(displayName) %>,
"description": <%- JSON.stringify(description) %>,
"version": "0.0.1",
"version": "<% if (gitHubWorkFlowInit) { %>0.0.0<% } else { %>0.0.1<% } %>",
"engines": {
"vscode": <%- JSON.stringify(vsCodeEngine) %>
},
Expand All @@ -17,4 +17,4 @@
}
]
}
}
}
1 change: 1 addition & 0 deletions generators/app/templates/ext-keymap/vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
.github/**
24 changes: 24 additions & 0 deletions generators/app/templates/ext-language/github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Package extension
run: |
tag=${GITHUB_REF#refs/tags/}
echo "Setting package version $tag"
npm --no-git-tag-version version "$tag"
npx vsce package
- name: Publish extension to marketplace
env:
AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
run: |
npx vsce publish -p "$AZURE_TOKEN"
Loading