mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-01-24 12:22:49 -05:00
feat: test
This commit is contained in:
9
.github/workflows/build-release.yml
vendored
9
.github/workflows/build-release.yml
vendored
@@ -1,12 +1,7 @@
|
||||
name: 'Build and Release CreamLinux'
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
tags:
|
||||
- 'v*' # Run on any tag that starts with 'v', e.g., v0.1.0
|
||||
pull_request:
|
||||
branches: ['main']
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
12
.releaserc
12
.releaserc
@@ -29,6 +29,18 @@
|
||||
{
|
||||
"path": "latest.json",
|
||||
"label": "Updater manifest file"
|
||||
},
|
||||
{
|
||||
"path": "src-tauri/target/release/bundle/appimage/Creamlinux_*.AppImage",
|
||||
"label": "Linux AppImage"
|
||||
},
|
||||
{
|
||||
"path": "src-tauri/target/release/bundle/deb/Creamlinux_*.deb",
|
||||
"label": "Linux DEB package"
|
||||
},
|
||||
{
|
||||
"path": "src-tauri/target/release/bundle/rpm/Creamlinux-*.rpm",
|
||||
"label": "Linux RPM package"
|
||||
}
|
||||
],
|
||||
"successComment": ":tada: This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release](https://github.com/${process.env.GITHUB_REPOSITORY}/releases/tag/${nextRelease.gitTag})"
|
||||
|
||||
@@ -2,86 +2,56 @@ import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
// Recreate __dirname
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
// Read the current version from package.json
|
||||
const packageJsonPath = path.join(__dirname, '..', 'package.json')
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
||||
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'))
|
||||
const version = packageJson.version
|
||||
console.log(`Current version: ${version}`)
|
||||
|
||||
// Get the current date in RFC 3339 format for pub_date
|
||||
const pubDate = new Date().toISOString()
|
||||
|
||||
// Base URL where the assets will be available
|
||||
const baseUrl = 'https://github.com/novattz/rust-gui-dev/releases/download'
|
||||
const releaseTag = `v${version}`
|
||||
const releaseUrl = `${baseUrl}/${releaseTag}`
|
||||
|
||||
// Create the updater JSON structure
|
||||
function findSigFile(dir, baseName) {
|
||||
const files = fs.readdirSync(dir)
|
||||
const sigFile = files.find((f) => f.startsWith(baseName) && f.endsWith('.sig'))
|
||||
return sigFile ? fs.readFileSync(path.join(dir, sigFile), 'utf8').trim() : null
|
||||
}
|
||||
|
||||
function addPlatform(platformKey, folder, baseName, ext) {
|
||||
const dir = path.join('src-tauri', 'target', 'release', 'bundle', folder)
|
||||
const fileName = `${baseName}${ext}`
|
||||
const filePath = path.join(dir, fileName)
|
||||
|
||||
if (fs.existsSync(filePath)) {
|
||||
const signature = findSigFile(dir, baseName)
|
||||
if (!signature) {
|
||||
console.warn(`⚠️ Signature not found for ${fileName}`)
|
||||
return
|
||||
}
|
||||
|
||||
updaterJson.platforms[platformKey] = {
|
||||
url: `${releaseUrl}/${fileName}`,
|
||||
signature,
|
||||
}
|
||||
} else {
|
||||
console.warn(`⚠️ File not found: ${filePath}`)
|
||||
}
|
||||
}
|
||||
|
||||
const updaterJson = {
|
||||
version,
|
||||
notes: `Release version ${version}`,
|
||||
pub_date: pubDate,
|
||||
platforms: {
|
||||
// Windows x64
|
||||
'windows-x86_64': {
|
||||
url: `${releaseUrl}/creamlinux-setup.exe`,
|
||||
signature: readSignature('windows', 'creamlinux-setup.exe'),
|
||||
},
|
||||
// Linux x64
|
||||
'linux-x86_64': {
|
||||
url: `${releaseUrl}/creamlinux.AppImage`,
|
||||
signature: readSignature('linux', 'creamlinux.AppImage'),
|
||||
},
|
||||
// macOS x64 and arm64 (universal)
|
||||
'darwin-universal': {
|
||||
url: `${releaseUrl}/creamlinux.app.tar.gz`,
|
||||
signature: readSignature('macos', 'creamlinux.app.tar.gz'),
|
||||
},
|
||||
},
|
||||
platforms: {},
|
||||
}
|
||||
|
||||
// Write the updater JSON file
|
||||
addPlatform('linux-x86_64', 'appimage', `Creamlinux_${version}_amd64`, '.AppImage')
|
||||
addPlatform('linux-deb', 'deb', `Creamlinux_${version}_amd64`, '.deb')
|
||||
addPlatform('linux-rpm', 'rpm', `Creamlinux-${version}-1.x86_64`, '.rpm')
|
||||
|
||||
// Optional: Windows/macOS can still be supported later
|
||||
|
||||
fs.writeFileSync('latest.json', JSON.stringify(updaterJson, null, 2))
|
||||
console.log('Created latest.json updater file')
|
||||
|
||||
// Helper function to read signature files
|
||||
function readSignature(platform, filename) {
|
||||
try {
|
||||
// Determine path based on platform
|
||||
let sigPath
|
||||
|
||||
switch (platform) {
|
||||
case 'windows':
|
||||
// Check both NSIS and MSI
|
||||
try {
|
||||
sigPath = path.join('src-tauri', 'target', 'release', 'bundle', 'nsis', `${filename}.sig`)
|
||||
return fs.readFileSync(sigPath, 'utf8').trim()
|
||||
} catch (e) {
|
||||
sigPath = path.join('src-tauri', 'target', 'release', 'bundle', 'msi', `${filename}.sig`)
|
||||
return fs.readFileSync(sigPath, 'utf8').trim()
|
||||
}
|
||||
case 'linux':
|
||||
sigPath = path.join(
|
||||
'src-tauri',
|
||||
'target',
|
||||
'release',
|
||||
'bundle',
|
||||
'appimage',
|
||||
`${filename}.sig`
|
||||
)
|
||||
return fs.readFileSync(sigPath, 'utf8').trim()
|
||||
case 'macos':
|
||||
sigPath = path.join('src-tauri', 'target', 'release', 'bundle', 'macos', `${filename}.sig`)
|
||||
return fs.readFileSync(sigPath, 'utf8').trim()
|
||||
default:
|
||||
throw new Error(`Unknown platform: ${platform}`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error reading signature for ${platform}/${filename}:`, error.message)
|
||||
return ''
|
||||
}
|
||||
}
|
||||
console.log('✅ Created latest.json updater file')
|
||||
|
||||
114
scripts/prepare-release.js
Normal file
114
scripts/prepare-release.js
Normal file
@@ -0,0 +1,114 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { execSync } from 'node:child_process'
|
||||
import readline from 'node:readline'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
// Utility
|
||||
function log(msg) {
|
||||
console.log(`\x1b[36m[release]\x1b[0m ${msg}`)
|
||||
}
|
||||
|
||||
function bumpPatchVersion(version) {
|
||||
const [major, minor, patch] = version.split('.').map(Number)
|
||||
return `${major}.${minor}.${patch + 1}`
|
||||
}
|
||||
|
||||
// STEP 1: Read + bump version
|
||||
const pkgPath = path.join(__dirname, '..', 'package.json')
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
||||
const oldVersion = pkg.version
|
||||
const newVersion = bumpPatchVersion(oldVersion)
|
||||
pkg.version = newVersion
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2))
|
||||
log(`Version bumped: ${oldVersion} → ${newVersion}`)
|
||||
|
||||
// STEP 2: Update Cargo.toml
|
||||
const cargoPath = path.join(__dirname, '..', 'src-tauri', 'Cargo.toml')
|
||||
let cargoToml = fs.readFileSync(cargoPath, 'utf8')
|
||||
cargoToml = cargoToml.replace(/version\s*=\s*"[^"]+"/, `version = "${newVersion}"`)
|
||||
fs.writeFileSync(cargoPath, cargoToml)
|
||||
log(`Updated Cargo.toml`)
|
||||
|
||||
// STEP 3: Update tauri.conf.json
|
||||
const tauriPath = path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json')
|
||||
const tauriConfig = JSON.parse(fs.readFileSync(tauriPath, 'utf8'))
|
||||
tauriConfig.version = newVersion
|
||||
fs.writeFileSync(tauriPath, JSON.stringify(tauriConfig, null, 2))
|
||||
log(`Updated tauri.conf.json`)
|
||||
|
||||
// STEP 4: Build
|
||||
log('Building project with Tauri...')
|
||||
execSync('NO_STRIP=true npm run tauri build', { stdio: 'inherit' })
|
||||
|
||||
// STEP 5: Generate latest.json
|
||||
const pubDate = new Date().toISOString()
|
||||
const baseUrl = `https://github.com/novattz/rust-gui-dev/releases/download/v${newVersion}`
|
||||
const latest = {
|
||||
version: newVersion,
|
||||
notes: `Release version ${newVersion}`,
|
||||
pub_date: pubDate,
|
||||
platforms: {},
|
||||
}
|
||||
|
||||
function findSig(dir, base) {
|
||||
const files = fs.readdirSync(dir)
|
||||
const sig = files.find((f) => f.startsWith(base) && f.endsWith('.sig'))
|
||||
return sig ? fs.readFileSync(path.join(dir, sig), 'utf8').trim() : null
|
||||
}
|
||||
|
||||
function addPlatform(key, folder, baseName, ext) {
|
||||
const dir = path.join(__dirname, '..', 'src-tauri', 'target', 'release', 'bundle', folder)
|
||||
const file = `${baseName}${ext}`
|
||||
const full = path.join(dir, file)
|
||||
if (!fs.existsSync(full)) return
|
||||
const sig = findSig(dir, baseName)
|
||||
if (!sig) return
|
||||
latest.platforms[key] = {
|
||||
url: `${baseUrl}/${file}`,
|
||||
signature: sig,
|
||||
}
|
||||
}
|
||||
|
||||
addPlatform('linux-x86_64', 'appimage', `Creamlinux_${newVersion}_amd64`, '.AppImage')
|
||||
addPlatform('linux-deb', 'deb', `Creamlinux_${newVersion}_amd64`, '.deb')
|
||||
addPlatform('linux-rpm', 'rpm', `Creamlinux-${newVersion}-1.x86_64`, '.rpm')
|
||||
fs.writeFileSync(path.join(__dirname, '..', 'latest.json'), JSON.stringify(latest, null, 2))
|
||||
log(`Generated latest.json`)
|
||||
|
||||
// STEP 6: Update changelog
|
||||
let changelogPath = path.join(__dirname, '..', 'CHANGELOG.md')
|
||||
let changelog = fs.existsSync(changelogPath)
|
||||
? fs.readFileSync(changelogPath, 'utf8')
|
||||
: '# Changelog\n\n'
|
||||
const date = new Date().toISOString().split('T')[0]
|
||||
let newEntry = `## [${newVersion}] - ${date}\n\n`
|
||||
try {
|
||||
const lastTag = execSync('git describe --tags --abbrev=0').toString().trim()
|
||||
const commits = execSync(`git log ${lastTag}..HEAD --pretty=format:"- %s (%an)"`)
|
||||
.toString()
|
||||
.trim()
|
||||
newEntry += commits ? `${commits}\n\n` : 'No notable changes.\n\n'
|
||||
} catch {
|
||||
newEntry += 'Initial release.\n\n'
|
||||
}
|
||||
changelog = changelog.replace('# Changelog\n\n', `# Changelog\n\n${newEntry}`)
|
||||
fs.writeFileSync(changelogPath, changelog)
|
||||
log(`Updated CHANGELOG.md`)
|
||||
|
||||
// STEP 7: Confirm + push
|
||||
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
||||
rl.question('Review the changelog and press [Enter] to commit, tag, and push release... ', () => {
|
||||
execSync(
|
||||
'git add package.json CHANGELOG.md src-tauri/Cargo.toml src-tauri/tauri.conf.json latest.json',
|
||||
{ stdio: 'inherit' }
|
||||
)
|
||||
execSync(`git commit -m "chore(release): v${newVersion}"`, { stdio: 'inherit' })
|
||||
execSync(`git tag v${newVersion}`, { stdio: 'inherit' })
|
||||
execSync('git push && git push --tags', { stdio: 'inherit' })
|
||||
log('🚀 Release pushed!')
|
||||
rl.close()
|
||||
})
|
||||
Reference in New Issue
Block a user