mirror of
https://github.com/appdev/siyuan-unlock.git
synced 2026-03-07 09:17:42 +08:00
229 lines
8.7 KiB
YAML
229 lines
8.7 KiB
YAML
name: CD For SiYuan Unlock
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
repo_name_android: "siyuan-android"
|
|
repo_name: "siyuan-unlock"
|
|
repo_owner: "appdev"
|
|
package_json: "app/package.json"
|
|
|
|
jobs:
|
|
create_release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
release_version: ${{ steps.release_info.outputs.release_version }}
|
|
version: ${{ steps.version.outputs.value }}
|
|
packageManager: ${{ steps.packageManager.outputs.value }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- run: pip install PyGithub
|
|
|
|
- name: Extract version from package.json
|
|
uses: sergeysova/jq-action@v2
|
|
id: version
|
|
with:
|
|
cmd: 'jq .version ${{ env.package_json }} -r'
|
|
|
|
- name: Extract electronVersion from package.json
|
|
uses: sergeysova/jq-action@v2
|
|
id: electronVersion
|
|
with:
|
|
cmd: "jq .devDependencies.electron ${{ env.package_json }} -r"
|
|
|
|
- name: Extract packageManager from package.json
|
|
uses: sergeysova/jq-action@v2
|
|
id: packageManager
|
|
with:
|
|
cmd: "jq .packageManager ${{ env.package_json }} -r"
|
|
|
|
- name: Gather Release Information
|
|
id: release_info
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.value }}
|
|
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
|
|
RELEASE_VERSION="v${VERSION}-${TIMESTAMP}"
|
|
echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
|
|
echo "release_title=Release ${RELEASE_VERSION}" >> $GITHUB_OUTPUT
|
|
changelog=$(git log -1 --pretty=%B)
|
|
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
|
|
echo "release_body<<$EOF" >> $GITHUB_ENV
|
|
echo "Release version ${RELEASE_VERSION}" >> $GITHUB_ENV
|
|
echo "Commit message: $changelog" >> $GITHUB_ENV
|
|
echo "$EOF" >> $GITHUB_ENV
|
|
|
|
- name: Create Release
|
|
id: create_release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
name: ${{ steps.release_info.outputs.release_title }}
|
|
tag: ${{ steps.release_info.outputs.release_version }}
|
|
body: ${{ env.release_body }}
|
|
draft: false
|
|
prerelease: true
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
build:
|
|
runs-on: ${{ matrix.config.os }}
|
|
name: ${{ matrix.config.name }}
|
|
needs: create_release
|
|
strategy:
|
|
matrix:
|
|
config:
|
|
- os: ubuntu-20.04
|
|
name: ubuntu build linux.AppImage
|
|
kernel_path: "../app/kernel-linux/SiYuan-Kernel"
|
|
build_args_prefix: "-s -w -X"
|
|
build_args_suffix: "Mode=prod"
|
|
electron_args: "dist-linux"
|
|
goos: "linux"
|
|
goarch: "amd64"
|
|
suffix: "linux.AppImage"
|
|
- os: ubuntu-20.04
|
|
name: ubuntu build linux.tar.gz
|
|
kernel_path: "../app/kernel-linux/SiYuan-Kernel"
|
|
build_args_prefix: "-s -w -X"
|
|
build_args_suffix: "Mode=prod"
|
|
electron_args: "dist-linux"
|
|
goos: "linux"
|
|
goarch: "amd64"
|
|
suffix: "linux.tar.gz"
|
|
- os: macos-latest
|
|
name: macos build mac.dmg
|
|
kernel_path: "../app/kernel-darwin/SiYuan-Kernel"
|
|
build_args_prefix: "-s -w -X"
|
|
build_args_suffix: "Mode=prod"
|
|
electron_args: "dist-darwin"
|
|
goos: "darwin"
|
|
goarch: "amd64"
|
|
suffix: "mac.dmg"
|
|
- os: macos-latest
|
|
name: macos build mac-arm64.dmg
|
|
kernel_path: "../app/kernel-darwin-arm64/SiYuan-Kernel"
|
|
build_args_prefix: "-s -w -X"
|
|
build_args_suffix: "Mode=prod"
|
|
electron_args: "dist-darwin-arm64"
|
|
goos: "darwin"
|
|
goarch: "arm64"
|
|
suffix: "mac-arm64.dmg"
|
|
- os: windows-latest
|
|
name: windows build win.exe
|
|
kernel_path: "../app/kernel/SiYuan-Kernel.exe"
|
|
build_args_prefix: "-s -w -H=windowsgui -X"
|
|
build_args_suffix: "Mode=prod"
|
|
electron_args: "dist"
|
|
goos: "windows"
|
|
gobin: "bin"
|
|
mingwsys: "MINGW64"
|
|
goarch: "amd64"
|
|
suffix: "win.exe"
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}
|
|
|
|
- name: Set up MingGW
|
|
uses: msys2/setup-msys2@v2
|
|
if: "contains( matrix.config.goos, 'windows')"
|
|
with:
|
|
install: p7zip mingw-w64-x86_64-lua
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.23' # Specify the Go version you need
|
|
check-latest: true
|
|
- run: go version
|
|
|
|
- name: Set up goversioninfo
|
|
run: go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo && go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo
|
|
if: "contains( matrix.config.goos, 'windows')"
|
|
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/kernel
|
|
env:
|
|
GO111MODULE: on
|
|
CGO_ENABLED: 1
|
|
GOOS: ${{ matrix.config.goos }}
|
|
GOPATH: ${{ github.workspace }}/go
|
|
GOARCH: ${{ matrix.config.goarch }}
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Install Node npm
|
|
run: npm install -g ${{ needs.create_release.outputs.packageManager }}
|
|
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
|
|
|
|
- name: Install Node Dependencies
|
|
run: npm install --no-frozen-lockfile
|
|
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
|
|
|
|
- name: Building UI
|
|
run: npm run build
|
|
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
|
|
|
|
- name: Remove Build Directory
|
|
uses: JesseTG/rm@v1.0.2
|
|
with:
|
|
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/build
|
|
|
|
- name: Remove Kernel Directory for Linux
|
|
uses: JesseTG/rm@v1.0.2
|
|
with:
|
|
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel-linux
|
|
|
|
- name: Remove Kernel Directory for Windows
|
|
uses: JesseTG/rm@v1.0.2
|
|
with:
|
|
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel
|
|
|
|
- name: Remove Kernel Directory for macOS
|
|
uses: JesseTG/rm@v1.0.2
|
|
with:
|
|
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel-darwin
|
|
|
|
- name: Remove Kernel Directory for macOS ARM64
|
|
uses: JesseTG/rm@v1.0.2
|
|
with:
|
|
path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/kernel-darwin-arm64
|
|
|
|
- name: Generate Icon Resource and Properties/Version Info For Windows
|
|
run: ${{ github.workspace }}\go\${{ matrix.config.gobin }}\goversioninfo -platform-specific=true -icon="resource\icon.ico" -manifest="resource\goversioninfo.exe.manifest"
|
|
if: "contains( matrix.config.goos, 'windows')"
|
|
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/kernel
|
|
|
|
- name: Building Kernel
|
|
run: go build --tags fts5 -o "${{ matrix.config.kernel_path }}" -v -ldflags "${{ matrix.config.build_args_prefix }} github.com/${{ env.repo_owner }}/${{ env.repo_name }}/kernel/util.${{ matrix.config.build_args_suffix }}"
|
|
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/kernel
|
|
env:
|
|
GO111MODULE: on
|
|
CGO_ENABLED: 1
|
|
GOOS: ${{ matrix.config.goos }}
|
|
GOPATH: ${{ github.workspace }}/go
|
|
GOARCH: ${{ matrix.config.goarch }}
|
|
|
|
- name: Building Electron App
|
|
run: npm run ${{ matrix.config.electron_args }}
|
|
working-directory: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app
|
|
|
|
- name: Upload Release
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
|
asset_name: siyuan-v${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}
|
|
asset_path: ${{ github.workspace }}/go/src/github.com/${{ env.repo_owner }}/${{ env.repo_name }}/app/build/siyuan-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}
|
|
asset_content_type: application/octet-stream
|