Version 0.65.1 #1599
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: Test, Build, and Publish | |
on: | |
push: | |
branches: ["main"] | |
tags: ["v*"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
type: ["native"] | |
include: | |
- os: ubuntu-latest | |
type: "web" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: "npm" | |
- name: Install dependencies | |
run: npm ci | |
- name: ESLint & Prettier | |
run: | | |
npm run check:eslint | |
npm run check:prettier | |
- name: Test keybinding generator | |
run: | | |
npm run test-gen-keys | |
npm run gen-keys | |
git diff --quiet || (echo "You have to run 'npm run gen-keys' and commit the updated package.json" && exit -1) | |
- name: Test | |
run: xvfb-run -a npm test | |
if: runner.os == 'Linux' && matrix.type == 'native' | |
- name: Test | |
run: npm run test | |
if: runner.os != 'Linux' && matrix.type == 'native' | |
- name: Test Web | |
run: npm run test:web -- --headless | |
if: matrix.type == 'web' | |
# Ref: https://github.com/redhat-developer/vscode-yaml/blob/89c53763249932454b766d09e7aa9035da7fb5b8/.github/workflows/CI.yaml#L48-L61 | |
- name: Build the vsix package on Linux | |
if: matrix.os == 'ubuntu-latest' && matrix.type == 'native' | |
run: | | |
if [ $IS_RELEASE = true ]; then | |
VERSION=$(node -p "require('./package.json').version") | |
else | |
VERSION=${{ github.sha }} | |
fi | |
if [ ${IS_PRE_RELEASE} = true ]; then | |
FLAGS="--pre-release" | |
else | |
FLAGS="" | |
fi | |
npm exec -- vsce package -o emacs-mcx-${VERSION}-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}.vsix ${FLAGS} | |
env: | |
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
IS_PRE_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') }} | |
- name: Upload the vsix built on Linux | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.type == 'native' && ! startsWith(github.ref, 'refs/tags/v') }} | |
with: | |
path: emacs-mcx*.vsix | |
name: emacs-mcx | |
- name: Upload the vsix built on Linux (when pushed with a version tag) | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.type == 'native' && startsWith(github.ref, 'refs/tags/v') }} | |
with: | |
path: emacs-mcx*.vsix | |
name: emacs-mcx | |
release: | |
if: ${{ success() && startsWith(github.ref, 'refs/tags/v') }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: emacs-mcx | |
- name: Create a new release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: emacs-mcx*.vsix | |
generate_release_notes: true | |
publish: | |
if: ${{ success() && startsWith(github.ref, 'refs/tags/v') }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [marketplace, openvsx] | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: emacs-mcx | |
- run: | | |
files=( emacs-mcx*.vsix ) | |
echo "vsix_filename=${files[0]}" >> $GITHUB_ENV | |
- if: matrix.target == 'marketplace' | |
name: Publish to Visual Studio Marketplace | |
uses: HaaLeo/publish-vscode-extension@v1 | |
with: | |
extensionFile: "${{ env.vsix_filename }}" | |
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }} | |
registryUrl: https://marketplace.visualstudio.com | |
- if: matrix.target == 'openvsx' | |
name: Publish to Open VSX Registry | |
uses: HaaLeo/publish-vscode-extension@v1 | |
with: | |
extensionFile: "${{ env.vsix_filename }}" | |
pat: ${{ secrets.OPEN_VSX_TOKEN }} |