[feat] add github actions scripts

This commit is contained in:
dijunkun
2025-08-10 00:03:13 +08:00
parent 1a1bbe3e4d
commit f2664daaec
14 changed files with 1134 additions and 22 deletions

213
.github/workflows/release.yaml.bak vendored Normal file
View File

@@ -0,0 +1,213 @@
name: Build and Release CrossDesk
on:
push:
branches: [release]
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Build on (${{ matrix.runner }} ${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: x86_64
platform: macos
runner: macos-13
cache-key: intel
out-dir: ./build/macosx/x86_64/release/crossdesk
artifact-name: crossdesk-macos-x86_64
package_script: ./scripts/macosx/pkg_x86_64.sh
- arch: arm64
platform: macos
runner: macos-14
cache-key: arm
out-dir: ./build/macosx/arm64/release/crossdesk
artifact-name: crossdesk-macos-arm64
package_script: ./scripts/macosx/pkg_arm64.sh
- arch: x86_64
platform: windows
runner: windows-2022
cache-key: intel
out-dir: ./build/win/x86_64/release/crossdesk
artifact-name: crossdesk-win-x86_64
package_script: ./scripts/windows/nsis_script.nsi
- arch: x86_64
platform: linux
runner: ubuntu-22.04
cache-key: intel
out-dir: ./build/linux/x86_64/release/crossdesk
artifact-name: crossdesk-linux-x86_64
package_script: ./scripts/linux/pkg_x86_64.sh
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Install xmake
if: runner.os == 'macOS'
run: brew install xmake
- name: Install xmake (Ubuntu)
if: runner.os == 'Linux'
run: |
curl -fsSL https://xmake.io/shget.text | bash
source ~/.xmake/profile
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install \
libxcb-randr0-dev \
libxcb-xtest0-dev \
libxcb-xinerama0-dev \
libxcb-shape0-dev \
libxcb-xkb-dev \
libxcb-xfixes0-dev \
libxv-dev \
libxtst-dev \
libasound2-dev \
libsndio-dev \
libxcb-shm0-dev \
libxrandr-dev \
libpulse-dev
- name: Install xmake (Windows)
if: runner.os == 'Windows'
run: |
Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content
echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Build CrossDesk
run: xmake b -vy crossdesk
- name: Cache xmake dependencies (Linux/macOS)
if: runner.os != 'Windows'
uses: actions/cache@v4
with:
path: ~/.xmake/packages
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
- name: Get LOCALAPPDATA path (Windows)
if: runner.os == 'Windows'
id: localappdata
run: |
echo "localappdata=$env:LOCALAPPDATA" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Cache xmake dependencies (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: ${{ steps.localappdata.outputs.localappdata }}\.xmake\packages
key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }}
restore-keys: |
${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-
# - name: Decode and save certificate
# shell: bash
# run: |
# mkdir -p certs
# echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/cert.crt
# - name: Package CrossDesk app
# if: runner.os != 'Windows'
# run: |
# chmod +x ${{ matrix.package_script }}
# ${{ matrix.package_script }}
# - name: Package CrossDesk app (Windows)
# if: runner.os == 'Windows'
# run: "& makensis.exe ${{ matrix.package_script }}"
# working-directory: ${{ github.workspace }}
# - name: Upload build artifacts
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.artifact-name }}-pkg
# path: crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg
# - name: Move files to release dir
# run: |
# mkdir -p release
# cp crossdesk-${{ matrix.platform }}-${{ matrix.arch }}-v0.0.1.pkg release/
# release:
# name: Publish Release
# if: startsWith(github.ref, 'refs/tags/v')
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Download all artifacts
# uses: actions/download-artifact@v4
# with:
# path: artifacts
# - name: Extract version number
# id: version
# run: |
# VERSION="${GITHUB_REF##*/}"
# VERSION_NUM="${VERSION#v}"
# echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_OUTPUT
# - name: Rename artifacts
# run: |
# mkdir -p release
# cp artifacts/crossdesk-macos-x86_64-pkg/* release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg
# cp artifacts/crossdesk-macos-arm64-pkg/* release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg
# - name: Upload to Versioned GitHub Release
# uses: softprops/action-gh-release@v2
# with:
# tag_name: v${{ steps.version.outputs.VERSION_NUM }}
# name: Release v${{ steps.version.outputs.VERSION_NUM }}
# draft: false
# prerelease: false
# files: release/*
# generate_release_notes: false
# body: |
# Binary release only. Source code is not included.
# - name: Upload to 'latest' Release
# run: |
# mkdir -p release/latest
# cp release/crossdesk-macos-x86_64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-x86_64-latest.pkg
# cp release/crossdesk-macos-aarch64-v${{ steps.version.outputs.VERSION_NUM }}.pkg release/latest/crossdesk-macos-aarch64-latest.pkg
# - name: Create or update 'latest' tag
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# git tag -f latest
# git push origin latest --force
# - name: Upload to GitHub Release (latest)
# uses: softprops/action-gh-release@v2
# with:
# tag_name: latest
# name: Latest Release
# draft: false
# prerelease: false
# files: |
# release/latest/crossdesk-macos-*.pkg
# generate_release_notes: false