mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 18:28:02 +00:00
ci: generate binaries using cargo-dist
(#1009)
* ci: generate binaries using `cargo-dist` * chore: clean script * fix: checking * dev: update dist workspace * dev: fix script * docs: move announcement
This commit is contained in:
parent
df03b36880
commit
83fe1e7987
8 changed files with 820 additions and 393 deletions
425
.github/workflows/release-vscode.yml
vendored
Normal file
425
.github/workflows/release-vscode.yml
vendored
Normal file
|
@ -0,0 +1,425 @@
|
|||
# stolen from https://github.com/nvarner/tinymist/blob/master/.github/workflows/release.yml
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'nightly/*'
|
||||
tags:
|
||||
- "*"
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
branches:
|
||||
- main
|
||||
- 'nightly/*'
|
||||
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"
|
||||
|
||||
checks:
|
||||
name: Check clippy, formatting, and documentation
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install deps
|
||||
run: yarn install
|
||||
- name: Check and build typst-preview
|
||||
run: |
|
||||
yarn build:preview
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo clippy --workspace --all-targets --all-features
|
||||
- run: cargo fmt --check --all
|
||||
- run: cargo doc --workspace --no-deps
|
||||
|
||||
# region: check-min-version
|
||||
min-version:
|
||||
name: Check minimum Rust version
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Check MSRV
|
||||
run: yarn check-msrv
|
||||
- uses: dtolnay/rust-toolchain@1.82.0
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo check --workspace
|
||||
# end-region: check-min-version
|
||||
|
||||
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-13
|
||||
rust-target: x86_64-apple-darwin
|
||||
platform: darwin
|
||||
arch: x64
|
||||
- os: macos-13
|
||||
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 }}
|
||||
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
|
||||
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
|
||||
isTest: ${{ matrix.rust-target == 'x86_64-unknown-linux-gnu' || matrix.rust-target == 'x86_64-pc-windows-msvc' }}
|
||||
steps:
|
||||
- name: "Print Env"
|
||||
run: |
|
||||
echo "Running on ${{ matrix.os }}"
|
||||
echo "Target: ${{ env.target }}"
|
||||
echo "Is Release: ${{ fromJson(env.isRelease) }}"
|
||||
echo "Is Nightly: ${{ fromJson(env.isNightly) }}"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Install deps
|
||||
run: yarn install
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Build typst-preview vscode extension
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Build tinymist vscode extension
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./editors/vscode
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.rust-target }}
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Install llvm
|
||||
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install llvm
|
||||
- name: Install AArch64 target toolchain
|
||||
if: matrix.rust-target == 'aarch64-unknown-linux-gnu' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
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' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-arm-linux-gnueabihf
|
||||
- name: Run rust-cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Build tinymist binary
|
||||
shell: pwsh
|
||||
run: |
|
||||
cargo build --profile=gh-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' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
cd target/${{ matrix.rust-target }}/gh-release
|
||||
cp tinymist.pdb tinymist-${{ env.target }}.pdb
|
||||
- name: Split debug symbols for linux
|
||||
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
cd target/${{ matrix.rust-target }}/gh-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' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
dsymutil -f "target/${{ matrix.rust-target }}/gh-release/tinymist"
|
||||
mv "target/${{ matrix.rust-target }}/gh-release/tinymist.dwarf" "target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf"
|
||||
- name: Copy binary to output directory
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
shell: pwsh
|
||||
run: |
|
||||
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "editors/vscode/out/"
|
||||
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "contrib/typst-preview/editors/vscode/out/"
|
||||
cp "target/${{ matrix.rust-target }}/gh-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 --profile=gh-release --workspace --target ${{ matrix.rust-target }}
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly)) && fromJson(env.isTest)
|
||||
- name: Upload split debug symbols for windows
|
||||
if: matrix.platform == 'win32' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.pdb
|
||||
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.pdb
|
||||
- name: Upload split debug symbols for linux
|
||||
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.debug
|
||||
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.debug
|
||||
compression-level: 0
|
||||
- name: Upload split debug symbols for mac
|
||||
if: matrix.platform == 'darwin' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.dwarf
|
||||
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf
|
||||
- name: Upload binary artifact
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}
|
||||
path: tinymist-${{ env.target }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
|
||||
- name: Package typst-preview extension
|
||||
if: fromJson(env.isRelease)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package tinymist extension
|
||||
if: fromJson(env.isRelease)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
|
||||
working-directory: ./editors/vscode
|
||||
- name: Package typst-preview extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package tinymist extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./editors/vscode
|
||||
- name: Test tinymist extension
|
||||
uses: coactions/setup-xvfb@v1
|
||||
with:
|
||||
run: yarn test
|
||||
working-directory: ./editors/vscode
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly)) && fromJson(env.isTest)
|
||||
- name: Upload typst-preview VSIX artifact
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: typst-preview-${{ env.target }}.vsix
|
||||
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
|
||||
- name: Upload VSIX artifact
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.vsix
|
||||
path: editors/vscode/tinymist-${{ env.target }}.vsix
|
||||
- name: Upload Tinymist E2E Test Snapshot
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-snapshot-${{ env.target }}
|
||||
path: target/e2e
|
||||
- name: Upload Tinymist Testing log
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-lsp-tests.${{ env.target }}.log
|
||||
path: editors/vscode/e2e-workspaces/simple-docs/tinymist-lsp.log
|
||||
|
||||
build_alpine:
|
||||
name: build (alpine-x64)
|
||||
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"
|
||||
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
|
||||
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
|
||||
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 typst-preview vscode extension
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Build tinymist vscode extension
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./editors/vscode
|
||||
- name: Build tinymist binary
|
||||
run: |
|
||||
cargo build --profile=gh-release -p tinymist --target $RUST_TARGET
|
||||
- name: Split debug symbols
|
||||
run: |
|
||||
cd target/$RUST_TARGET/gh-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 }}/gh-release/tinymist-${{ env.target }}.debug
|
||||
- name: Copy binary to output directory
|
||||
run: |
|
||||
mkdir -p editors/vscode/out
|
||||
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "editors/vscode/out/"
|
||||
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "contrib/typst-preview/editors/vscode/out/"
|
||||
cp "target/${{ env.RUST_TARGET }}/gh-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 typst-preview extension
|
||||
if: fromJson(env.isRelease)
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package extension
|
||||
if: fromJson(env.isRelease)
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
|
||||
working-directory: ./editors/vscode
|
||||
- name: Package typst-preview extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./editors/vscode
|
||||
|
||||
- name: Upload typst-preview VSIX artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: typst-preview-${{ env.target }}.vsix
|
||||
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
|
||||
- name: Upload tinymist 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]
|
||||
env:
|
||||
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
|
||||
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
|
||||
if: success() && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc')
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install deps
|
||||
run: yarn install
|
||||
- name: Deploy to VS Code Marketplace
|
||||
if: fromJson(env.isRelease)
|
||||
run: npx @vscode/vsce publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
|
||||
- name: Deploy to OpenVSX
|
||||
if: fromJson(env.isRelease)
|
||||
run: npx ovsx publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate
|
||||
env:
|
||||
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}
|
||||
- name: Deploy to VS Code Marketplace (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: npx @vscode/vsce publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate --pre-release
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
|
||||
- name: Deploy to OpenVSX (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: npx ovsx publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate --pre-release
|
||||
env:
|
||||
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}
|
649
.github/workflows/release.yml
vendored
649
.github/workflows/release.yml
vendored
|
@ -1,425 +1,292 @@
|
|||
# stolen from https://github.com/nvarner/tinymist/blob/master/.github/workflows/release.yml
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'nightly/*'
|
||||
tags:
|
||||
- "*"
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
branches:
|
||||
- main
|
||||
- 'nightly/*'
|
||||
workflow_dispatch:
|
||||
# This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/
|
||||
#
|
||||
# Copyright 2022-2024, axodotdev
|
||||
# SPDX-License-Identifier: MIT or Apache-2.0
|
||||
#
|
||||
# CI that:
|
||||
#
|
||||
# * checks for a Git Tag that looks like a release
|
||||
# * builds artifacts with dist (archives, installers, hashes)
|
||||
# * uploads those artifacts to temporary workflow zip
|
||||
# * on success, uploads the artifacts to a GitHub Release
|
||||
#
|
||||
# Note that a GitHub Release with this tag is assumed to exist as a draft
|
||||
# with the appropriate title/body, and will be undrafted for you.
|
||||
|
||||
env:
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
||||
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
|
||||
name: Release
|
||||
permissions:
|
||||
"contents": "write"
|
||||
|
||||
# This task will run whenever you workflow_dispatch with a tag that looks like a version
|
||||
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
|
||||
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
|
||||
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
|
||||
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
|
||||
#
|
||||
# If PACKAGE_NAME is specified, then the announcement will be for that
|
||||
# package (erroring out if it doesn't have the given version or isn't dist-able).
|
||||
#
|
||||
# If PACKAGE_NAME isn't specified, then the announcement will be for all
|
||||
# (dist-able) packages in the workspace with that version (this mode is
|
||||
# intended for workspaces with only one dist-able package, or with all dist-able
|
||||
# packages versioned/released in lockstep).
|
||||
#
|
||||
# If you push multiple tags at once, separate instances of this workflow will
|
||||
# spin up, creating an independent announcement for each one. However, GitHub
|
||||
# will hard limit this to 3 tags per commit, as it will assume more tags is a
|
||||
# mistake.
|
||||
#
|
||||
# If there's a prerelease-style suffix to the version, then the release(s)
|
||||
# will be marked as a prerelease.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: Release Tag
|
||||
required: true
|
||||
default: dry-run
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
pre_build:
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
name: Duplicate Actions Detection
|
||||
runs-on: ubuntu-latest
|
||||
# Run 'dist plan' (or host) to determine what tasks we need to do
|
||||
plan:
|
||||
runs-on: "ubuntu-20.04"
|
||||
outputs:
|
||||
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
||||
steps:
|
||||
- id: skip_check
|
||||
uses: fkirc/skip-duplicate-actions@v5
|
||||
with:
|
||||
cancel_others: "true"
|
||||
|
||||
checks:
|
||||
name: Check clippy, formatting, and documentation
|
||||
runs-on: ubuntu-latest
|
||||
val: ${{ steps.plan.outputs.manifest }}
|
||||
tag: ${{ (inputs.tag != 'dry-run' && inputs.tag) || '' }}
|
||||
tag-flag: ${{ inputs.tag && inputs.tag != 'dry-run' && format('--tag={0}', inputs.tag) || '' }}
|
||||
publishing: ${{ inputs.tag && inputs.tag != 'dry-run' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
submodules: recursive
|
||||
- name: Install dist
|
||||
# we specify bash to get pipefail; it guards against the `curl` command
|
||||
# failing. otherwise `sh` won't catch that `curl` returned non-0
|
||||
shell: bash
|
||||
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.26.1/cargo-dist-installer.sh | sh"
|
||||
- name: Cache dist
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install deps
|
||||
run: yarn install
|
||||
- name: Check and build typst-preview
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/dist
|
||||
# sure would be cool if github gave us proper conditionals...
|
||||
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
|
||||
# functionality based on whether this is a pull_request, and whether it's from a fork.
|
||||
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
|
||||
# but also really annoying to build CI around when it needs secrets to work right.)
|
||||
- id: plan
|
||||
run: |
|
||||
yarn build:preview
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo clippy --workspace --all-targets --all-features
|
||||
- run: cargo fmt --check --all
|
||||
- run: cargo doc --workspace --no-deps
|
||||
|
||||
# region: check-min-version
|
||||
min-version:
|
||||
name: Check minimum Rust version
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
dist ${{ (inputs.tag && inputs.tag != 'dry-run' && format('host --steps=create --tag={0}', inputs.tag)) || 'plan' }} --output-format=json > plan-dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
cat plan-dist-manifest.json
|
||||
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||
- name: "Upload dist-manifest.json"
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Check MSRV
|
||||
run: yarn check-msrv
|
||||
- uses: dtolnay/rust-toolchain@1.82.0
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo check --workspace
|
||||
# end-region: check-min-version
|
||||
name: artifacts-plan-dist-manifest
|
||||
path: plan-dist-manifest.json
|
||||
|
||||
build:
|
||||
# Build and packages all the platform-specific things
|
||||
build-local-artifacts:
|
||||
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
|
||||
# Let the initial task tell us to not run (currently very blunt)
|
||||
needs:
|
||||
- plan
|
||||
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') || inputs.tag == 'dry-run' }}
|
||||
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-13
|
||||
rust-target: x86_64-apple-darwin
|
||||
platform: darwin
|
||||
arch: x64
|
||||
- os: macos-13
|
||||
rust-target: aarch64-apple-darwin
|
||||
platform: darwin
|
||||
arch: arm64
|
||||
regular_build: 'true'
|
||||
name: build (${{ matrix.platform }}-${{ matrix.arch }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
fail-fast: false
|
||||
# Target platforms/runners are computed by dist in create-release.
|
||||
# Each member of the matrix has the following arguments:
|
||||
#
|
||||
# - runner: the github runner
|
||||
# - dist-args: cli flags to pass to dist
|
||||
# - install-dist: expression to run to install dist on the runner
|
||||
#
|
||||
# Typically there will be:
|
||||
# - 1 "global" task that builds universal installers
|
||||
# - N "local" tasks that build each platform's binaries and platform-specific installers
|
||||
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
container: ${{ matrix.container && matrix.container.image || null }}
|
||||
env:
|
||||
target: ${{ matrix.platform }}-${{ matrix.arch }}
|
||||
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
|
||||
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
|
||||
isTest: ${{ matrix.rust-target == 'x86_64-unknown-linux-gnu' || matrix.rust-target == 'x86_64-pc-windows-msvc' }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
|
||||
steps:
|
||||
- name: "Print Env"
|
||||
- name: enable windows longpaths
|
||||
run: |
|
||||
echo "Running on ${{ matrix.os }}"
|
||||
echo "Target: ${{ env.target }}"
|
||||
echo "Is Release: ${{ fromJson(env.isRelease) }}"
|
||||
echo "Is Nightly: ${{ fromJson(env.isNightly) }}"
|
||||
git config --global core.longpaths true
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Install deps
|
||||
run: yarn install
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Build typst-preview vscode extension
|
||||
- name: Install Rust non-interactively if not already installed
|
||||
if: ${{ matrix.container }}
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Build tinymist vscode extension
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./editors/vscode
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
if ! command -v cargo > /dev/null 2>&1; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
fi
|
||||
- name: Install dist
|
||||
run: ${{ matrix.install_dist.run }}
|
||||
# Get the dist-manifest
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
targets: ${{ matrix.rust-target }}
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Install llvm
|
||||
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install llvm
|
||||
- name: Install AArch64 target toolchain
|
||||
if: matrix.rust-target == 'aarch64-unknown-linux-gnu' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
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' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-arm-linux-gnueabihf
|
||||
- name: Run rust-cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
- name: Build tinymist binary
|
||||
shell: pwsh
|
||||
run: |
|
||||
cargo build --profile=gh-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' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
cd target/${{ matrix.rust-target }}/gh-release
|
||||
cp tinymist.pdb tinymist-${{ env.target }}.pdb
|
||||
- name: Split debug symbols for linux
|
||||
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
cd target/${{ matrix.rust-target }}/gh-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' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
run: |
|
||||
dsymutil -f "target/${{ matrix.rust-target }}/gh-release/tinymist"
|
||||
mv "target/${{ matrix.rust-target }}/gh-release/tinymist.dwarf" "target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf"
|
||||
- name: Copy binary to output directory
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
shell: pwsh
|
||||
run: |
|
||||
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "editors/vscode/out/"
|
||||
cp "target/${{ matrix.rust-target }}/gh-release/tinymist$(If ('${{ matrix.platform }}' -eq 'win32') { '.exe' } else { '' } )" "contrib/typst-preview/editors/vscode/out/"
|
||||
cp "target/${{ matrix.rust-target }}/gh-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 --profile=gh-release --workspace --target ${{ matrix.rust-target }}
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly)) && fromJson(env.isTest)
|
||||
- name: Upload split debug symbols for windows
|
||||
if: matrix.platform == 'win32' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.pdb
|
||||
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.pdb
|
||||
- name: Upload split debug symbols for linux
|
||||
if: matrix.platform == 'linux' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.debug
|
||||
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.debug
|
||||
compression-level: 0
|
||||
- name: Upload split debug symbols for mac
|
||||
if: matrix.platform == 'darwin' && (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.dwarf
|
||||
path: target/${{ matrix.rust-target }}/gh-release/tinymist-${{ env.target }}.dwarf
|
||||
- name: Upload binary artifact
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}
|
||||
path: tinymist-${{ env.target }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
|
||||
- name: Package typst-preview extension
|
||||
if: fromJson(env.isRelease)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package tinymist extension
|
||||
if: fromJson(env.isRelease)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
|
||||
working-directory: ./editors/vscode
|
||||
- name: Package typst-preview extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package tinymist extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
shell: pwsh
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./editors/vscode
|
||||
- name: Test tinymist extension
|
||||
uses: coactions/setup-xvfb@v1
|
||||
with:
|
||||
run: yarn test
|
||||
working-directory: ./editors/vscode
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly)) && fromJson(env.isTest)
|
||||
- name: Upload typst-preview VSIX artifact
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: typst-preview-${{ env.target }}.vsix
|
||||
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
|
||||
- name: Upload VSIX artifact
|
||||
if: (fromJson(env.isRelease) || fromJson(env.isNightly))
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.vsix
|
||||
path: editors/vscode/tinymist-${{ env.target }}.vsix
|
||||
- name: Upload Tinymist E2E Test Snapshot
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-snapshot-${{ env.target }}
|
||||
path: target/e2e
|
||||
- name: Upload Tinymist Testing log
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-lsp-tests.${{ env.target }}.log
|
||||
path: editors/vscode/e2e-workspaces/simple-docs/tinymist-lsp.log
|
||||
|
||||
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"
|
||||
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
|
||||
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
|
||||
steps:
|
||||
pattern: artifacts-*
|
||||
path: target/distrib/
|
||||
merge-multiple: true
|
||||
- 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 typst-preview vscode extension
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Build tinymist vscode extension
|
||||
${{ matrix.packages_install }}
|
||||
- name: Build artifacts
|
||||
run: |
|
||||
yarn
|
||||
yarn run compile
|
||||
working-directory: ./editors/vscode
|
||||
- name: Build tinymist binary
|
||||
# Actually do builds and make zips and whatnot
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
- id: cargo-dist
|
||||
name: Post-build
|
||||
# We force bash here just because github makes it really hard to get values up
|
||||
# to "real" actions without writing to env-vars, and writing to env-vars has
|
||||
# inconsistent syntax between shell and powershell.
|
||||
shell: bash
|
||||
run: |
|
||||
cargo build --profile=gh-release -p tinymist --target $RUST_TARGET
|
||||
- name: Split debug symbols
|
||||
run: |
|
||||
cd target/$RUST_TARGET/gh-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 }}/gh-release/tinymist-${{ env.target }}.debug
|
||||
- name: Copy binary to output directory
|
||||
run: |
|
||||
mkdir -p editors/vscode/out
|
||||
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "editors/vscode/out/"
|
||||
cp "target/${{ env.RUST_TARGET }}/gh-release/tinymist" "contrib/typst-preview/editors/vscode/out/"
|
||||
cp "target/${{ env.RUST_TARGET }}/gh-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 typst-preview extension
|
||||
if: fromJson(env.isRelease)
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package extension
|
||||
if: fromJson(env.isRelease)
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix
|
||||
working-directory: ./editors/vscode
|
||||
- name: Package typst-preview extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: yarn run package -- --target ${{ env.target }} -o typst-preview-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./contrib/typst-preview/editors/vscode
|
||||
- name: Package extension (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: yarn run package -- --target ${{ env.target }} -o tinymist-${{ env.target }}.vsix --pre-release
|
||||
working-directory: ./editors/vscode
|
||||
|
||||
- name: Upload typst-preview VSIX artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: typst-preview-${{ env.target }}.vsix
|
||||
path: contrib/typst-preview/editors/vscode/typst-preview-${{ env.target }}.vsix
|
||||
- name: Upload tinymist VSIX artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tinymist-${{ env.target }}.vsix
|
||||
path: editors/vscode/tinymist-${{ env.target }}.vsix
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, build_alpine]
|
||||
if: success() && startsWith(github.ref, 'refs/tags/')
|
||||
permissions:
|
||||
contents: write
|
||||
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||
- name: "Upload artifacts"
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
|
||||
path: |
|
||||
${{ steps.cargo-dist.outputs.paths }}
|
||||
${{ env.BUILD_MANIFEST_NAME }}
|
||||
|
||||
# Build and package all the platform-agnostic(ish) things
|
||||
build-global-artifacts:
|
||||
needs:
|
||||
- plan
|
||||
- build-local-artifacts
|
||||
runs-on: "ubuntu-20.04"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions/download-artifact@v4
|
||||
- name: Install cached dist
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
- name: Display structure of downloaded files
|
||||
run: ls -R artifacts
|
||||
- uses: ncipollo/release-action@v1
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
artifacts: "artifacts/*/*"
|
||||
allowUpdates: true
|
||||
omitBodyDuringUpdate: true
|
||||
omitDraftDuringUpdate: true
|
||||
omitNameDuringUpdate: true
|
||||
omitPrereleaseDuringUpdate: true
|
||||
pattern: artifacts-*
|
||||
path: target/distrib/
|
||||
merge-multiple: true
|
||||
- id: cargo-dist
|
||||
shell: bash
|
||||
run: |
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
env:
|
||||
isRelease: ${{ (startsWith(github.ref, 'refs/tags/') && (!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8')))) }}
|
||||
isNightly: ${{ ((startsWith(github.ref, 'refs/tags/') && !((!contains(github.ref, 'rc') && (endsWith(github.ref, '0') || endsWith(github.ref, '2') || endsWith(github.ref, '4') || endsWith(github.ref, '6') || endsWith(github.ref, '8'))))) || (!startsWith(github.ref, 'refs/tags/') && matrix.regular_build == 'true')) }}
|
||||
if: success() && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc')
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||
- name: "Upload artifacts"
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
node-version: 22
|
||||
- name: Install deps
|
||||
run: yarn install
|
||||
- name: Deploy to VS Code Marketplace
|
||||
if: fromJson(env.isRelease)
|
||||
run: npx @vscode/vsce publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate
|
||||
name: artifacts-build-global
|
||||
path: |
|
||||
${{ steps.cargo-dist.outputs.paths }}
|
||||
${{ env.BUILD_MANIFEST_NAME }}
|
||||
# Determines if we should publish/announce
|
||||
host:
|
||||
needs:
|
||||
- plan
|
||||
- build-local-artifacts
|
||||
- build-global-artifacts
|
||||
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
|
||||
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
runs-on: "ubuntu-20.04"
|
||||
outputs:
|
||||
val: ${{ steps.host.outputs.manifest }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install cached dist
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Fetch artifacts from scratch-storage
|
||||
- name: Fetch artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: artifacts-*
|
||||
path: target/distrib/
|
||||
merge-multiple: true
|
||||
- id: host
|
||||
shell: bash
|
||||
run: |
|
||||
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
|
||||
echo "artifacts uploaded and released successfully"
|
||||
cat dist-manifest.json
|
||||
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||
- name: "Upload dist-manifest.json"
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
# Overwrite the previous copy
|
||||
name: artifacts-dist-manifest
|
||||
path: dist-manifest.json
|
||||
# Create a GitHub Release while uploading all files to it
|
||||
- name: "Download GitHub Artifacts"
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: artifacts-*
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
- name: Cleanup
|
||||
run: |
|
||||
# Remove the granular manifests
|
||||
rm -f artifacts/*-dist-manifest.json
|
||||
- name: Create GitHub Release
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
|
||||
- name: Deploy to OpenVSX
|
||||
if: fromJson(env.isRelease)
|
||||
run: npx ovsx publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate
|
||||
env:
|
||||
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}
|
||||
- name: Deploy to VS Code Marketplace (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: npx @vscode/vsce publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate --pre-release
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
|
||||
- name: Deploy to OpenVSX (Nightly)
|
||||
if: fromJson(env.isNightly)
|
||||
run: npx ovsx publish --packagePath $(find . -type f -iname 'tinymist-*.vsix') --skip-duplicate --pre-release
|
||||
env:
|
||||
OVSX_PAT: ${{ secrets.OPENVSX_ACCESS_TOKEN }}
|
||||
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
|
||||
RELEASE_COMMIT: "${{ github.sha }}"
|
||||
run: |
|
||||
# If we're editing a release in place, we need to upload things ahead of time
|
||||
gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
|
||||
|
||||
gh release edit "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --draft=false
|
||||
|
||||
announce:
|
||||
needs:
|
||||
- plan
|
||||
- host
|
||||
# use "always() && ..." to allow us to wait for all publish jobs while
|
||||
# still allowing individual publish jobs to skip themselves (for prereleases).
|
||||
# "host" however must run to completion, no skipping allowed!
|
||||
if: ${{ always() && needs.host.result == 'success' }}
|
||||
runs-on: "ubuntu-20.04"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
|
|
@ -168,6 +168,11 @@ panic = "abort" # Abort on panic
|
|||
inherits = "release"
|
||||
debug = true
|
||||
|
||||
# The profile that 'dist' will build with
|
||||
[profile.dist]
|
||||
inherits = "release"
|
||||
lto = "thin"
|
||||
|
||||
[workspace.lints.rust]
|
||||
missing_docs = "warn"
|
||||
|
||||
|
|
51
dist-workspace.toml
Normal file
51
dist-workspace.toml
Normal file
|
@ -0,0 +1,51 @@
|
|||
[workspace]
|
||||
members = ["cargo:."]
|
||||
|
||||
# Config for 'dist'
|
||||
[dist]
|
||||
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
|
||||
cargo-dist-version = "0.26.1"
|
||||
# CI backends to support
|
||||
ci = "github"
|
||||
# The installers to generate for each app
|
||||
installers = ["shell", "powershell"]
|
||||
# The archive format to use for windows builds (defaults .zip)
|
||||
windows-archive = ".zip"
|
||||
# The archive format to use for non-windows builds (defaults .tar.xz)
|
||||
unix-archive = ".tar.gz"
|
||||
# Target platforms to build apps for (Rust target-triple syntax)
|
||||
# These targets are determined based on the awesome ruff project...
|
||||
targets = [
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-pc-windows-msvc",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"arm-unknown-linux-musleabihf",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"armv7-unknown-linux-musleabihf",
|
||||
# "i686-pc-windows-msvc",
|
||||
# "i686-unknown-linux-gnu",
|
||||
# "i686-unknown-linux-musl",
|
||||
# "powerpc64-unknown-linux-gnu",
|
||||
# "powerpc64le-unknown-linux-gnu",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"riscv64gc-unknown-linux-gnu",
|
||||
"riscv64gc-unknown-linux-musl",
|
||||
"loongarch64-unknown-linux-gnu",
|
||||
"loongarch64-unknown-linux-musl",
|
||||
]
|
||||
# Whether to auto-include files like READMEs, LICENSEs, and CHANGELOGs (default true)
|
||||
auto-includes = false
|
||||
# Whether dist should create a Github Release or use an existing draft
|
||||
create-release = false
|
||||
# Which actions to run on pull requests
|
||||
pr-run-mode = "skip"
|
||||
# Whether CI should trigger releases with dispatches instead of tag pushes
|
||||
dispatch-releases = true
|
||||
# Whether to install an updater program
|
||||
install-updater = false
|
||||
# Path that installers should place binaries in
|
||||
install-path = ["$XDG_BIN_HOME/", "$XDG_DATA_HOME/../bin", "~/.local/bin"]
|
|
@ -4,6 +4,10 @@ All notable changes to the "tinymist" extension will be documented in this file.
|
|||
|
||||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
||||
|
||||
## Unreleased
|
||||
|
||||
*We now use [cargo-dist](https://github.com/axodotdev/cargo-dist) to build and release binaries. The registries should prefer to using these binaries over that for VS Code (or VSCodium) extensions.* These following suffixes are used for VS Code (or VSCodium) extensions: `win32-x64`, `win32-arm64`, `linux-x64`, `linux-arm64`, `linux-armhf`, `darwin-x64`, `darwin-arm64`, `alpine-x64`, `alpine-arm64`, and `web`. If you have any problems with changes, please report them to [GitHub Issues](https://github.com/Myriad-Dreamin/tinymist/issues).
|
||||
|
||||
## v0.12.12 - [2024-12-15]
|
||||
|
||||
* Bumped typstyle from v0.12.6 to v0.12.12 by @Enter-tainer in https://github.com/Myriad-Dreamin/tinymist/pull/987 and https://github.com/Myriad-Dreamin/tinymist/pull/1010
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
"test:grammar": "cd syntaxes/textmate && yarn run test",
|
||||
"build:typlite": "cargo build --bin typlite",
|
||||
"typlite": "target/debug/typlite",
|
||||
"check-msrv": "node scripts/check-msrv.mjs"
|
||||
"check-msrv": "node scripts/check-msrv.mjs",
|
||||
"generate-ci": "dist generate",
|
||||
"draft-release": "node scripts/draft-release.mjs"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import fs from 'fs';
|
||||
|
||||
const ciFile = fs.readFileSync('.github/workflows/release.yml', 'utf-8');
|
||||
const ciFile = fs.readFileSync('.github/workflows/release-vscode.yml', 'utf-8');
|
||||
|
||||
const checkMinVersion = ciFile.match(/# region: check-min-version([\s\S]+?)# end-region: check-min-version/mg);
|
||||
if (!checkMinVersion) {
|
||||
|
|
73
scripts/draft-release.mjs
Normal file
73
scripts/draft-release.mjs
Normal file
|
@ -0,0 +1,73 @@
|
|||
import { exec } from 'child_process';
|
||||
import fs from 'fs';
|
||||
|
||||
const versionToUpload = process.argv[2];
|
||||
|
||||
const run = (command) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const main = async () => {
|
||||
if (!versionToUpload) {
|
||||
console.error("Please provide the version to upload");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// read version from packages.json
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync('./editors/vscode/package.json', 'utf8')
|
||||
);
|
||||
if (packageJson.version !== versionToUpload) {
|
||||
console.error(`Version in Cargo.toml (${packageJson.version}) is different from the version to upload (${versionToUpload})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// run dist host command
|
||||
// remove target/distrib/dist-manifest.json which causes stateful announce...
|
||||
if (fs.existsSync('target/distrib/dist-manifest.json')) {
|
||||
fs.unlinkSync('target/distrib/dist-manifest.json');
|
||||
}
|
||||
const distManifest = await run('dist host --steps=upload --steps=release --output-format=json');
|
||||
const distData = JSON.parse(distManifest);
|
||||
const body = distData.announcement_github_body;
|
||||
// write to file
|
||||
fs.writeFileSync('target/announcement-dist.md', body);
|
||||
|
||||
// parse-changelog .\editors\vscode\CHANGELOG.md
|
||||
const changelogPlainRaw = await run('parse-changelog ./editors/vscode/CHANGELOG.md');
|
||||
// **Full Changelog**:
|
||||
// Patch the full changelog link
|
||||
const fullChangelogLine = /\*\*Full Changelog\*\*: https:\/\/github.com\/Myriad-Dreamin\/tinymist\/compare\/v(\d+\.\d+\.\d+)...v(\d+\.\d+\.\d+)/;
|
||||
let anyMatched = false;
|
||||
const changelogPlain = changelogPlainRaw.replace(fullChangelogLine, (_match, p1, p2) => {
|
||||
anyMatched = true;
|
||||
if (!versionToUpload.startsWith(p2)) {
|
||||
console.error(`Failed to patch the full changelog link, expected version to upload to start with ${p2}, but got ${versionToUpload}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
return `\*\*Full Changelog\*\*: https://github.com/Myriad-Dreamin/tinymist/compare/v${p1}...v${versionToUpload}`;
|
||||
});
|
||||
if (!anyMatched) {
|
||||
console.error("Failed to patch the full changelog link");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
fs.writeFileSync('target/announcement-changelog.md', changelogPlain);
|
||||
|
||||
|
||||
// concat and generate final announcement
|
||||
const announcement = `${changelogPlain}\n\n${body}`;
|
||||
fs.writeFileSync('target/announcement.gen.md', announcement);
|
||||
|
||||
console.log("Please check the generated announcement in target/announcement.gen.md");
|
||||
};
|
||||
|
||||
main();
|
Loading…
Add table
Add a link
Reference in a new issue