Skip to content

Commit

Permalink
Split test-build- and publish- jobs for the VSC extension
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx committed Mar 24, 2023
1 parent e0db1ea commit 5c6f69e
Showing 1 changed file with 50 additions and 5 deletions.
55 changes: 50 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ jobs:
with:
files: packages/desktop-cli/stlite-desktop-cli-v*.tgz

test-build-publish-vscode-extension:
test-build-vscode-extension:
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -880,9 +880,54 @@ jobs:
- run: yarn test
if: runner.os != 'Linux'
working-directory: packages/vscode-stlite
- name: Publish
if: success() && startsWith(github.ref, 'refs/tags/v') && matrix.os == 'ubuntu-latest'
run: npm run deploy
- name: Build
if: success() && matrix.os == 'ubuntu-latest'
run: |
if [ $IS_RELEASE = true ]; then
VERSION=$(node -p "require('./package.json').version")
else
VERSION=${{ github.sha }}
fi
yarn run vsce package -o vscode-stlite-${VERSION}-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}.vsix
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
working-directory: packages/vscode-stlite
- name: Upload the vsix built on Linux
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-latest' && ! startsWith(github.ref, 'refs/tags/v') }}
with:
path: vscode-stlite*.vsix
name: vscode-stlite
working-directory: packages/vscode-stlite

publish-vscode-extension:
if: ${{ !failure() && startsWith(github.ref, 'refs/tags/v') }} # `!failure()` is necessary to avoid skipping this job after successful build: https://github.com/actions/runner/issues/491
needs: [test-build-vscode-extension]

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
target: [marketplace, openvsx]

steps:
- uses: actions/download-artifact@v3
with:
name: vscode-stlite
- run: |
files=( vscode-stlite*.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.VSCE_PAT }}
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 }}

0 comments on commit 5c6f69e

Please sign in to comment.