Build & Release VS Code Dev Spaces #3
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: Build & Release VS Code Dev Spaces | |
| on: | |
| schedule: | |
| - cron: "0 8 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| publishToMarketPlace: | |
| description: "Publish to VS Code Marketplace ?" | |
| required: true | |
| type: choice | |
| options: | |
| - "true" | |
| - "false" | |
| default: "false" | |
| publishToOVSX: | |
| description: "Publish to OpenVSX Registry ?" | |
| required: true | |
| type: choice | |
| options: | |
| - "true" | |
| - "false" | |
| default: "false" | |
| publishPreRelease: | |
| description: "Publish a pre-release ?" | |
| required: true | |
| type: choice | |
| options: | |
| - "true" | |
| - "false" | |
| default: "true" | |
| jobs: | |
| should-build-change: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| repo-cache-hit: ${{ steps.cache-last-commit.outputs.cache-hit }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| repository: "redhat-developer/devspaces-remote-ssh" | |
| fetch-depth: 2 | |
| path: devspaces-remote-ssh | |
| - run: | | |
| pushd devspaces-remote-ssh | |
| git rev-parse HEAD >> ../lastCommit | |
| - name: Check New Changes | |
| id: cache-last-commit | |
| uses: actions/cache@v5 | |
| with: | |
| path: lastCommit | |
| key: lastCommit-${{ hashFiles('lastCommit') }} | |
| packaging-job: | |
| runs-on: ubuntu-latest | |
| needs: should-build-change | |
| if: ${{ needs.should-build-change.outputs.repo-cache-hit != 'true' || github.event_name != 'schedule' }} | |
| steps: | |
| - name: Checkout Dev Spaces Remote SSH | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: redhat-developer/devspaces-remote-ssh | |
| path: devspaces-remote-ssh | |
| - name: Set Up NodeJS | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '20' | |
| - name: Install NodeJS dependencies | |
| run: npm install -g typescript "@vscode/vsce" "ovsx" | |
| - name: Build Extension | |
| run: | | |
| pushd devspaces-remote-ssh | |
| echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV | |
| npm install | |
| npm run compile | |
| npm run vscode:prepublish | |
| - name: Prepare Pre-Release | |
| if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }} | |
| run: | | |
| pushd devspaces-remote-ssh | |
| npm run prepare-pre-release | |
| echo "publishPreReleaseFlag=--pre-release" >> $GITHUB_ENV | |
| - name: Package devspaces-remote-ssh | |
| run: | | |
| pushd devspaces-remote-ssh | |
| vsce package -o ../devspaces-remote-ssh-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix | |
| - name: Upload VSIX Artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: devspaces-remote-ssh | |
| path: | | |
| devspaces-remote-ssh-${{ env.EXT_VERSION }}-${{github.run_number}}.vsix | |
| if-no-files-found: error | |
| - name: Publish to GH Release Tab | |
| if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }} | |
| uses: "marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0" | |
| with: | |
| repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
| automatic_release_tag: "${{ env.EXT_VERSION }}" | |
| title: "${{ env.EXT_VERSION }}" | |
| draft: true | |
| files: | | |
| devspaces-remote-ssh-${{ env.EXT_VERSION }}-${{ github.run_number }}.vsix | |
| release-job: | |
| environment: ${{ (inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true') && 'release' || 'pre-release' }} | |
| runs-on: ubuntu-latest | |
| needs: packaging-job | |
| steps: | |
| - name: Set Up NodeJS | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: | | |
| npm install -g typescript "@vscode/vsce" "ovsx" | |
| - name: Download VSIX | |
| uses: actions/download-artifact@v5 | |
| - name: Publish to VS Code Marketplace | |
| if: ${{ github.event_name == 'schedule' || inputs.publishToMarketPlace == 'true' || inputs.publishPreRelease == 'true' }} | |
| run: | | |
| echo vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath devspaces-remote-ssh/devspaces-remote-ssh-*-${GITHUB_RUN_NUMBER}.vsix | |
| - name: Publish to OpenVSX Registry | |
| if: ${{ github.event_name == 'schedule' || inputs.publishToOVSX == 'true' || inputs.publishPreRelease == 'true' }} | |
| run: | | |
| echo ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath devspaces-remote-ssh/devspaces-remote-ssh-*-${GITHUB_RUN_NUMBER}.vsix | |
| post-release-job: | |
| if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }} | |
| runs-on: ubuntu-latest | |
| needs: release-job | |
| steps: | |
| - name: Check Out Dev Spaces Remote SSH | |
| uses: actions/checkout@v5 | |
| - name: Set Up NodeJS | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '20' | |
| - name: Upversion for Development | |
| run: | | |
| tag=`npm version --no-git-tag-version patch` | |
| git config --global user.email "devspaces-remote-ssh-bot@users.noreply.github.com" | |
| git config --global user.name "devspaces-remote-ssh-bot" | |
| git commit -am "Upversion to ${tag#v}" | |
| git push origin |