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'
# tags:
# - "v*"
branches:
- "main"
#branches:
# - "main"
workflow_dispatch:
@ -39,24 +39,13 @@ jobs:
- name: Get version from npm and increment
run: |
cd vscode-highlight
PATH="$(yarn global bin):$PATH"
yarn global add semver
# take npm version and increment it
VERSION="1.0.${{ github.run_number }}"
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
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_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
- name: Set version to ${{ env.FINAL_VERSION }}
@ -69,7 +58,8 @@ jobs:
with:
node-version: "15"
registry-url: "https://registry.npmjs.org"
- run: |
- name: build package
run: |
cd vscode-highlight
npm i -g vsce
vsce package
@ -85,6 +75,6 @@ jobs:
Version: ${{ env.FINAL_VERSION }}
files: |
${{ env.PKG_FILE }}
draft: false
prerelease: true
draft: true
prerelease: false