Merge pull request #40 from MetamediaTechnology/refactoring #95
This file contains hidden or 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: Node.js CI | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: [ staging, main ] | |
| pull_request: | |
| branches: [ staging, main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [20.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install Xvfb | |
| run: sudo apt-get install -y xvfb | |
| - name: Start Xvfb | |
| run: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | |
| - run: npm ci | |
| - run: npm run lint | |
| - name: Run tests with Xvfb | |
| run: | | |
| export DISPLAY=:99 | |
| npm test | |
| package: | |
| needs: build | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: 'npm' | |
| - run: npm ci | |
| - name: Install vsce | |
| run: npm install -g @vscode/vsce | |
| - name: Package Extension | |
| run: vsce package | |
| - name: Upload VSIX | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extension-vsix | |
| path: "*.vsix" | |
| retention-days: 1 | |
| release: | |
| needs: package | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download packaged VSIX | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: extension-vsix | |
| path: . | |
| - name: Get version from package.json | |
| id: get_version | |
| run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT | |
| - name: Install GitHub CLI | |
| run: | | |
| type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) | |
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
| sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
| sudo apt update | |
| sudo apt install gh -y | |
| - name: Create GitHub Release | |
| id: create_release | |
| run: | | |
| NOTES=$(awk '/### \[/ {if (found) exit; found=1} found' CHANGELOG.md) | |
| gh release create "v${{ steps.get_version.outputs.VERSION }}" \ | |
| --title "Release v${{ steps.get_version.outputs.VERSION }}" \ | |
| --notes "$NOTES" \ | |
| --repo ${{ github.repository }} \ | |
| ./*.vsix | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |