mirror of
https://github.com/werf/actions.git
synced 2026-02-05 02:46:23 +03:00
Validate the version input value
An arbitrary version must be within MAJOR.MINOR
This commit is contained in:
@@ -5,6 +5,7 @@ import * as semver from 'semver'
|
||||
import {context} from '@actions/github'
|
||||
import {String} from 'typescript-string-operations'
|
||||
import {Manager} from './manager'
|
||||
import * as werf from './werf'
|
||||
|
||||
const minimalWerfVersion = 'v1.1.17'
|
||||
|
||||
@@ -66,6 +67,16 @@ export function ProcessGitHubContext(): void {
|
||||
export function ValidateWerfVersion(version: string): void {
|
||||
const ver = semver.coerce(version)
|
||||
if (ver) {
|
||||
if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) {
|
||||
throw new Error(
|
||||
String.Format(
|
||||
'The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})',
|
||||
version.trim(),
|
||||
werf.MAJOR_MINOR_GROUP
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (semver.gte(ver, minimalWerfVersion)) {
|
||||
return
|
||||
}
|
||||
@@ -73,7 +84,7 @@ export function ValidateWerfVersion(version: string): void {
|
||||
|
||||
throw new Error(
|
||||
String.Format(
|
||||
'werf version {0} is not supported (expected version should be equal or greater than {1})',
|
||||
'werf version {0} is not supported (expected version must be equal or greater than {1})',
|
||||
version.trim(),
|
||||
minimalWerfVersion
|
||||
)
|
||||
|
||||
@@ -9,11 +9,11 @@ import {String} from 'typescript-string-operations'
|
||||
import * as crypto from 'crypto'
|
||||
import * as tmp from 'tmp'
|
||||
import * as dotenv from 'dotenv'
|
||||
import * as werf from './werf'
|
||||
|
||||
const WERF_API_GET_CHANNEL_VERSION_URL_METHOD =
|
||||
'https://werf.io/api/getChannelVersionURL'
|
||||
const WERF_API_GET_VERSION_URL_METHOD = 'https://werf.io/api/getVersionURL'
|
||||
const MAJOR_MINOR_GROUP = '1.1'
|
||||
|
||||
export class Manager {
|
||||
private readonly channel: string
|
||||
@@ -112,7 +112,7 @@ export class Manager {
|
||||
} else {
|
||||
url = WERF_API_GET_CHANNEL_VERSION_URL_METHOD
|
||||
query = {
|
||||
group: MAJOR_MINOR_GROUP,
|
||||
group: werf.MAJOR_MINOR_GROUP,
|
||||
channel: this.channel,
|
||||
os: this.os,
|
||||
arch: this.arch
|
||||
|
||||
3
src/werf.ts
Normal file
3
src/werf.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const MAJOR_MINOR_GROUP = '1.1'
|
||||
export const MAJOR = 1
|
||||
export const MINOR = 1
|
||||
Reference in New Issue
Block a user