Fix version calculation (#4)

Fix version calculation
This commit is contained in:
Pavel 2021-05-25 12:51:51 +03:00 committed by GitHub
parent 73c68481c3
commit 03148eae86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,8 @@ on:
# uncomment to release only on tags starting with 'v' # uncomment to release only on tags starting with 'v'
# tags: # tags:
# - "v*" # - "v*"
branches: #branches:
- "main" # - "main"
workflow_dispatch: workflow_dispatch:
@ -39,24 +39,13 @@ jobs:
- name: Get version from npm and increment - name: Get version from npm and increment
run: | run: |
cd vscode-highlight cd vscode-highlight
PATH="$(yarn global bin):$PATH" VERSION="1.0.${{ github.run_number }}"
yarn global add semver
# take npm version and increment it
PKG_NAME="$(cat package.json | jq -r .name)" PKG_NAME="$(cat package.json | jq -r .name)"
NPM_VERSION="$(yarn info --silent "$PKG_NAME" version || true)"
NEXT_NPM_VERSION="$(semver --increment patch "$NPM_VERSION")"
# take local version
LOCAL_VERSION="$(cat package.json | jq -r .version)"
# take maximum of the local and NEXT_NPM versions
MAX_VERSION="$(semver "$LOCAL_VERSION" "$NEXT_NPM_VERSION" "0.0.0" | tail -n1)"
# save info to env # save info to env
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV echo "FINAL_VERSION=$VERSION" | tee -a $GITHUB_ENV
echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV echo "PKG_NAME=$PKG_NAME" | tee -a $GITHUB_ENV
echo "PKG_FILE=vscode-highlight/${PKG_NAME}-${MAX_VERSION}.vsix" | tee -a $GITHUB_ENV echo "PKG_FILE=vscode-highlight/${PKG_NAME}-${VERSION}.vsix" | tee -a $GITHUB_ENV
### Set version ### Set version
- name: Set version to ${{ env.FINAL_VERSION }} - name: Set version to ${{ env.FINAL_VERSION }}
@ -69,7 +58,8 @@ jobs:
with: with:
node-version: "15" node-version: "15"
registry-url: "https://registry.npmjs.org" registry-url: "https://registry.npmjs.org"
- run: | - name: build package
run: |
cd vscode-highlight cd vscode-highlight
npm i -g vsce npm i -g vsce
vsce package vsce package
@ -85,6 +75,6 @@ jobs:
Version: ${{ env.FINAL_VERSION }} Version: ${{ env.FINAL_VERSION }}
files: | files: |
${{ env.PKG_FILE }} ${{ env.PKG_FILE }}
draft: false draft: true
prerelease: true prerelease: false