Add script for publishing to OpenVsx #1332
Workflow file for this run
This file contains 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: CI | |
on: [push, pull_request] | |
env: | |
PACKAGE_NAME: ide-vscode | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Prepare: Checkout Repository" | |
uses: actions/checkout@v2 | |
- name: "Prepare: Use Node.js ${{ matrix.node-version }}" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: v16.x | |
#- name: "Prepare: Setup sonarqube" | |
# uses: warchant/setup-sonar-scanner@v1 | |
#- run: npm install -g npm@latest | |
- run: npm install -g [email protected] | |
- run: npm install | |
- run: npm run lint | |
- run: npm run vscode:prepublish | |
#- run: npm test | |
# env: | |
# CI: true | |
- name: "Prepare: Package VSCode Extension" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: v16.x | |
#- run: npm install -g npm@latest | |
- run: npm install -g [email protected] | |
- run: npm install -g [email protected] | |
- run: vsce package --out dist/ | |
#- name: "Run sonar-scanner" | |
# env: | |
# to get access to secrets.SONAR_TOKEN, provide GITHUB_TOKEN | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# run: sonar-scanner | |
# -Dsonar.login=${{ secrets.SONAR_TOKEN }} | |
- name: "Upload Artifact: VSIX Packages" | |
uses: actions/upload-artifact@v2 | |
with: | |
name: package | |
path: dist/*.vsix | |
release-github: | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Prepare: Checkout Repository" | |
uses: actions/checkout@v2 | |
- name: "Prepare: Get Build Artifact" | |
uses: actions/download-artifact@v2 | |
with: | |
name: package | |
path: dist/ | |
- name: "Prepare: Get the version" | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} | |
- name: "Prepare: Get changelog for current version" | |
id: get_changelog | |
run: | | |
CHANGELOG=$(ed --silent CHANGELOG.md <<< "/## ${VERSION}/+;/## /-p") | |
# Escape Newlines for set-output, see: | |
# https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/m-p/38372#M3322 | |
CHANGELOG="${CHANGELOG//'%'/'%25'}" | |
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" | |
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" | |
echo "::set-output name=CHANGELOG::$CHANGELOG" | |
env: | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
- name: "Check for valid release package" | |
run: test -e ./dist/${PACKAGE_NAME}-${{ steps.get_version.outputs.VERSION }}.vsix | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
body: ${{ steps.get_changelog.outputs.CHANGELOG }} | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/${{ env.PACKAGE_NAME }}-${{ steps.get_version.outputs.VERSION }}.vsix | |
asset_name: ${{ env.PACKAGE_NAME }}-${{ steps.get_version.outputs.VERSION }}.vsix | |
asset_content_type: application/zip | |
release-marketplace: | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Prepare: Checkout Repository" | |
uses: actions/checkout@v2 | |
- name: "Prepare: Use Node.js ${{ matrix.node-version }}" | |
uses: actions/setup-node@v1 | |
with: | |
node-version: v12.x | |
- name: "Prepare: Get Build Artifact" | |
uses: actions/download-artifact@v2 | |
with: | |
name: package | |
path: dist/ | |
- name: "Prepare: Get the version" | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} | |
- run: npm install -g [email protected] | |
- run: vsce publish -p "${MARKETPLACE_TOKEN}" --packagePath dist/${PACKAGE_NAME}-${VERSION}.vsix | |
env: | |
# Note: Marketplace Token according to: | |
# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token | |
# The token is only valid for a limited time - renewal might be required. | |
MARKETPLACE_TOKEN: ${{ secrets.MARKETPLACE_TOKEN }} | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
- run: npm install -g [email protected] | |
- run: ovsx publish -p "${OPENVSX_NAMESPACE_TOKEN}" --packagePath dist/${PACKAGE_NAME}-${VERSION}.vsix | |
env: | |
OPENVSX_NAMESPACE_TOKEN: ${{ secrets.OPENVSX_NAMESPACE_TOKEN }} | |
VERSION: ${{ steps.get_version.outputs.VERSION }} |