Compare commits

...

4 Commits

Author SHA1 Message Date
floraachy 4473b0e04e
删除文件 src/index.js 2025-03-13 06:14:37 +00:00
floraachy 7997d7a9f3
删除文件 package.json 2025-03-13 06:14:31 +00:00
floraachy 882d9c45a4
删除文件 package-lock.json 2025-03-13 06:14:26 +00:00
floraachy b8a676bca6
删除文件 action.yml 2025-03-13 06:14:13 +00:00
4 changed files with 0 additions and 390 deletions

View File

@ -1,23 +0,0 @@
name: '创建发行版'
description: '在指定仓库创建发行版'
author: 'GitLink'
inputs:
domain:
description: '选填域名默认为http://172.20.32.201:4000/'
username:
description: '必填,对需要发行版本的仓库具备管理员权限的用户'
password:
description: '必填,用户名对应的密码'
repository:
description: '选填,仓库名,格式:拥有者/仓库标识例如tester/test为空则默认为当前流水线保存的仓库'
release_title:
description: '必填,发行版标题'
release_desc:
description: '选填,发行版描述'
tag_name:
description: '选填,标记,为空则自动生成'
sha:
description: '选填分支或者sha为空则为默认分支'
runs:
using: 'node20'
main: 'dist/index.js'

205
package-lock.json generated
View File

@ -1,205 +0,0 @@
{
"name": "publish-releases-action",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "publish-releases-action",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.11.1",
"axios": "^1.7.9",
"before-after-hook": "^3.0.2",
"undici": "^7.3.0",
"universal-user-agent": "^7.0.2"
}
},
"node_modules/@actions/core": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz",
"integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==",
"license": "MIT",
"dependencies": {
"@actions/exec": "^1.1.1",
"@actions/http-client": "^2.0.1"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"license": "MIT",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/http-client": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz",
"integrity": "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==",
"license": "MIT",
"dependencies": {
"tunnel": "^0.0.6",
"undici": "^5.25.4"
}
},
"node_modules/@actions/http-client/node_modules/undici": {
"version": "5.28.5",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
"license": "MIT",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
"engines": {
"node": ">=14.0"
}
},
"node_modules/@actions/io": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==",
"license": "MIT"
},
"node_modules/@fastify/busboy": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
"license": "MIT",
"engines": {
"node": ">=14"
}
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.7.9",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/before-after-hook": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz",
"integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==",
"license": "Apache-2.0"
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz",
"integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"license": "MIT"
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"license": "MIT",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/undici": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.3.0.tgz",
"integrity": "sha512-Qy96NND4Dou5jKoSJ2gm8ax8AJM/Ey9o9mz7KN1bb9GP+G0l20Zw8afxTnY2f4b7hmhn/z8aC2kfArVQlAhFBw==",
"license": "MIT",
"engines": {
"node": ">=20.18.1"
}
},
"node_modules/universal-user-agent": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",
"integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==",
"license": "ISC"
}
}
}

View File

@ -1,19 +0,0 @@
{
"name": "publish-releases-action",
"version": "1.0.0",
"description": "支持用户使用节点,登录指定用户在指定仓库创建发行版",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"run": "node dist/index.js"
},
"author": "floraachy",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.11.1",
"axios": "^1.7.9",
"before-after-hook": "^3.0.2",
"undici": "^7.3.0",
"universal-user-agent": "^7.0.2"
}
}

View File

