Files
LowderPlay_cheburcheck/.github/workflows/release.yml
T
2026-09-07 17:35:23 +05:00

136 lines
5.4 KiB
YAML

name: Draft component release
on:
workflow_call:
inputs:
component:
required: true
type: string
artifact-pattern:
required: false
type: string
default: ''
permissions:
actions: read
contents: write
concurrency:
group: draft-release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
draft-release:
name: Draft GitHub release
runs-on: ubuntu-latest
steps:
- name: Download component artifacts
if: inputs.component != 'website'
uses: actions/download-artifact@v8
with:
pattern: ${{ inputs.artifact-pattern }}
path: release-artifacts
merge-multiple: true
- name: Generate release body
id: body
uses: actions/github-script@v8
env:
TAG_NAME: ${{ github.ref_name }}
COMPONENT: ${{ inputs.component }}
with:
script: |
const fs = require('fs');
const path = require('path');
const tag = process.env.TAG_NAME;
fs.mkdirSync('release-artifacts', { recursive: true });
const component = process.env.COMPONENT;
core.setOutput('prerelease', tag.slice((component + '-v').length).split('+')[0].includes('-'));
const files = fs.readdirSync('release-artifacts')
.filter((name) => fs.statSync(path.join('release-artifacts', name)).isFile())
.sort();
function describe(name) {
if (/^cheburchecker_.+_amd64\.deb$/.test(name)) {
return 'Пакет Cheburchecker для Debian Linux x86-64.';
}
if (/^cheburchecker_.+_arm64\.deb$/.test(name)) {
return 'Пакет Cheburchecker для Debian Linux ARM64.';
}
if (/^cheburprobe-.+-linux-amd64$/.test(name)) {
return 'Cheburprobe для Linux x86-64.';
}
if (/^cheburprobe-.+-linux-arm64$/.test(name)) {
return 'Cheburprobe для Linux ARM64.';
}
if (/^cheburprobe-.+-windows-x86_64\.exe$/.test(name)) {
return 'Cheburprobe для Windows x86-64.';
}
if (/^cheburprobe_.+_amd64\.deb$/.test(name)) {
return 'Пакет Cheburprobe для Debian Linux x86-64 с сервисом и автообновлением.';
}
if (/^cheburprobe_.+_arm64\.deb$/.test(name)) {
return 'Пакет Cheburprobe для Debian Linux ARM64 с сервисом и автообновлением.';
}
if (/^cheburprobe-.+_.+\.apk$/.test(name)) {
return 'Пакет Cheburprobe для версий OpenWrt с пакетным менеджером APK (25.12+).';
}
if (/^luci-app-cheburprobe-.+\.apk$/.test(name)) {
return 'Интерфейс LuCI для APK-пакета Cheburprobe.';
}
if (/^cheburprobe_.+_.+\.ipk$/.test(name)) {
return 'Пакет Cheburprobe для версий OpenWrt с пакетным менеджером opkg.';
}
if (/^luci-app-cheburprobe_.+_all\.ipk$/.test(name)) {
return 'Интерфейс LuCI для IPK-пакета Cheburprobe.';
}
return 'Файл релиза.';
}
const baseUrl = [
'https://github.com',
encodeURIComponent(context.repo.owner),
encodeURIComponent(context.repo.repo),
'releases',
'download',
encodeURIComponent(tag),
].join('/');
const sourceBaseUrl = [
'https://github.com',
encodeURIComponent(context.repo.owner),
encodeURIComponent(context.repo.repo),
'blob',
encodeURIComponent(tag),
].join('/');
const rows = files.map((name) => {
const url = baseUrl + '/' + encodeURIComponent(name);
return '| [`' + name + '`](' + url + ') | ' + describe(name) + ' |';
});
const body = [
'## Документация',
'',
'- [Документация](' + sourceBaseUrl + (component === 'website' ? '/README.md' : '/' + component + '/README.md') + ')',
'',
component === 'website' ? '## Docker images' : '## Файлы релиза',
'',
...(component === 'website' ? [
'`ghcr.io/' + context.repo.owner.toLowerCase() + '/' + context.repo.repo.toLowerCase() + ':' + tag.slice('website-v'.length) + '`',
'`ghcr.io/' + context.repo.owner.toLowerCase() + '/' + context.repo.repo.toLowerCase() + '-frontend:' + tag.slice('website-v'.length) + '`',
] : ['| Файл | Описание |', '| --- | --- |', ...rows]),
'',
].join('\n');
fs.writeFileSync('release-body.md', body);
- name: Publish draft release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: true
prerelease: ${{ steps.body.outputs.prerelease }}
body_path: release-body.md
fail_on_unmatched_files: ${{ inputs.component != 'website' }}
files: release-artifacts/*