mirror of
https://github.com/Novattz/creamlinux-installer.git
synced 2026-08-01 19:18:25 -04:00
301 lines
10 KiB
YAML
301 lines
10 KiB
YAML
name: 'Build and Release'
|
|
|
|
on:
|
|
workflow_dispatch: # Allows manual triggering
|
|
|
|
jobs:
|
|
create-release:
|
|
permissions:
|
|
contents: write
|
|
runs-on: 'ubuntu-24.04'
|
|
outputs:
|
|
release_id: ${{ steps.create-release.outputs.result }}
|
|
version: ${{ steps.get-version.outputs.version }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: setup node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: lts/*
|
|
cache: 'npm'
|
|
|
|
- name: get version
|
|
id: get-version
|
|
run: |
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Package version: $VERSION"
|
|
|
|
- name: get changelog notes for version
|
|
id: changelog
|
|
env:
|
|
VERSION: ${{ steps.get-version.outputs.version }}
|
|
run: |
|
|
NOTES="$(awk -v ver="$VERSION" '
|
|
BEGIN { found=0 }
|
|
$0 ~ "^## \\[" ver "\\] - " { found=1 }
|
|
found {
|
|
if ($0 ~ "^## \\[" && $0 !~ "^## \\[" ver "\\] - " ) exit
|
|
print
|
|
}
|
|
' CHANGELOG.md)"
|
|
|
|
if [ -z "$NOTES" ]; then
|
|
echo "No changelog entry found for version $VERSION" >&2
|
|
exit 1
|
|
fi
|
|
|
|
{
|
|
echo "notes<<EOF"
|
|
echo "$NOTES"
|
|
echo "EOF"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: install nix
|
|
uses: DeterminateSystems/nix-installer-action@main
|
|
|
|
- name: update package.nix version, date, and npm hash
|
|
env:
|
|
VERSION: ${{ steps.get-version.outputs.version }}
|
|
run: |
|
|
# Get today's date in YYYY-MM-DD format
|
|
TODAY=$(date -u +%Y-%m-%d)
|
|
|
|
# Compute new npm deps hash from package-lock.json
|
|
HASH=$(nix-shell -p prefetch-npm-deps --run "prefetch-npm-deps package-lock.json" 2>/dev/null)
|
|
echo "New hash: $HASH"
|
|
|
|
# Update version string (e.g. 1.5.5-unstable-2026-05-03)
|
|
sed -i "s|version = \"[^\"]*\"|version = \"${VERSION}-unstable-${TODAY}\"|" package.nix
|
|
|
|
# Update npm deps hash
|
|
sed -i "s|hash = \"[^\"]*\"|hash = \"${HASH}\"|" package.nix
|
|
|
|
echo "Updated package.nix:"
|
|
grep -E 'version|hash' package.nix
|
|
|
|
- name: commit updated package.nix
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add package.nix
|
|
if [[ $(git status -s) ]]; then
|
|
git commit -m "chore: update package.nix for v${{ steps.get-version.outputs.version }}"
|
|
git push
|
|
fi
|
|
|
|
- name: create draft release
|
|
id: create-release
|
|
uses: actions/github-script@v6
|
|
env:
|
|
VERSION: ${{ steps.get-version.outputs.version }}
|
|
NOTES: ${{ steps.changelog.outputs.notes }}
|
|
with:
|
|
script: |
|
|
const { data } = await github.rest.repos.createRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag_name: `v${process.env.VERSION}`,
|
|
name: `v${process.env.VERSION}`,
|
|
body: process.env.NOTES,
|
|
draft: true,
|
|
prerelease: false
|
|
})
|
|
return data.id
|
|
|
|
build-tauri:
|
|
needs: create-release
|
|
permissions:
|
|
contents: write
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: 'ubuntu-24.04'
|
|
args: ''
|
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: lts/*
|
|
cache: 'npm'
|
|
|
|
- name: Install Rust stable
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Rust cache
|
|
uses: swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: './src-tauri -> target'
|
|
|
|
- name: Install system dependencies (Ubuntu)
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libwebkit2gtk-4.1-0=2.44.0-2 \
|
|
libwebkit2gtk-4.1-dev=2.44.0-2 \
|
|
libjavascriptcoregtk-4.1-0=2.44.0-2 \
|
|
libjavascriptcoregtk-4.1-dev=2.44.0-2 \
|
|
gir1.2-javascriptcoregtk-4.1=2.44.0-2 \
|
|
gir1.2-webkit2-4.1=2.44.0-2 \
|
|
libappindicator3-dev \
|
|
librsvg2-dev \
|
|
patchelf \
|
|
build-essential \
|
|
curl \
|
|
wget \
|
|
file \
|
|
libssl-dev \
|
|
libgtk-3-dev
|
|
|
|
- name: Install frontend dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Tauri app
|
|
run: npm run tauri build
|
|
env:
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
|
|
- name: Strip bundled GTK/WebKit/GLib stack, rely on the host's instead
|
|
run: |
|
|
set -euo pipefail
|
|
cd src-tauri/target/release/bundle/appimage
|
|
APPIMAGE=$(ls *.AppImage)
|
|
chmod +x "$APPIMAGE"
|
|
./"$APPIMAGE" --appimage-extract >/dev/null
|
|
|
|
LDCONFIG_CACHE=$(ldconfig -p)
|
|
resolve_lib_path() {
|
|
awk -v lib="$1" '$1==lib {print $NF; exit}' <<< "$LDCONFIG_CACHE"
|
|
}
|
|
|
|
# WebKitGTK bundled by the AppImage tooling is pinned to whatever the
|
|
# build image ships, and drifts out of sync with newer host systems
|
|
# (freezes on old bundled WebKit, EGL/DMABUF crashes on some newer
|
|
# ones). The only configuration that's tested clean is deferring the
|
|
# whole GTK/WebKit/GLib stack to the host's own matched libraries, so
|
|
# we compute the full dependency closure from the host side (whatever
|
|
# is actually installed here) and strip every bundled copy that's
|
|
# also part of that closure.
|
|
declare -A EXCLUDE
|
|
for seed in libwebkit2gtk-4.1.so.0 libglib-2.0.so.0 libgio-2.0.so.0 libgobject-2.0.so.0 libgmodule-2.0.so.0; do
|
|
EXCLUDE[$seed]=1
|
|
done
|
|
|
|
changed=1
|
|
while [ "$changed" -eq 1 ]; do
|
|
changed=0
|
|
for lib in "${!EXCLUDE[@]}"; do
|
|
hostpath=$(resolve_lib_path "$lib")
|
|
[ -n "$hostpath" ] && [ -e "$hostpath" ] || continue
|
|
deps=$(ldd "$hostpath" 2>/dev/null | grep -oE '[a-zA-Z0-9._+-]+\.so[0-9.]*' | sort -u) || true
|
|
for d in $deps; do
|
|
if [ -z "${EXCLUDE[$d]:-}" ]; then
|
|
if find squashfs-root/usr/lib -maxdepth 1 -name "${d}*" 2>/dev/null | grep -q .; then
|
|
EXCLUDE[$d]=1
|
|
changed=1
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
done
|
|
|
|
echo "Excluding ${#EXCLUDE[@]} bundled libraries, relying on the host's instead:"
|
|
for lib in "${!EXCLUDE[@]}"; do echo " $lib"; done | sort
|
|
|
|
for lib in "${!EXCLUDE[@]}"; do
|
|
find squashfs-root/usr/lib -maxdepth 1 -name "${lib%.so*}.so*" -delete
|
|
done
|
|
|
|
curl -sSL -o appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
|
|
chmod +x appimagetool
|
|
rm -f "$APPIMAGE"
|
|
ARCH=x86_64 ./appimagetool --appimage-extract-and-run squashfs-root "$APPIMAGE"
|
|
rm -rf squashfs-root appimagetool
|
|
|
|
- name: Sign artifacts and upload to release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
VERSION: ${{ needs.create-release.outputs.version }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
set -euo pipefail
|
|
cd src-tauri/target/release/bundle
|
|
|
|
APPIMAGE_PATH=$(ls appimage/*.AppImage)
|
|
DEB_PATH=$(ls deb/*.deb)
|
|
RPM_PATH=$(ls rpm/*.rpm)
|
|
|
|
for f in "$APPIMAGE_PATH" "$DEB_PATH" "$RPM_PATH"; do
|
|
npx --prefix "$GITHUB_WORKSPACE" tauri signer sign "$f"
|
|
done
|
|
|
|
APPIMAGE_NAME=$(basename "$APPIMAGE_PATH")
|
|
DEB_NAME=$(basename "$DEB_PATH")
|
|
RPM_NAME=$(basename "$RPM_PATH")
|
|
|
|
jq -n \
|
|
--arg version "$VERSION" \
|
|
--arg pub_date "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
|
|
--arg appimage_sig "$(cat "${APPIMAGE_PATH}.sig")" \
|
|
--arg appimage_url "https://github.com/$REPO/releases/latest/download/$APPIMAGE_NAME" \
|
|
--arg deb_sig "$(cat "${DEB_PATH}.sig")" \
|
|
--arg deb_url "https://github.com/$REPO/releases/latest/download/$DEB_NAME" \
|
|
--arg rpm_sig "$(cat "${RPM_PATH}.sig")" \
|
|
--arg rpm_url "https://github.com/$REPO/releases/latest/download/$RPM_NAME" \
|
|
'{
|
|
version: $version,
|
|
notes: "",
|
|
pub_date: $pub_date,
|
|
platforms: {
|
|
"linux-x86_64": { signature: $appimage_sig, url: $appimage_url },
|
|
"linux-x86_64-appimage": { signature: $appimage_sig, url: $appimage_url },
|
|
"linux-x86_64-deb": { signature: $deb_sig, url: $deb_url },
|
|
"linux-x86_64-rpm": { signature: $rpm_sig, url: $rpm_url }
|
|
}
|
|
}' > latest.json
|
|
|
|
gh release upload "v${VERSION}" \
|
|
"$APPIMAGE_PATH" "${APPIMAGE_PATH}.sig" \
|
|
"$DEB_PATH" "${DEB_PATH}.sig" \
|
|
"$RPM_PATH" "${RPM_PATH}.sig" \
|
|
latest.json \
|
|
--clobber \
|
|
--repo "$REPO"
|
|
|
|
publish-release:
|
|
name: Publish release
|
|
needs: [create-release, build-tauri]
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Publish GitHub release (unset draft)
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const release_id = Number("${{ needs.create-release.outputs.release_id }}");
|
|
|
|
await github.rest.repos.updateRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
release_id,
|
|
draft: false
|
|
});
|