feat: switch versioning

This commit is contained in:
Lowder
2026-09-07 17:35:23 +05:00
parent ed82023d87
commit 04275dbb36
11 changed files with 420 additions and 236 deletions
+95 -76
View File
@@ -1,81 +1,100 @@
name: Build Rust Application
name: Build Reporter
on:
push:
branches: [ master ]
tags: [ 'v*.*.*' ]
tags: [ 'reporter-v*.*.*' ]
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
linux-amd64:
name: Linux amd64 (.deb)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build Debian package
run: cargo deb -p reporter -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-amd64-deb
path: target/debian/*.deb
compression-level: 0
linux-arm64:
name: Linux arm64 (.deb via cross)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: build
target: "aarch64-unknown-linux-gnu"
args: "--release --bin cheburchecker"
strip: true
- name: Create Debian archive
run: cargo deb --target aarch64-unknown-linux-gnu --no-strip --no-build -p reporter -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-arm64-deb
path: target/aarch64-unknown-linux-gnu/debian/*.deb
windows:
name: Windows amd64
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build release binary
run: cargo build --release --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: windows-amd64-exe
path: target/release/*.exe
env:
CARGO_TERM_COLOR: always
jobs:
validate:
uses: ./.github/workflows/validate-release.yml
with:
component: reporter
linux-amd64:
needs: validate
name: Linux amd64 (.deb)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build Debian package
run: cargo deb -p reporter -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-amd64-deb
path: target/debian/*.deb
compression-level: 0
linux-arm64:
needs: validate
name: Linux arm64 (.deb via cross)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: build
target: "aarch64-unknown-linux-gnu"
args: "--release --bin cheburchecker"
strip: true
- name: Create Debian archive
run: cargo deb --target aarch64-unknown-linux-gnu --no-strip --no-build -p reporter -- --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: linux-arm64-deb
path: target/aarch64-unknown-linux-gnu/debian/*.deb
windows:
needs: validate
name: Windows amd64
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build release binary
run: cargo build --release --bin cheburchecker
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: windows-amd64-exe
path: target/release/*.exe
release:
needs: [linux-amd64, linux-arm64, windows]
if: github.event_name == 'push' && github.ref_type == 'tag'
permissions:
contents: write
actions: read
uses: ./.github/workflows/release.yml
with:
component: reporter
artifact-pattern: '*'
+19 -3
View File
@@ -3,7 +3,7 @@ name: Build and Publish Docker Images
on:
push:
branches: [ "master" ]
tags: [ 'v*.*.*' ]
tags: [ 'website-v*.*.*' ]
pull_request:
branches: [ "master" ]
@@ -12,7 +12,13 @@ env:
IMAGE_NAME: ${{ github.repository }}
jobs:
validate:
uses: ./.github/workflows/validate-release.yml
with:
component: website
build:
needs: validate
name: Build ${{ matrix.service }} image
runs-on: ubuntu-latest
strategy:
@@ -54,8 +60,8 @@ jobs:
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}},value=${{ needs.validate.outputs.version }},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.validate.outputs.version }},enable=${{ github.ref_type == 'tag' }}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
@@ -81,3 +87,13 @@ jobs:
- name: Trigger Coolify deploy
run: |
curl --fail --request POST '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
release:
needs: [build]
if: github.event_name == 'push' && github.ref_type == 'tag'
permissions:
contents: write
actions: read
uses: ./.github/workflows/release.yml
with:
component: website
+23 -3
View File
@@ -3,7 +3,7 @@ name: Build Probe
on:
push:
branches: [ master ]
tags: [ 'v*.*.*' ]
tags: [ 'probe-v*.*.*' ]
pull_request:
workflow_dispatch:
@@ -14,7 +14,13 @@ env:
OPENWRT_ARM64_ARCHES: aarch64_generic aarch64_cortex-a53 aarch64_cortex-a72
jobs:
validate:
uses: ./.github/workflows/validate-release.yml
with:
component: probe
linux-amd64:
needs: validate
name: Linux amd64 binary and .deb
runs-on: ubuntu-latest
steps:
@@ -58,6 +64,7 @@ jobs:
compression-level: 0
linux-arm64:
needs: validate
name: Linux arm64 binary, .deb, and OpenWrt packages
runs-on: ubuntu-latest
steps:
@@ -134,6 +141,7 @@ jobs:
compression-level: 0
windows-amd64:
needs: validate
name: Windows amd64 binary
runs-on: windows-latest
steps:
@@ -160,6 +168,7 @@ jobs:
compression-level: 0
docker:
needs: validate
name: Docker image amd64/arm64
runs-on: ubuntu-latest
permissions:
@@ -223,8 +232,8 @@ jobs:
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}},value=${{ needs.validate.outputs.version }},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.validate.outputs.version }},enable=${{ github.ref_type == 'tag' }}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
@@ -239,3 +248,14 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
needs: [linux-amd64, linux-arm64, windows-amd64, docker]
if: github.event_name == 'push' && github.ref_type == 'tag'
permissions:
contents: write
actions: read
uses: ./.github/workflows/release.yml
with:
component: probe
artifact-pattern: 'cheburprobe-*'
+29 -140
View File
@@ -1,8 +1,15 @@
name: Draft Release
name: Draft component release
on:
push:
tags: [ 'v*.*.*' ]
workflow_call:
inputs:
component:
required: true
type: string
artifact-pattern:
required: false
type: string
default: ''
permissions:
actions: read
@@ -17,148 +24,29 @@ jobs:
name: Draft GitHub release
runs-on: ubuntu-latest
steps:
- name: Collect build artifacts
uses: actions/github-script@v8
env:
TAG_NAME: ${{ github.ref_name }}
WORKFLOWS: |
Build Rust Application
Build Probe
- name: Download component artifacts
if: inputs.component != 'website'
uses: actions/download-artifact@v8
with:
script: |
const fs = require('fs');
const path = require('path');
const owner = context.repo.owner;
const repo = context.repo.repo;
const tagName = process.env.TAG_NAME;
const workflows = process.env.WORKFLOWS
.split(/\r?\n/)
.map((name) => name.trim())
.filter(Boolean);
const targetSha = context.sha;
const outDir = path.join(process.cwd(), 'artifact-archives');
const pollDelayMs = 30_000;
const timeoutMs = 30 * 60 * 1000;
fs.mkdirSync(outDir, { recursive: true });
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function findWorkflowRun(workflowName) {
const startedAt = Date.now();
while (Date.now() - startedAt < timeoutMs) {
const runs = await github.paginate(
github.rest.actions.listWorkflowRunsForRepo,
{
owner,
repo,
head_sha: targetSha,
event: 'push',
per_page: 100,
},
);
const run = runs.find((candidate) =>
candidate.name === workflowName &&
candidate.head_sha === targetSha &&
candidate.head_branch === tagName
);
if (run?.status === 'completed') {
if (run.conclusion === 'success') {
return run;
}
throw new Error(
`${workflowName} completed with conclusion ${run.conclusion}: ${run.html_url}`,
);
}
core.info(
run
? `${workflowName} is ${run.status}; waiting for completion.`
: `Waiting for ${workflowName} to start for ${tagName}.`,
);
await sleep(pollDelayMs);
}
throw new Error(`Timed out waiting for ${workflowName} on ${tagName}.`);
}
for (const workflowName of workflows) {
const run = await findWorkflowRun(workflowName);
core.info(`Downloading artifacts from ${workflowName}: ${run.html_url}`);
const artifacts = await github.paginate(
github.rest.actions.listWorkflowRunArtifacts,
{
owner,
repo,
run_id: run.id,
per_page: 100,
},
);
for (const artifact of artifacts.filter((item) => !item.expired)) {
if (artifact.name.endsWith('.dockerbuild')) {
core.info(`Skipping Docker build record artifact ${artifact.name}`);
continue;
}
const archive = await github.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
const artifactPath = path.join(outDir, `${artifact.name}.zip`);
fs.writeFileSync(artifactPath, Buffer.from(archive.data));
core.info(`Saved ${artifactPath}`);
}
}
- name: Extract release assets
shell: bash
run: |
set -euo pipefail
mkdir -p release-artifacts
for archive in artifact-archives/*.zip; do
artifact_name="$(basename "$archive" .zip)"
extract_dir="$(mktemp -d)"
unzip -q "$archive" -d "$extract_dir"
while IFS= read -r -d '' file; do
filename="$(basename "$file")"
target="release-artifacts/$filename"
if [ -e "$target" ]; then
target="release-artifacts/${artifact_name}-${filename}"
fi
mv "$file" "$target"
done < <(find "$extract_dir" -type f -print0)
rm -rf "$extract_dir"
done
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();
@@ -222,14 +110,14 @@ jobs:
const body = [
'## Документация',
'',
'- [Cheburprobe](' + sourceBaseUrl + '/probe/README.md)',
'- [Cheburchecker](' + sourceBaseUrl + '/reporter/README.md)',
'- [Документация](' + sourceBaseUrl + (component === 'website' ? '/README.md' : '/' + component + '/README.md') + ')',
'',
'## Файлы релиза',
component === 'website' ? '## Docker images' : '## Файлы релиза',
'',
'| Файл | Описание |',
'| --- | --- |',
...rows,
...(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');
@@ -241,6 +129,7 @@ jobs:
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: true
fail_on_unmatched_files: ${{ inputs.component != 'website' }}
files: release-artifacts/*
+24
View File
@@ -0,0 +1,24 @@
name: Validate component version
on:
workflow_call:
inputs:
component:
required: true
type: string
outputs:
version:
value: ${{ jobs.validate.outputs.version }}
jobs:
validate:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v6
- name: Validate release tag
id: version
env:
COMPONENT: ${{ inputs.component }}
run: python3 .github/scripts/validate-release.py "$COMPONENT"