Auto Update Keybindings #385
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Update Keybindings | |
on: | |
schedule: | |
- cron: '0 */12 * * *' | |
workflow_dispatch: | |
inputs: {} | |
jobs: | |
get-default-keybindings: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- run: npm ci | |
working-directory: vs-code-default-keybindings/scripts/get_default_keybindings | |
- name: Run get-default-keybindings (Linux) | |
run: xvfb-run -a npm start | |
working-directory: vs-code-default-keybindings/scripts/get_default_keybindings | |
if: runner.os == 'Linux' | |
- name: Run get-default-keybindings (macOS, Windows) | |
run: npm start | |
working-directory: vs-code-default-keybindings/scripts/get_default_keybindings | |
if: runner.os != 'Linux' | |
- name: Upload the output file | |
uses: actions/upload-artifact@v4 | |
with: | |
name: raw-default-keybindings-${{ matrix.os }} | |
path: vs-code-default-keybindings/scripts/*.keybindings.raw.json | |
update_keybindings: | |
runs-on: ubuntu-latest | |
needs: get-default-keybindings | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Download three JSON files | |
uses: actions/download-artifact@v4 | |
- name: Copy JSON files | |
shell: bash | |
run: | | |
cp raw-default-keybindings-ubuntu-latest/linux.keybindings.raw.json vs-code-default-keybindings/scripts/ | |
cp raw-default-keybindings-macos-latest/macos.keybindings.raw.json vs-code-default-keybindings/scripts/ | |
cp raw-default-keybindings-windows-latest/windows.keybindings.raw.json vs-code-default-keybindings/scripts/ | |
- name: Update keybindings files | |
run: python3 process_json.py | |
working-directory: vs-code-default-keybindings/scripts | |
- name: Update Keybindings | |
run: | | |
./scripts/build-keybindings.py | |
- name: Diff | |
id: diff | |
run: | | |
if git diff --exit-code; then | |
echo "has-diff=false" >> $GITHUB_OUTPUT | |
else | |
echo "has-diff=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Bump version | |
if: steps.diff.outputs.has-diff == 'true' | |
run: | | |
npm version patch --no-git-tag-version | |
- name: Update changelog | |
if: steps.diff.outputs.has-diff == 'true' | |
id: changelog | |
run: | | |
version=$(jq -r .version package.json) | |
engineversion=$(jq -r .engines.vscode package.json | tr -d '^') | |
echo "" >> CHANGELOG.md | |
echo "## Release v${version}" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
echo "- Update keybindings for vscode ${engineversion}" >> CHANGELOG.md | |
echo "extension_version=${version}" >> $GITHUB_OUTPUT | |
echo "engine_version=${engineversion}" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
if: steps.diff.outputs.has-diff == 'true' | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.TOKEN }} | |
commit-message: Auto update keybindings from vscode v${{steps.changelog.outputs.engine_version}} | |
title: Auto update keybindings from vscode v${{steps.changelog.outputs.engine_version}} | |
body: | | |
This PR updates the keybindings for vscode ${{steps.changelog.outputs.engine_version}} | |
branch: release/v${{steps.changelog.outputs.extension_version}} |