More tweaks to actions
This commit is contained in:
parent
55186dc6b7
commit
0dcd38e0ab
20
.gitea-actions/create-release/action.yml
Normal file
20
.gitea-actions/create-release/action.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: 'Create Gitea Release'
|
||||||
|
description: 'Create a release in Gitea'
|
||||||
|
inputs:
|
||||||
|
tag_name:
|
||||||
|
description: 'The name of the tag'
|
||||||
|
required: true
|
||||||
|
release_name:
|
||||||
|
description: 'The name of the release'
|
||||||
|
required: true
|
||||||
|
draft:
|
||||||
|
description: 'Is this a draft release?'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
|
prerelease:
|
||||||
|
description: 'Is this a prerelease?'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
|
runs:
|
||||||
|
using: 'node16'
|
||||||
|
main: 'index.js'
|
37
.gitea-actions/create-release/index.js
Normal file
37
.gitea-actions/create-release/index.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
const core = require('@actions/core');
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const token = process.env.GITEA_TOKEN;
|
||||||
|
const tag = core.getInput('tag_name');
|
||||||
|
const name = core.getInput('release_name');
|
||||||
|
const draft = core.getInput('draft') === 'true';
|
||||||
|
const prerelease = core.getInput('prerelease') === 'true';
|
||||||
|
const repo = process.env.GITEA_REPOSITORY;
|
||||||
|
const apiUrl = `${process.env.GITEA_SERVER_URL}/api/v1/repos/${repo}/releases`;
|
||||||
|
|
||||||
|
const res = await fetch(apiUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Authorization: `token ${token}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
tag_name: tag,
|
||||||
|
name,
|
||||||
|
draft,
|
||||||
|
prerelease
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Failed to create release: ${res.status} ${await res.text()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await res.json();
|
||||||
|
core.setOutput('upload_url', json.upload_url);
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(err.message);
|
||||||
|
}
|
||||||
|
})();
|
19
.gitea-actions/upload-release-asset/action.yml
Normal file
19
.gitea-actions/upload-release-asset/action.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: 'Upload Release Asset to Gitea'
|
||||||
|
description: 'Upload a file to a Gitea release'
|
||||||
|
inputs:
|
||||||
|
upload_url:
|
||||||
|
description: 'The upload URL from the release creation step'
|
||||||
|
required: true
|
||||||
|
asset_path:
|
||||||
|
description: 'Path to the file to upload'
|
||||||
|
required: true
|
||||||
|
asset_name:
|
||||||
|
description: 'Name of the uploaded file'
|
||||||
|
required: true
|
||||||
|
asset_content_type:
|
||||||
|
description: 'Content-Type of the file'
|
||||||
|
default: 'application/octet-stream'
|
||||||
|
required: false
|
||||||
|
runs:
|
||||||
|
using: 'node16'
|
||||||
|
main: 'index.js'
|
35
.gitea-actions/upload-release-asset/index.js
Normal file
35
.gitea-actions/upload-release-asset/index.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const core = require('@actions/core');
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const token = process.env.GITEA_TOKEN;
|
||||||
|
const uploadUrl = core.getInput('upload_url');
|
||||||
|
const assetPath = core.getInput('asset_path');
|
||||||
|
const assetName = core.getInput('asset_name');
|
||||||
|
const contentType = core.getInput('asset_content_type');
|
||||||
|
|
||||||
|
const fileData = fs.readFileSync(assetPath);
|
||||||
|
|
||||||
|
const url = `${uploadUrl}?name=${encodeURIComponent(assetName)}`;
|
||||||
|
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Authorization: `token ${token}`,
|
||||||
|
'Content-Type': contentType,
|
||||||
|
},
|
||||||
|
body: fileData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Failed to upload asset: ${res.status} ${await res.text()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
core.info(`Asset uploaded: ${assetName}`);
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(err.message);
|
||||||
|
}
|
||||||
|
})();
|
@ -48,7 +48,7 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Create Gitea release
|
- name: Create Gitea release
|
||||||
uses: https://gitea.com/actions/create-release@v1
|
uses: ./.gitea-actions/create-release
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ gitea.ref }}
|
tag_name: ${{ gitea.ref }}
|
||||||
release_name: ${{ steps.version.outputs.version }}
|
release_name: ${{ steps.version.outputs.version }}
|
||||||
@ -56,9 +56,11 @@ jobs:
|
|||||||
prerelease: false
|
prerelease: false
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
|
|
||||||
- name: Upload release asset
|
- name: Upload release asset
|
||||||
uses: https://gitea.com/actions/upload-release-asset@v1
|
uses: ./.gitea-actions/upload-release-asset
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create-release.outputs.upload_url }}
|
upload_url: ${{ steps.create-release.outputs.upload_url }}
|
||||||
asset_path: ./OFDLV${{ steps.version.outputs.version }}.zip
|
asset_path: ./OFDLV${{ steps.version.outputs.version }}.zip
|
||||||
|
113
package-lock.json
generated
Normal file
113
package-lock.json
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
{
|
||||||
|
"name": "gitea-actions",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "gitea-actions",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.10.0",
|
||||||
|
"node-fetch": "^2.6.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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==",
|
||||||
|
"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==",
|
||||||
|
"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==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "^0.0.6",
|
||||||
|
"undici": "^5.25.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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=="
|
||||||
|
},
|
||||||
|
"node_modules/@fastify/busboy": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/node-fetch": {
|
||||||
|
"version": "2.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||||
|
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-url": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "4.x || >=6.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"encoding": "^0.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"encoding": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tr46": {
|
||||||
|
"version": "0.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
|
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||||
|
},
|
||||||
|
"node_modules/tunnel": {
|
||||||
|
"version": "0.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||||
|
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/undici": {
|
||||||
|
"version": "5.29.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
|
||||||
|
"integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@fastify/busboy": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/webidl-conversions": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-url": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||||
|
"dependencies": {
|
||||||
|
"tr46": "~0.0.3",
|
||||||
|
"webidl-conversions": "^3.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
package.json
Normal file
11
package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "gitea-actions",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.10.0",
|
||||||
|
"node-fetch": "^2.6.9"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user