@ -1,143 +0,0 @@
const core = require('@actions/core');
const axios = require('axios');
const crypto = require('crypto');
function generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * charactersLength);
result += characters.charAt(randomIndex);
}
return result;
}
const upload_artifact = async () => {
//使用trim移除前后的多余空格
const domain = (process.env['INPUT_DOMAIN'] || "http://172.20.32.201:4000").trim();
const username = (process.env['INPUT_USERNAME'] || '').trim();
const password = (process.env['INPUT_PASSWORD'] || '').trim();
const repository = (process.env['INPUT_REPOSITORY'] || process.env['GITHUB_REPOSITORY'] || '').trim();
const tag_name = (process.env['INPUT_TAG_NAME'] || generateRandomString(5)).trim();
const release_title = (process.env['INPUT_RELEASE_TITLE'] || '').trim();
const release_desc = (process.env['INPUT_RELEASE_DESC'] || '').trim();
const sha = (process.env['INPUT_SHA'] || '').trim();
console.log("---打印一下接收到的各项参数---")
console.log("domain: ", domain)
console.log("username: ", username)
console.log("password: ", password)
console.log("repository: ", repository)
console.log("release_title: ", release_title)
console.log("release_desc: ", release_desc)
console.log("tag_name: ", release_desc)
console.log("sha: ", sha)
const new_domain = domain.endsWith('/') ? domain.slice(0, -1) : domain;
console.log("new_domain: ", new_domain)
// -------------------- 将登录密码基于平台加密算法加密----------------------------
function aesEncrypt(plainText, keyStr, ivStr) {
// 将字符串密钥和IV转换为16字节的Buffer
const key = Buffer.from(keyStr.slice(0, 16), 'utf8');
const iv = Buffer.from(ivStr.slice(0, 16), 'utf8');
// 创建并设置AES-CBC加密器
const cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
// 加密数据并添加PKCS7填充
let encryptedData = cipher.update(plainText, 'utf8', 'base64');
encryptedData += cipher.final('base64');
return encryptedData;
}
const key = '59c96c3572ab8cc1'; // 密钥
const iv = '59c96c3572ab8cc1'; // 初始化向量
// 加密
const pwd = aesEncrypt(password, key, iv);
console.log("加密后的密码: ", pwd);
try {
// -------------------- 登录获取用户cookies----------------------------
const loginCookies = await fetch(new_domain + "/api/accounts/login.json", {
"headers": {
"content-type": "application/json",
},
"body": `{\"login\":\"${username}\",\"password\":\"${pwd}\",\"autologin\":0}`,
"method": "POST",
"mode": "cors",
"credentials": "include"
}).then((r) => r.headers.get('Set-Cookie'))
console.log("loginCookies=======" + loginCookies)
if (!sha) {
try {
// 获取仓库的默认分支
const detail_url = new_domain + "/api/" + repository + "/detail.json";
console.log("detail_url=======" + detail_url)
const detailResponse = await axios.get(detail_url, {
headers: {
cookie: loginCookies
}
});
console.log(JSON.stringify(detailResponse.data));
// 检查 HTTP 状态码
if (detailResponse.status !== 200) {
throw new Error(`请求接口detail.json失败状态码${detailResponse.status}`);
}
// 检查业务状态码
if (detailResponse.data.status !== 1) {
throw new Error('请求接口detail.json失败' + detailResponse.data);
}
// 获取默认分支如果获取失败则赋予默认值为master
const sha = detailResponse.data.default_branch || 'master';
console.log("sha=======" + sha);
} catch (error) {
console.error("请求接口detail.json时发生错误", error);
throw error; // 或者返回一个默认值,例如 'main'
}
}
let releases_data = {
"tag_name": tag_name, //标签,标记一个版本,必填
"name": release_title + "_" + generateRandomString(5), // 发行版标题,必填
"body": release_desc, //发行版描述,选填
"target_commitish": sha
}
console.log("releases_data=======" + JSON.stringify(releases_data));
let api_config = {
method: 'post',
maxBodyLength: Infinity,
url: new_domain + '/api/' + repository + '/releases.json',
headers: {
'cookie': loginCookies
},
data: releases_data
};
const apiResponse = await axios.request(api_config)
console.log(JSON.stringify(apiResponse.data));
if (apiResponse.data && apiResponse.data.status !== 0) {
core.error('发布失败');
core.setFailed('发布失败');
}
} catch (error) {
console.error('错误日志', error);
core.error('错误日志', error);
core.setFailed('错误日志');
}
}
const main = async () => {
await upload_artifact()
}
main()