mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-01-30 23:32:49 -05:00
chore: Stop tracking for script
This commit is contained in:
214
.github/workflows/build-release.yml
vendored
214
.github/workflows/build-release.yml
vendored
@@ -1,214 +0,0 @@
|
|||||||
name: Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
# For the Tauri updater public key
|
|
||||||
TAURI_PUBLIC_KEY: ${{ secrets.TAURI_PUBLIC_KEY }}
|
|
||||||
# For signing the updates
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
semantic-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# Skip if this is already a tag push
|
|
||||||
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
|
|
||||||
outputs:
|
|
||||||
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
|
|
||||||
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0 # Required for semantic-release
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Run semantic-release
|
|
||||||
id: semantic
|
|
||||||
run: npx semantic-release
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
build-and-release:
|
|
||||||
needs: [semantic-release]
|
|
||||||
# Only run if a new release was published or if this is a tag push
|
|
||||||
if: needs.semantic-release.outputs.new_release_published == 'true' || startsWith(github.ref, 'refs/tags/')
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
platform: [ubuntu-latest]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
# If this is a tag push, we need to check out that specific tag
|
|
||||||
ref: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || github.event.repository.default_branch }}
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Run ESLint
|
|
||||||
run: npm run lint
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Cache Rust dependencies
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: 'src-tauri -> target'
|
|
||||||
cache-on-failure: true
|
|
||||||
|
|
||||||
# Setup platform-specific dependencies
|
|
||||||
- name: Install Linux dependencies
|
|
||||||
if: matrix.platform == 'ubuntu-latest'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
|
||||||
|
|
||||||
- name: Install macOS dependencies
|
|
||||||
if: matrix.platform == 'macos-latest'
|
|
||||||
run: |
|
|
||||||
rustup target add aarch64-apple-darwin
|
|
||||||
|
|
||||||
- name: Install Windows dependencies
|
|
||||||
if: matrix.platform == 'windows-latest'
|
|
||||||
run: |
|
|
||||||
# Windows typically doesn't need additional dependencies
|
|
||||||
|
|
||||||
# Install glob for the updater script
|
|
||||||
- name: Install glob for updater
|
|
||||||
if: matrix.platform == 'ubuntu-latest'
|
|
||||||
run: npm install -g glob
|
|
||||||
|
|
||||||
# Sync package version
|
|
||||||
- name: Sync Version
|
|
||||||
run: npm run sync-version
|
|
||||||
|
|
||||||
# Build the app with updater artifacts
|
|
||||||
- name: Build the app
|
|
||||||
run: npm run tauri build
|
|
||||||
|
|
||||||
# Upload the artifacts for each platform
|
|
||||||
- name: Upload Linux artifacts
|
|
||||||
if: matrix.platform == 'ubuntu-latest'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: creamlinux-linux
|
|
||||||
path: |
|
|
||||||
src-tauri/target/release/bundle/deb/*.deb
|
|
||||||
src-tauri/target/release/bundle/appimage/*.AppImage
|
|
||||||
src-tauri/target/release/bundle/appimage/*.AppImage.sig
|
|
||||||
|
|
||||||
- name: Upload macOS artifacts
|
|
||||||
if: matrix.platform == 'macos-latest'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: creamlinux-macos
|
|
||||||
path: |
|
|
||||||
src-tauri/target/release/bundle/macos/*.app
|
|
||||||
src-tauri/target/release/bundle/macos/*.app.tar.gz
|
|
||||||
src-tauri/target/release/bundle/macos/*.app.tar.gz.sig
|
|
||||||
src-tauri/target/release/bundle/dmg/*.dmg
|
|
||||||
|
|
||||||
- name: Upload Windows artifacts
|
|
||||||
if: matrix.platform == 'windows-latest'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: creamlinux-windows
|
|
||||||
path: |
|
|
||||||
src-tauri/target/release/bundle/msi/*.msi
|
|
||||||
src-tauri/target/release/bundle/msi/*.msi.sig
|
|
||||||
src-tauri/target/release/bundle/nsis/*.exe
|
|
||||||
src-tauri/target/release/bundle/nsis/*.exe.sig
|
|
||||||
|
|
||||||
create-github-release:
|
|
||||||
needs: [semantic-release, build-and-release]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# Only run if we have a tag (either from semantic-release or a manual tag push)
|
|
||||||
if: needs.semantic-release.outputs.new_release_published == 'true' || startsWith(github.ref, 'refs/tags/')
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
|
|
||||||
- name: Install glob
|
|
||||||
run: npm install -g glob
|
|
||||||
|
|
||||||
- name: Download all artifacts
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: artifacts
|
|
||||||
|
|
||||||
# Flatten the artifacts structure
|
|
||||||
- name: Prepare artifacts for release
|
|
||||||
run: |
|
|
||||||
mkdir -p release_assets
|
|
||||||
find artifacts -type f -name "*.deb" -o -name "*.AppImage" -o -name "*.AppImage.sig" -o -name "*.dmg" -o -name "*.app.tar.gz" -o -name "*.app.tar.gz.sig" -o -name "*.msi" -o -name "*.msi.sig" -o -name "*.exe" -o -name "*.exe.sig" | xargs -I{} cp {} release_assets/
|
|
||||||
|
|
||||||
# Generate updater JSON
|
|
||||||
- name: Generate updater JSON
|
|
||||||
run: |
|
|
||||||
npm install glob
|
|
||||||
# Get version from refs/tags/v1.0.0 format
|
|
||||||
VERSION="${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || needs.semantic-release.outputs.new_release_version }}"
|
|
||||||
VERSION="${VERSION#v}" # Remove 'v' prefix if it exists
|
|
||||||
echo "Release version: $VERSION"
|
|
||||||
|
|
||||||
# Create a simple updater JSON
|
|
||||||
cat > release_assets/latest.json << EOF
|
|
||||||
{
|
|
||||||
"version": "$VERSION",
|
|
||||||
"notes": "Release version $VERSION",
|
|
||||||
"pub_date": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
|
|
||||||
"platforms": {
|
|
||||||
"windows-x86_64": {
|
|
||||||
"url": "https://github.com/${{ github.repository }}/releases/download/v$VERSION/creamlinux_$VERSION_x64_en-US.msi",
|
|
||||||
"signature": "$(cat artifacts/creamlinux-windows/msi/*.msi.sig 2>/dev/null || echo '')"
|
|
||||||
},
|
|
||||||
"linux-x86_64": {
|
|
||||||
"url": "https://github.com/${{ github.repository }}/releases/download/v$VERSION/Creamlinux_${VERSION}_amd64.AppImage",
|
|
||||||
"signature": "$(cat artifacts/creamlinux-linux/appimage/*.AppImage.sig 2>/dev/null || echo '')"
|
|
||||||
},
|
|
||||||
"darwin-universal": {
|
|
||||||
"url": "https://github.com/${{ github.repository }}/releases/download/v$VERSION/creamlinux.app.tar.gz",
|
|
||||||
"signature": "$(cat artifacts/creamlinux-macos/macos/*.app.tar.gz.sig 2>/dev/null || echo '')"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat release_assets/latest.json
|
|
||||||
|
|
||||||
# Create GitHub release
|
|
||||||
- name: Create GitHub release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: release_assets/*
|
|
||||||
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('v{0}', needs.semantic-release.outputs.new_release_version) }}
|
|
||||||
generate_release_notes: true
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
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