name: Build extension on: push: tags: '**' branches: - '*' - 'feature/**' - 'release/**' pull_request: types: [opened, synchronize] branches: - '*' - 'feature/**' - 'release/**' workflow_dispatch: jobs: build: runs-on: ubuntu-18.04 name: Build and package timeout-minutes: 10 steps: - uses: actions/checkout@v2 - name: Define variables id: vars run: | SOURCE_NAME=${GITHUB_REF#refs/*/} VSIX_NAME="vscode-sshfs-$SOURCE_NAME.vsix" if [[ $GITHUB_REF == refs/tags/v* ]]; then TAG_VERSION=${GITHUB_REF#refs/tags/v} VSIX_NAME="vscode-sshfs-$TAG_VERSION.vsix" echo ::set-output name=TAG_VERSION::$TAG_VERSION elif [[ $GITHUB_REF == refs/pull/*/head || $GITHUB_REF == refs/pull/*/merge ]]; then PR_NUMBER=${GITHUB_REF#refs/pull/} PR_NUMBER=${PR_NUMBER%/head} PR_NUMBER=${PR_NUMBER%/merge} VSIX_NAME="vscode-sshfs-pr-$PR_NUMBER.vsix" echo ::set-output name=PR_NUMBER::$PR_NUMBER elif [[ -n $SOURCE_NAME ]]; then VSIX_NAME="vscode-sshfs-$SOURCE_NAME.vsix" fi VSIX_NAME=${VSIX_NAME//"/"/"-"} echo ::set-output name=VSIX_NAME::$VSIX_NAME - name: Use Node.js 10.x uses: actions/setup-node@v1 with: node-version: 10.x - name: Install VSCE run: | yarn global add vsce echo "$(yarn global bin)" >> $GITHUB_PATH - name: Install dependencies in / run: yarn --frozen-lockfile - name: Install dependencies in /webview/ working-directory: webview run: yarn --frozen-lockfile - name: Build extension run: vsce package -o ${{ steps.vars.outputs.VSIX_NAME }} - name: Upload a Build Artifact uses: actions/upload-artifact@v2.2.1 with: name: ${{ steps.vars.outputs.VSIX_NAME }} path: ${{ steps.vars.outputs.VSIX_NAME }} if-no-files-found: error - name: Create release id: create_release if: ${{ success() && steps.vars.outputs.TAG_VERSION }} uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} release_name: Release ${{ steps.vars.outputs.TAG_VERSION }} draft: true - name: Upload release asset id: upload_release_asset if: ${{ success() && steps.vars.outputs.TAG_VERSION }} uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ${{ steps.vars.outputs.VSIX_NAME }} asset_name: ${{ steps.vars.outputs.VSIX_NAME }} asset_content_type: application/vsix