Initiated the action. #1
@ -15,3 +15,6 @@ jobs:
|
||||
- run: echo Current branch ${{github.ref_name}}
|
||||
- name: version-up
|
||||
uses: https://git.horstenkamp.eu/Philipp/version-up-action.git@${{github.ref_name}}
|
||||
with:
|
||||
url-pattern: https://dl.gitea.com/act_runner/{{VERSION}}/act_runner-{{VERSION}}-linux-arm-7
|
||||
start-version: 0.1.1
|
||||
|
51
index.js
51
index.js
@ -1,10 +1,11 @@
|
||||
const core = require("@actions/core");
|
||||
|
||||
function parseVersion(str) {
|
||||
if (typeof str != "string") {
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseVersion(str){
|
||||
if (typeof(str) != 'string') { return false; }
|
||||
|
||||
var arr = str.split('.');
|
||||
var arr = str.split(".");
|
||||
|
||||
// parse int or default to 0
|
||||
var maj = parseInt(arr[0]) || 0;
|
||||
@ -13,49 +14,63 @@ function parseVersion(str){
|
||||
return {
|
||||
major: maj,
|
||||
minor: min,
|
||||
patch: patch
|
||||
}
|
||||
patch: patch,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
async function increaseVersionPart(url_pattern, version, version_part) {
|
||||
let test_vor_existence = version;
|
||||
while (true) {
|
||||
const url_with_version = url_pattern.replace(/{{VERSION}}/g, test_vor_existence);
|
||||
const url_with_version = url_pattern.replace(
|
||||
/{{VERSION}}/g,
|
||||
test_vor_existence,
|
||||
);
|
||||
if (url_with_version == url_pattern) {
|
||||
throw new Error('The url does not contain an {{VERSION}} marker!');
|
||||
throw new Error("The url does not contain an {{VERSION}} marker!");
|
||||
}
|
||||
let status = await fetch(url_with_version, {
|
||||
method: "GET",
|
||||
}).then((response) => response.status);
|
||||
if (status === 200) {
|
||||
version = test_vor_existence;
|
||||
const version_parsed = parseVersion(test_vor_existence)
|
||||
const version_parsed = parseVersion(test_vor_existence);
|
||||
if (version_part == "minor") {
|
||||
test_vor_existence = `${version_parsed.major}.${version_parsed.minor + 1}.0`;
|
||||
test_vor_existence = `${version_parsed.major}.${
|
||||
version_parsed.minor + 1
|
||||
}.0`;
|
||||
} else if (version_part == "micro") {
|
||||
test_vor_existence = `${version_parsed.major}.${version_parsed.minor}.${version_parsed.patch + 1}`;
|
||||
test_vor_existence = `${version_parsed.major}.${version_parsed.minor}.${
|
||||
version_parsed.patch + 1
|
||||
}`;
|
||||
} else {
|
||||
throw new Error('The url does not contain an {{VERSION}} marker!');
|
||||
throw new Error("The url does not contain an {{VERSION}} marker!");
|
||||
}
|
||||
} else {
|
||||
return version
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function increaseVersion(url_pattern, version) {
|
||||
let minor = await increaseVersionPart(url_pattern, version, version_part="minor");
|
||||
return await increaseVersionPart(url_pattern, minor, version_part="micro");
|
||||
let minor = await increaseVersionPart(
|
||||
url_pattern,
|
||||
version,
|
||||
(version_part = "minor"),
|
||||
);
|
||||
return await increaseVersionPart(
|
||||
url_pattern,
|
||||
minor,
|
||||
(version_part = "micro"),
|
||||
);
|
||||
}
|
||||
|
||||
async function main(){
|
||||
async function main() {
|
||||
try {
|
||||
const url_pattern = core.getInput("url-pattern");
|
||||
const start_version = core.getInput("start-version");
|
||||
const current_version = await increaseVersion(url_pattern, start_version);
|
||||
core.info(`The new version determend is ${current_version}`);
|
||||
core.setOutput('max_version', current_version);
|
||||
core.setOutput("max_version", current_version);
|
||||
return current_version;
|
||||
} catch (error) {
|
||||
core.setFailed(`Action failed with error: ${error}`);
|
||||
|
1
node_modules/.cache/prettier/.prettier-caches/706f51a62288b0ed1d148f635575b4d90c61cdcf.json
generated
vendored
Normal file
1
node_modules/.cache/prettier/.prettier-caches/706f51a62288b0ed1d148f635575b4d90c61cdcf.json
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"0a9cd11a33d0e683718dc953b18cd8ddd9b4087f":{"files":{"index.js":["eet1sBLWVjGy4Iu3o3sSkhGQCig=",true]},"modified":1716927105637}}
|
Loading…
x
Reference in New Issue
Block a user