mirror of
https://github.com/fluencelabs/aqua-vscode
synced 2025-04-25 08:32:15 +00:00
Add ci
This commit is contained in:
parent
660fb64fc0
commit
5f848e100c
96
.github/workflows/vscode_highlight.yml
vendored
Normal file
96
.github/workflows/vscode_highlight.yml
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
name: "build vscode syntax highlight"
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./vscode-highlight
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
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: |
|
||||||
|
# install semver and add it to PATH
|
||||||
|
yarn global add semver
|
||||||
|
PATH="$(yarn global bin):$PATH"
|
||||||
|
|
||||||
|
# sanitize branch name so it can be used as a semver suffix (replace [^0-9a-zA-Z-] with hyphen)
|
||||||
|
SANITIZED_BRANCH="$(echo -n "${{ env.BRANCH_NAME }}" | tr -C '[:alnum:]-' -)"
|
||||||
|
# get package name from package.json
|
||||||
|
PKG_NAME="$(cat package.json | jq -r .name)"
|
||||||
|
|
||||||
|
# take all versions from npm and replace single quotes with double quotes
|
||||||
|
NPM_VERSIONS=$(yarn info --silent "$PKG_NAME" versions 2>/dev/null | tr \' \")
|
||||||
|
# take only versions that contain branch name
|
||||||
|
NPM_VERSIONS_FILTERED=$(echo $NPM_VERSIONS | jq -r ".[] | select(contains(\"$SANITIZED_BRANCH\"))")
|
||||||
|
# flatten into a single line
|
||||||
|
NPM_VERSIONS_FLATTENED=$(echo $NPM_VERSIONS_FILTERED | awk '{print}' ORS=' ')
|
||||||
|
# sort versions according to semver, take highest (last)
|
||||||
|
LAST_NPM_VERSION="$(semver -p $(echo $NPM_VERSIONS_FLATTENED) | tail -n1 || true)"
|
||||||
|
# increment prerelease part of the version
|
||||||
|
PRERELEASE_NPM_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${LAST_NPM_VERSION}" || true)"
|
||||||
|
|
||||||
|
# take local version
|
||||||
|
LOCAL_VERSION="$(cat package.json | jq -r .version)"
|
||||||
|
# set prerelease part on local version
|
||||||
|
LOCAL_PRERELEASE_VERSION="$(semver --increment prerelease --preid "$SANITIZED_BRANCH" "${LOCAL_VERSION}-0")" # added '-0' here to avoid semver erroneously increment patch octet. Any suffix works, '-0' is chosen deliberately.
|
||||||
|
|
||||||
|
# take the highest version
|
||||||
|
MAX_VERSION="$(semver "$LOCAL_PRERELEASE_VERSION" "$PRERELEASE_NPM_VERSION" | tail -n1)"
|
||||||
|
|
||||||
|
# save info to env
|
||||||
|
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
|
||||||
|
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
|
||||||
|
echo "PKG_FILE=${PKG_NAME}-${FINAL_VERSION}.tgz" | 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 npm package
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: "15"
|
||||||
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
- run: npm pack
|
||||||
|
|
||||||
|
### Create a pre-release
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.FINAL_VERSION }}
|
||||||
|
release_name: VSCode syntax highlighting plugin ${{ env.FINAL_VERSION }}
|
||||||
|
files: |
|
||||||
|
${{ env.PKG_FILE }}
|
||||||
|
body: |
|
||||||
|
Version: ${{ env.FINAL_VERSION }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
1
vscode-highlight/.gitignore
vendored
1
vscode-highlight/.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
*.vsix
|
*.vsix
|
||||||
|
*.tgz
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "aqua",
|
"name": "aqua-syntax-highlight",
|
||||||
"displayName": "aqua",
|
"displayName": "aqua",
|
||||||
"description": "aqua language support",
|
"description": "aqua language support",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.56.0"
|
"vscode": "^1.56.0"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user