Skip to content

Merge pull request #30 from terwer/dev #18

Merge pull request #30 from terwer/dev

Merge pull request #30 from terwer/dev #18

Workflow file for this run

name: CI/CD For my-note
on:
push:
branches:
- main
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 }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
- run: pip install PyGithub
- name: Gather Release Information
id: release_info
run: |
echo "::set-output name=release_title::$(git show --format=%s --no-patch | head -1)"
echo "::set-output name=release_version::$(TZ=Asia/Shanghai date +'v%Y%m%d%H%M')"
changelog=$(python scripts/parse-changelog.py -t ${{ github.ref }} siyuan-note/siyuan)
changelog="${changelog//'%'/'%25'}"
changelog="${changelog//$'\n'/'%0A'}"
changelog="${changelog//$'\r'/'%0D'}"
echo "::set-output name=release_body::$changelog"
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
- name: Extract version from package.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: 'jq .version app/package.json -r'
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
with:
release_name: ${{ steps.release_info.outputs.release_version }}
tag_name: ${{ github.ref }}
body: ${{ steps.release_info.outputs.release_body }}
draft: false
prerelease: true
build:
runs-on: ${{ matrix.config.os }}
needs: create_release
strategy:
matrix:
config:
- os: ubuntu-20.04
kernel_path: "../app/kernel-linux/SiYuan-Kernel"
build_args: "-s -w -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
electron_args: "dist-linux"
goos: "linux"
goarch: "amd64"
suffix: "linux.AppImage"
- os: ubuntu-20.04
kernel_path: "../app/kernel-linux/SiYuan-Kernel"
build_args: "-s -w -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
electron_args: "dist-linux"
goos: "linux"
goarch: "amd64"
suffix: "linux.tar.gz"
- os: macos-latest
kernel_path: "../app/kernel-darwin/SiYuan-Kernel"
build_args: "-s -w -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
electron_args: "dist-darwin"
goos: "darwin"
goarch: "amd64"
suffix: "mac.dmg"
- os: macos-latest
kernel_path: "../app/kernel-darwin-arm64/SiYuan-Kernel"
build_args: "-s -w -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
electron_args: "dist-darwin-arm64"
goos: "darwin"
goarch: "arm64"
suffix: "mac-arm64.dmg"
- os: windows-2019
kernel_path: "../app/kernel/SiYuan-Kernel.exe"
build_args: "-s -w -H=windowsgui -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
electron_args: "dist"
goos: "windows"
gobin: "bin"
mingwsys: "MINGW64"
goarch: "amd64"
suffix: "win.exe"
steps:
- uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan
- 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 TDM-GCC
run: msys2 -c "bash go/src/github.com/siyuan-note/siyuan/scripts/get-tdm-gcc.sh tdm https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm-1/tdm-gcc-10.3.0.exe" && echo "CC=${{ github.workspace }}/tdm/bin/gcc.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if: "contains( matrix.config.goarch, '386')"
working-directory: ${{ github.workspace }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
- 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/siyuan-note/siyuan/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@v3
with:
node-version: 18
- name: Install Node pnpm
run: npm install -g pnpm && pnpm config set registry https://registry.npmmirror.com/ && pnpm config set electron_mirror=https://cdn.npmmirror.com/binaries/electron/ && pnpm config set electron_custom_dir=28.1.3
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
- name: Install Node Dependencies
run: pnpm install
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
- name: Building UI
run: pnpm run build
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
- name: Remove Build Directory
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app/build
- name: Remove Kernel Directory for Linux
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app/kernel-linux
- name: Remove Kernel Directory for Windows
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app/kernel
- name: Remove Kernel Directory for macOS
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app/kernel-darwin
- name: Remove Kernel Directory for macOS ARM64
uses: JesseTG/rm@v1.0.2
with:
path: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/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/siyuan-note/siyuan/kernel
- name: Building Kernel
run: go build --tags fts5 -o "${{ matrix.config.kernel_path }}" -v -ldflags "${{ matrix.config.build_args }}"
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/kernel
env:
GO111MODULE: on
CGO_ENABLED: 1
GOOS: ${{ matrix.config.goos }}
GOPATH: ${{ github.workspace }}/go
GOARCH: ${{ matrix.config.goarch }}
- name: Building Electron
run: pnpm run ${{ matrix.config.electron_args }}
working-directory: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app
- name: Upload Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: my-note-${{ needs.create_release.outputs.release_version }}-${{ matrix.config.suffix }}
asset_path: ${{ github.workspace }}/go/src/github.com/siyuan-note/siyuan/app/build/siyuan-${{ needs.create_release.outputs.version }}-${{ matrix.config.suffix }}
asset_content_type: application/octet-stream