mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-12-23 08:47:50 +00:00
* docs: update documents * fix: correct order of building binaries * build: bump version to 0.11.2 * docs: redirect changelog * docs: update document tips * docs: update insert template in place tips * build: bump typstyle version to 0.11.7
282 lines
11 KiB
YAML
282 lines
11 KiB
YAML
# stolen from https://github.com/nvarner/tinymist/blob/master/.github/workflows/release.yml
|
|
name: CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "*"
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
|
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
|
|
|
|
jobs:
|
|
pre_build:
|
|
permissions:
|
|
actions: write
|
|
contents: read
|
|
name: Duplicate Actions Detection
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
steps:
|
|
- id: skip_check
|
|
uses: fkirc/skip-duplicate-actions@v5
|
|
with:
|
|
cancel_others: "true"
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: windows-latest
|
|
rust-target: x86_64-pc-windows-msvc
|
|
platform: win32
|
|
arch: x64
|
|
regular_build: 'true'
|
|
- os: windows-latest
|
|
rust-target: aarch64-pc-windows-msvc
|
|
platform: win32
|
|
arch: arm64
|
|
- os: ubuntu-20.04
|
|
rust-target: x86_64-unknown-linux-gnu
|
|
platform: linux
|
|
arch: x64
|
|
regular_build: 'true'
|
|
- os: ubuntu-20.04
|
|
rust-target: aarch64-unknown-linux-gnu
|
|
platform: linux
|
|
arch: arm64
|
|
- os: ubuntu-20.04
|
|
rust-target: arm-unknown-linux-gnueabihf
|
|
platform: linux
|
|
arch: armhf
|
|
- os: macos-11
|
|
rust-target: x86_64-apple-darwin
|
|
platform: darwin
|
|
arch: x64
|
|
- os: macos-11
|
|
rust-target: aarch64-apple-darwin
|
|
platform: darwin
|
|
arch: arm64
|
|
regular_build: 'true'
|
|
name: build (${{ matrix.platform }}-${{ matrix.arch }})
|
|
runs-on: ${{ matrix.os }}
|
|
env:
|
|
target: ${{ matrix.platform }}-${{ matrix.arch }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 16
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
- name: Install deps
|
|
run: yarn install
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
- name: Build vscode extension
|
|
run: |
|
|
yarn
|
|
yarn run compile
|
|
working-directory: ./editors/vscode
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
- name: rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.rust-target }}
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
- name: Install llvm
|
|
if: matrix.platform == 'linux' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install llvm
|
|
- name: Install AArch64 target toolchain
|
|
if: matrix.rust-target == 'aarch64-unknown-linux-gnu' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install gcc-aarch64-linux-gnu
|
|
- name: Install ARM target toolchain
|
|
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install gcc-arm-linux-gnueabihf
|
|
- name: Run rust-cache
|
|
uses: Swatinem/rust-cache@v2
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
- name: Build tinymist binary
|
|
shell: pwsh
|
|
run: |
|
|
cargo build --release -p tinymist --target ${{ matrix.rust-target }}
|
|
if: startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true'
|
|
- name: Rename debug symbols for windows
|
|
if: matrix.platform == 'win32' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
run: |
|
|
cd target/${{ matrix.rust-target }}/release
|
|
cp tinymist.pdb tinymist-${{ env.target }}.pdb
|
|
- name: Split debug symbols for linux
|
|
if: matrix.platform == 'linux' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
run: |
|
|
cd target/${{ matrix.rust-target }}/release
|
|
llvm-objcopy --compress-debug-sections --only-keep-debug "tinymist" "tinymist-${{ env.target }}.debug"
|
|
llvm-objcopy --strip-debug --add-gnu-debuglink="tinymist-${{ env.target }}.debug" "tinymist"
|
|
- name: Collect debug symbols for mac
|
|
if: matrix.platform == 'darwin' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
run: |
|
|
dsymutil -f "target/${{ matrix.rust-target }}/release/tinymist"
|
|
mv "target/${{ matrix.rust-target }}/release/tinymist.dwarf" "target/${{ matrix.rust-target }}/release/tinymist-${{ env.target }}.dwarf"
|
|
- name: Copy binary to output directory
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
shell: pwsh
|
|
run: |
|
|
cp "target/${{ matrix.rust-target }}/release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "editors/vscode/out/"
|
|
cp "target/${{ matrix.rust-target }}/release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "tinymist-${{ env.target }}$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )"
|
|
- name: Test tinymist
|
|
run: |
|
|
cargo test --release --workspace --target ${{ matrix.rust-target }}
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true') && (matrix.platform == 'linux') && (matrix.arch == 'x64')
|
|
- name: Upload split debug symbols for windows
|
|
if: matrix.platform == 'win32' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}.pdb
|
|
path: target/${{ matrix.rust-target }}/release/tinymist-${{ env.target }}.pdb
|
|
- name: Upload split debug symbols for linux
|
|
if: matrix.platform == 'linux' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}.debug
|
|
path: target/${{ matrix.rust-target }}/release/tinymist-${{ env.target }}.debug
|
|
compression-level: 0
|
|
- name: Upload split debug symbols for mac
|
|
if: matrix.platform == 'darwin' && (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}.dwarf
|
|
path: target/${{ matrix.rust-target }}/release/tinymist-${{ env.target }}.dwarf
|
|
- name: Upload binary artifact
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}
|
|
path: tinymist-${{ env.target }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
|
|
- name: Package extension
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
shell: pwsh
|
|
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
|
|
working-directory: ./editors/vscode
|
|
- name: Upload VSIX artifact
|
|
if: (startsWith(github.ref, 'refs/tags/') || matrix.regular_build == 'true')
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}.vsix
|
|
path: editors/vscode/tinymist-${{ env.target }}.vsix
|
|
|
|
build_alpine:
|
|
name: build (x86_64-unknown-linux-musl)
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
container:
|
|
image: rust:alpine
|
|
volumes:
|
|
- /usr/local/cargo/registry:/usr/local/cargo/registry
|
|
env:
|
|
target: alpine-x64
|
|
RUST_TARGET: x86_64-unknown-linux-musl
|
|
RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
|
|
steps:
|
|
- name: Install dependencies
|
|
run: apk add --no-cache git clang lld musl-dev nodejs npm yarn binutils
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
- name: Run rust-cache
|
|
uses: Swatinem/rust-cache@v2
|
|
- name: Install deps
|
|
run: yarn install
|
|
- name: Build vscode extension
|
|
run: |
|
|
yarn
|
|
yarn run compile
|
|
working-directory: ./editors/vscode
|
|
- name: Build tinymist binary
|
|
run: |
|
|
cargo build --release -p tinymist --target $RUST_TARGET
|
|
- name: Split debug symbols
|
|
run: |
|
|
cd target/$RUST_TARGET/release
|
|
objcopy --compress-debug-sections --only-keep-debug "tinymist" "tinymist-${{ env.target }}.debug"
|
|
objcopy --strip-debug --add-gnu-debuglink="tinymist-${{ env.target }}.debug" "tinymist"
|
|
- name: Upload split debug symbols
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}.debug
|
|
path: target/${{ env.RUST_TARGET }}/release/tinymist-${{ env.target }}.debug
|
|
- name: Copy binary to output directory
|
|
run: |
|
|
mkdir -p editors/vscode/out
|
|
cp "target/${{ env.RUST_TARGET }}/release/tinymist" "editors/vscode/out/"
|
|
cp "target/${{ env.RUST_TARGET }}/release/tinymist" "tinymist-${{ env.target }}"
|
|
- name: Upload binary artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}
|
|
path: tinymist-${{ env.target }}
|
|
- name: Package extension
|
|
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
|
|
working-directory: ./editors/vscode
|
|
- name: Upload VSIX artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tinymist-${{ env.target }}.vsix
|
|
path: editors/vscode/tinymist-${{ env.target }}.vsix
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs: [build, build_alpine]
|
|
if: success() && startsWith(github.ref, 'refs/tags/')
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
- name: Display structure of downloaded files
|
|
run: ls -R artifacts
|
|
- uses: ncipollo/release-action@v1
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
artifacts: "artifacts/*/*"
|
|
allowUpdates: true
|
|
omitBodyDuringUpdate: true
|
|
omitDraftDuringUpdate: true
|
|
omitNameDuringUpdate: true
|
|
omitPrereleaseDuringUpdate: true
|
|
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
if: success() && startsWith(github.ref, 'refs/tags/')
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
|
|
- name: Deploy to VS Code Marketplace
|
|
run: npx vsce publish --packagePath $(find . -type f -iname '*.vsix')
|
|
env:
|
|
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
|
|
|
|
- name: Deploy to OpenVSX
|
|
run: npx ovsx publish --packagePath $(find . -type f -iname '*.vsix')
|
|
env:
|
|
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}
|