2022-05-17 15:06:52 +03:00

78 lines
2.6 KiB
YAML

name: 'build and release vscode syntax highlight'
on:
push:
# uncomment to release only on tags starting with 'v'
# tags:
# - "v*"
branches:
- 'main'
workflow_dispatch:
jobs:
npm-publish:
name: 'Publish'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
### Extract branch name
- name: Extract branch name
if: github.event_name != 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
id: extract_branch
- name: Extract branch name
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v2
### Calculate FINAL_VERSION
- name: Install jq
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
- name: Get version from npm and increment
run: |
VERSION="1.0.${{ github.run_number }}"
PKG_NAME="$(cat package.json | jq -r .name)"
# save info to env
echo "FINAL_VERSION=$VERSION" | tee -a $GITHUB_ENV
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
echo "PKG_FILE=${PKG_NAME}-${VERSION}.vsix" | tee -a $GITHUB_ENV
### Set version
- name: Set version to ${{ env.FINAL_VERSION }}
run: |
yarn version --new-version ${{ env.FINAL_VERSION }} --no-git-tag-version
### Pack vsix package
- uses: actions/setup-node@v1
with:
node-version: '15'
registry-url: 'https://registry.npmjs.org'
- name: build package
run: |
npm i -g vsce
vsce package
vsce publish -p ${{ secrets.VSCE_PAT }}
### create release
- uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.FINAL_VERSION }}
name: Visual Studio Code syntax highlight ${{ env.FINAL_VERSION }}
body: |
Version: ${{ env.FINAL_VERSION }}
files: |
${{ env.PKG_FILE }}
draft: true
prerelease: false