Skip to content

VSCode Release

VSCode Release #95

Workflow file for this run

name: VSCode Release
on:
workflow_call:
inputs:
jsTag:
description: 'JS Wrapper tag name'
required: false
type: string
default: nightly
vscodeTag:
description: 'Tag name'
required: false
type: string
default: nightly
dev:
description: 'Is dev build'
required: false
default: true
type: boolean
publish:
description: 'Publish to marketplace'
required: false
default: true
type: boolean
workflow_dispatch:
inputs:
jsTag:
description: 'JSW tag name (ignored if not dev build)'
required: false
vscodeTag:
description: 'Tag name (ignored if not dev build)'
required: false
dev:
description: 'Is dev build'
required: false
default: true
type: boolean
publish:
description: 'Publish to marketplace'
required: false
default: false
type: boolean
jobs:
delete:
uses: Checkmarx/ast-vscode-extension/.github/workflows/delete-dev-releases.yml@main
with:
tag: ${{ inputs.vscodeTag }}
secrets: inherit
if: inputs.dev
release:
runs-on: ubuntu-latest
steps:
# CHECKOUT PROJECT
- name: Checkout
uses: actions/[email protected]
# GIT CONFIGURATION
- run: |
git config user.name vscode-releases
git config user.email [email protected]
# AUTHENTICATE TO GITHUB PACKAGE REGISTRY
- name: Authenticate with GitHub package registry
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
# SETUP NODE
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.15.0
# GET TAG NAME
- name: Generate Tag name
run: |
if [ ${{ inputs.dev }} == true ]; then
echo "TAG_NAME=$(npm version prerelease --preid=${{ inputs.vscodeTag }} --no-git-tag-version --allow-same-version)" >> $GITHUB_ENV
else
echo "TAG_NAME=$(npm version minor)" >> $GITHUB_ENV
fi
# INSTALL NPM DEPENDENCIES
- name: Install dependencies
run: npm install
# GET AND INSTALL JS WRAPPER VERSION PROVIDED BY USER
- name: Get and install JS Wrapper if provided by user
if: inputs.dev == true && inputs.jsTag != ''
run: |
echo "Getting js wrapper ${{inputs.jsTag}} version..."
JS_VERSION_NAME=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper/versions | jq '.[]|select((.name | contains("-${{inputs.jsTag}}.0")) or .name == "${{inputs.jsTag}}")|.name' | tr -d '"')
if [ ${JS_VERSION_NAME} != '' ]; then
echo "Install JS Wrapper version ${JS_VERSION_NAME}"
npm install "@checkmarxdev/ast-cli-javascript-wrapper@"${JS_VERSION_NAME}
else
echo "JS wrapper with version ${JS_VERSION_NAME} not found"
fi
# INSTALL VSCE
- name: Install VSCE
run: npm install -g vsce
# PACKAGE PROJECT
- name: Package .vsix file
run: |
if [ ${{ inputs.dev }} == true ]; then
node .github/scripts/updateDevVersion.js
vsce package --pre-release
else
vsce package
fi
# CREATE GH RELEASE NAME
- name: Handle GH Release name
run: |
VSIX_TAG_NAME=$(cat package.json | jq .version | cut -d'"' -f 2)
echo "VSIX_TAG_NAME=$VSIX_TAG_NAME" >> $GITHUB_ENV
if [ ${{ inputs.dev }} == true ]; then
echo "GH_RELEASE_NAME=${{env.TAG_NAME}} (${VSIX_TAG_NAME})" >> $GITHUB_ENV
else
echo "GH_RELEASE_NAME=${{env.TAG_NAME}}" >> $GITHUB_ENV
fi
# PUSH TAGS IF IT IS A RELEASE
- name: Push tag if release
if: inputs.dev == false
run: git push && git push --tags
# CREATE GH RELEASE
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: ${{env.GH_RELEASE_NAME}}
tag_name: ${{env.TAG_NAME}}
generate_release_notes: true
files: ast-results-${{env.VSIX_TAG_NAME}}.vsix
prerelease: ${{ inputs.dev }}
# PUBLISH TO MARKETPLACE
- name: Publish
env:
MARKET_TOKEN: ${{ secrets.MARKET_TOKEN }}
if: env.MARKET_TOKEN != null && (inputs.dev == false || (inputs.dev == true && inputs.publish == true))
run: |
if [ ${{ inputs.dev }} == true ]; then
vsce publish --pre-release -p ${{ env.MARKET_TOKEN }}
else
vsce publish -p ${{ env.MARKET_TOKEN }}
fi
# GENERATE AND WRITE CHANGELOG TO FILE
- name: Generate release changelog
uses: BobAnkh/[email protected]
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PATH: 'CHANGELOG.md'