|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: |
| 5 | + - released |
| 6 | +jobs: |
| 7 | + publish: |
| 8 | + if: github.event_name == 'release' |
| 9 | + runs-on: ubuntu-latest |
| 10 | + needs: build |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v2 |
| 13 | + with: |
| 14 | + ref: master |
| 15 | + token: ${{ secrets.TOKEN }} |
| 16 | + - name: Use Node.js |
| 17 | + uses: actions/setup-node@v1 |
| 18 | + with: |
| 19 | + node-version: 12.x |
| 20 | + - name: Prepare build |
| 21 | + id: set-version |
| 22 | + run: | |
| 23 | + VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/} |
| 24 | + NEXT_VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.` |
| 25 | + tmp=$(mktemp) |
| 26 | + git config --global user.name 'ProjectBot' |
| 27 | + git config --global user.email 'bot@users.noreply.github.com' |
| 28 | + jq --arg version "${NEXT_VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json |
| 29 | + git add package.json |
| 30 | + git commit -m 'auto bump version with release' |
| 31 | + git push |
| 32 | + jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json |
| 33 | + NAME=$(jq -r '.name' package.json)-$VERSION |
| 34 | + echo ::set-output name=name::$NAME |
| 35 | + mkdir dist |
| 36 | + npx vsce package -o $NAME.vsix |
| 37 | + - name: Upload Release Asset |
| 38 | + id: upload-release-asset |
| 39 | + uses: actions/upload-release-asset@v1 |
| 40 | + if: runner.os == 'Linux' |
| 41 | + env: |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + with: |
| 44 | + upload_url: ${{ github.event.release.upload_url }} |
| 45 | + asset_path: ${{ steps.set-version.outputs.name }}.vsix |
| 46 | + asset_name: ${{ steps.set-version.outputs.name }}.vsix |
| 47 | + asset_content_type: application/zip |
| 48 | + - name: Publish to VSCode Marketplace |
| 49 | + run: | |
| 50 | + [ -n "${{ secrets.VSCE_TOKEN }}" ] && \ |
| 51 | + npx vsce publish --packagePath ${{ steps.set-version.outputs.name }}.vsix -p ${{ secrets.VSCE_TOKEN }} || true |
| 52 | + - name: Publish to Open VSX Registry |
| 53 | + run: | |
| 54 | + [ -n "${{ secrets.OVSX_TOKEN }}" ] && \ |
| 55 | + npx ovsx publish --packagePath ${{ steps.set-version.outputs.name }}.vsix --pat ${{ secrets.OVSX_TOKEN }} || true |
0 commit comments